newfirtsCommit

This commit is contained in:
2026-02-24 08:17:51 -03:00
parent 569747f166
commit 98ab91c21a
27 changed files with 6 additions and 506 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
import{j as e}from"./query-vendor-BLVqILA6.js";import{d as w,r as t}from"./router-vendor-D4by-_6Z.js";import{s as i}from"./index-doec96Hx.js";import{a0 as j,c as b,a2 as N}from"./ui-vendor-CyRvbSfR.js";import"./react-vendor-CqRd3GwO.js";import"./supabase-vendor-CnnNSQLo.js";import"./state-vendor-DHadhBU5.js";const _=()=>{const o=w(),[s,c]=t.useState("loading"),[g,n]=t.useState("Processando autenticação..."),l=t.useCallback(async()=>{try{const a=new URLSearchParams(window.location.search),d=a.get("error"),x=a.get("error_description");if(d)throw new Error(x||d);const{data:{session:r},error:m}=await i.auth.getSession();if(m)throw m;if(!r)throw new Error("Nenhuma sessão encontrada");const{data:u,error:h}=await i.from("usuarios").select("id, organizacao_id").eq("id",r.user.id).single();if(!u&&h?.code==="PGRST116"){const{error:p}=await i.from("usuarios").insert({id:r.user.id,email:r.user.email,nome:r.user.user_metadata.full_name||r.user.email?.split("@")[0]})}c("success"),n("Login realizado com sucesso!");const f=u?.organizacao_id;setTimeout(()=>{o(f?"/":"/selecionar-organizacao")},1e3)}catch(a){c("error"),n(a instanceof Error?a.message:"Erro ao processar autenticação"),setTimeout(()=>{o("/login")},3e3)}},[o]);return t.useEffect(()=>{l()},[l]),e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 flex items-center justify-center p-4",children:e.jsx("div",{className:"bg-white rounded-2xl shadow-xl p-8 max-w-md w-full",children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[s==="loading"&&e.jsx(j,{className:"w-16 h-16 text-blue-500 animate-spin"}),s==="success"&&e.jsx(b,{className:"w-16 h-16 text-green-500"}),s==="error"&&e.jsx(N,{className:"w-16 h-16 text-red-500"}),e.jsxs("div",{className:"text-center",children:[e.jsxs("h2",{className:"text-2xl font-bold text-gray-900 mb-2",children:[s==="loading"&&"Processando...",s==="success"&&"Sucesso!",s==="error"&&"Erro"]}),e.jsx("p",{className:"text-gray-600",children:g})]}),s==="loading"&&e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-blue-500 h-2 rounded-full animate-pulse w-2/3"})}),s!=="loading"&&e.jsx("p",{className:"text-sm text-gray-500",children:s==="success"?"Redirecionando para o sistema...":"Redirecionando para o login..."})]})})})};export{_ as AuthCallback};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
import{j as M}from"./query-vendor-BLVqILA6.js";import{r as c}from"./router-vendor-D4by-_6Z.js";const E=()=>{const l=c.useRef(null),h=c.useRef(),n=c.useRef([]);return c.useEffect(()=>{const e=l.current;if(!e)return;const r=e.getContext("2d");if(!r)return;const f=()=>{e.width=window.innerWidth,e.height=window.innerHeight},u=()=>{const t=Math.floor(e.width*e.height/15e3);n.current=[];for(let a=0;a<t;a++)n.current.push({x:Math.random()*e.width,y:Math.random()*e.height,vx:(Math.random()-.5)*.5,vy:(Math.random()-.5)*.5})},g=t=>{r.beginPath(),r.arc(t.x,t.y,2,0,Math.PI*2),r.fillStyle="rgba(147, 197, 253, 0.8)",r.fill()},y=(t,a,i,o)=>{const s=1-i/o;r.beginPath(),r.moveTo(t.x,t.y),r.lineTo(a.x,a.y),r.strokeStyle=`rgba(147, 197, 253, ${s*.3})`,r.lineWidth=1,r.stroke()},v=()=>{n.current.forEach(t=>{t.x+=t.vx,t.y+=t.vy,(t.x<0||t.x>e.width)&&(t.vx*=-1),(t.y<0||t.y>e.height)&&(t.vy*=-1),t.x=Math.max(0,Math.min(e.width,t.x)),t.y=Math.max(0,Math.min(e.height,t.y))})},x=()=>{r.clearRect(0,0,e.width,e.height);const t=r.createLinearGradient(0,0,e.width,e.height);t.addColorStop(0,"#0f172a"),t.addColorStop(.5,"#1e1b4b"),t.addColorStop(1,"#581c87"),r.fillStyle=t,r.fillRect(0,0,e.width,e.height),v();const a=120;for(let i=0;i<n.current.length;i++)for(let o=i+1;o<n.current.length;o++){const s=n.current[i],d=n.current[o],w=Math.sqrt(Math.pow(s.x-d.x,2)+Math.pow(s.y-d.y,2));w<a&&y(s,d,w,a)}n.current.forEach(g),h.current=requestAnimationFrame(x)};f(),u(),x();const m=()=>{f(),u()};return window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m),h.current&&cancelAnimationFrame(h.current)}},[]),M.jsx("canvas",{ref:l,className:"fixed inset-0 w-full h-full -z-10",style:{background:"linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #581c87 100%)"}})};export{E as N};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
import{j as a}from"./query-vendor-BLVqILA6.js";import{r as o}from"./router-vendor-D4by-_6Z.js";import{m as s,I as l,am as i}from"./ui-vendor-CyRvbSfR.js";function n(){const[t,e]=o.useState(()=>{const r=localStorage.getItem("theme");return r||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")});return o.useEffect(()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(t),localStorage.setItem("theme",t)},[t]),{theme:t,toggleTheme:()=>{e(r=>r==="light"?"dark":"light")},isDark:t==="dark"}}function h(){const{toggleTheme:t,isDark:e}=n();return a.jsx(s.button,{onClick:t,className:"relative p-2 rounded-xl bg-white/70 dark:bg-gray-800/70 backdrop-blur-md border border-gray-200/50 dark:border-gray-700/50 shadow-lg hover:shadow-xl transition-all duration-300 group",whileHover:{scale:1.05},whileTap:{scale:.95},title:e?"Alternar para modo claro":"Alternar para modo escuro",children:a.jsxs("div",{className:"relative w-6 h-6",children:[a.jsx(s.div,{initial:!1,animate:{scale:e?0:1,rotate:e?180:0,opacity:e?0:1},transition:{duration:.3,ease:"easeInOut"},className:"absolute inset-0 flex items-center justify-center",children:a.jsx(l,{className:"w-5 h-5 text-yellow-500 group-hover:text-yellow-600"})}),a.jsx(s.div,{initial:!1,animate:{scale:e?1:0,rotate:e?0:-180,opacity:e?1:0},transition:{duration:.3,ease:"easeInOut"},className:"absolute inset-0 flex items-center justify-center",children:a.jsx(i,{className:"w-5 h-5 text-blue-400 group-hover:text-blue-300"})})]})})}export{h as T};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +0,0 @@
import{r as d}from"./router-vendor-D4by-_6Z.js";import{s as n}from"./index-doec96Hx.js";const w=()=>{const[g,s]=d.useState(!1),[m,t]=d.useState(null);return{loading:g,error:m,validarConvite:async i=>{try{s(!0),t(null);const e=i.toUpperCase().trim(),{data:r,error:a}=await n.from("convites").select(`
id,
codigo,
organizacao_id,
role,
max_usos,
usos_atuais,
ativo,
expira_em,
email_convidado,
organizacoes:organizacao_id (nome)
`).eq("codigo",e).eq("ativo",!0).single();if(a||!r)return{success:!1,error:"Código de convite inválido ou expirado."};const o=r;return o.expira_em&&new Date(o.expira_em)<new Date?{success:!1,error:"Este código de convite expirou."}:o.max_usos>0&&o.usos_atuais>=o.max_usos?{success:!1,error:"Este código de convite já atingiu o limite de usos."}:{success:!0,organizacao_id:o.organizacao_id,organizacao_nome:o.organizacoes?.nome||"Organização",role:o.role}}catch(e){const r=e instanceof Error?e.message:"Erro ao validar convite";return t(r),{success:!1,error:r}}finally{s(!1)}},usarConvite:async(i,e)=>{try{s(!0),t(null);const{data:r,error:a}=await n.rpc("usar_convite",{p_codigo:i,p_usuario_id:e});if(a)throw a;const o=r;return o.success||t(o.error||"Erro ao usar convite"),o}catch(r){const a=r instanceof Error?r.message:"Erro ao usar convite";return t(a),{success:!1,error:a}}finally{s(!1)}},gerarConvite:async(i,e={})=>{try{s(!0),t(null);const{data:r,error:a}=await n.rpc("gerar_codigo_convite");if(a)throw a;const o=r;let u=null;if(e.expiraEmDias){const c=new Date;c.setDate(c.getDate()+e.expiraEmDias),u=c.toISOString()}const{data:{user:f}}=await n.auth.getUser(),{error:l}=await n.from("convites").insert({organizacao_id:i,codigo:o,criado_por:f?.id,email_convidado:e.emailConvidado||null,role:e.role||"usuario",max_usos:e.maxUsos??1,expira_em:u});if(l)throw l;return{success:!0,codigo:o}}catch(r){const a=r instanceof Error?r.message:"Erro ao gerar convite";return t(a),{success:!1,error:a}}finally{s(!1)}},listarConvites:async i=>{try{s(!0);const{data:e,error:r}=await n.from("convites").select("*").eq("organizacao_id",i).order("created_at",{ascending:!1});if(r)throw r;return e||[]}catch{return[]}finally{s(!1)}}}};export{w as u};

View File

@@ -1 +0,0 @@
import{d,p as U,s as o}from"./index-doec96Hx.js";import{c as g}from"./state-vendor-DHadhBU5.js";import"./query-vendor-BLVqILA6.js";import"./router-vendor-D4by-_6Z.js";import"./react-vendor-CqRd3GwO.js";import"./ui-vendor-CyRvbSfR.js";import"./supabase-vendor-CnnNSQLo.js";const i={currentUser:null,users:[],loading:!1,error:null},m=g()(d(U((r,u)=>({...i,setCurrentUser:e=>r({currentUser:e},!1,"setCurrentUser"),setUsers:e=>r({users:e},!1,"setUsers"),setLoading:e=>r({loading:e},!1,"setLoading"),setError:e=>r({error:e},!1,"setError"),clearError:()=>r({error:null},!1,"clearError"),reset:()=>r(i,!1,"reset"),fetchCurrentUser:async e=>{try{r({loading:!0,error:null},!1,"fetchCurrentUser:start");const{data:s,error:a}=await o.from("usuarios").select("*").eq("id",e).single();if(a)throw a;r({currentUser:s,loading:!1},!1,"fetchCurrentUser:success")}catch(s){r({error:s.message||"Erro ao buscar usuário",loading:!1},!1,"fetchCurrentUser:error")}},fetchUsers:async()=>{try{r({loading:!0,error:null},!1,"fetchUsers:start");const{data:e,error:s}=await o.from("usuarios").select("*").order("nome");if(s)throw s;r({users:e||[],loading:!1},!1,"fetchUsers:success")}catch(e){r({error:e.message||"Erro ao buscar usuários",loading:!1},!1,"fetchUsers:error")}},updateUser:async(e,s)=>{try{r({loading:!0,error:null},!1,"updateUser:start");const{data:a,error:t}=await o.from("usuarios").update({...s,updated_at:new Date().toISOString()}).eq("id",e).select().single();if(t)throw t;const{users:n,currentUser:l}=u(),f=n.map(c=>c.id===e?a:c);return r({users:f,currentUser:l?.id===e?a:l,loading:!1},!1,"updateUser:success"),!0}catch(a){return r({error:a.message||"Erro ao atualizar usuário",loading:!1},!1,"updateUser:error"),!1}},createUser:async e=>{try{r({loading:!0,error:null},!1,"createUser:start");const{data:s,error:a}=await o.from("usuarios").insert(e).select().single();if(a)throw a;const{users:t}=u();return r({users:[...t,s],loading:!1},!1,"createUser:success"),!0}catch(s){return r({error:s.message||"Erro ao criar usuário",loading:!1},!1,"createUser:error"),!1}},deleteUser:async e=>{try{r({loading:!0,error:null},!1,"deleteUser:start");const{error:s}=await o.from("usuarios").delete().eq("id",e);if(s)throw s;const{users:a,currentUser:t}=u(),n=a.filter(l=>l.id!==e);return r({users:n,currentUser:t?.id===e?null:t,loading:!1},!1,"deleteUser:success"),!0}catch(s){return r({error:s.message||"Erro ao deletar usuário",loading:!1},!1,"deleteUser:error"),!1}}}),{name:"user-store",partialize:r=>({currentUser:r.currentUser,users:r.users})}))),b=()=>m(r=>r.currentUser);export{b as useCurrentUser,m as useUserStore};

12
dist/index.html vendored
View File

@@ -8,14 +8,14 @@
<meta name="theme-color" content="#2563eb" /> <meta name="theme-color" content="#2563eb" />
<link rel="manifest" href="/manifest.json" /> <link rel="manifest" href="/manifest.json" />
<title>RDO Mobile - Relatório Diário de Obra</title> <title>RDO Mobile - Relatório Diário de Obra</title>
<script type="module" crossorigin src="/assets/js/index-doec96Hx.js"></script> <script type="module" crossorigin src="/assets/js/index-DXLajEHZ.js"></script>
<link rel="modulepreload" crossorigin href="/assets/js/react-vendor-CqRd3GwO.js"> <link rel="modulepreload" crossorigin href="/assets/js/react-vendor-CqRd3GwO.js">
<link rel="modulepreload" crossorigin href="/assets/js/router-vendor-D4by-_6Z.js"> <link rel="modulepreload" crossorigin href="/assets/js/router-vendor-D4by-_6Z.js">
<link rel="modulepreload" crossorigin href="/assets/js/query-vendor-BLVqILA6.js"> <link rel="modulepreload" crossorigin href="/assets/js/query-vendor-Dc_G4OIP.js">
<link rel="modulepreload" crossorigin href="/assets/js/ui-vendor-CyRvbSfR.js"> <link rel="modulepreload" crossorigin href="/assets/js/ui-vendor-DHNIDV-1.js">
<link rel="modulepreload" crossorigin href="/assets/js/supabase-vendor-CnnNSQLo.js"> <link rel="modulepreload" crossorigin href="/assets/js/supabase-vendor-By1yMVW6.js">
<link rel="modulepreload" crossorigin href="/assets/js/state-vendor-DHadhBU5.js"> <link rel="modulepreload" crossorigin href="/assets/js/state-vendor-DK3LaRDK.js">
<link rel="stylesheet" crossorigin href="/assets/css/index-DXaaJsOA.css"> <link rel="stylesheet" crossorigin href="/assets/css/index-CYCdtjzd.css">
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>