1import{r as t,j as e,c as a,C as h,i as p,k as P,l as k,m as g,B as f,f as i,aQ as Ve,s as b,g as ke,o as fe,e as Pe}from"./main-WBJUeER2.js";import{fetchWithCache as De}from"./offlineCache-cXU_okv_.js";import{I as x}from"./input-BLqqkK6e.js";import{L as m}from"./label-NWWEjw9U.js";import{T as ye,a as ve,b as Y,c as S,d as _e,e as N}from"./table-Zl2zer5o.js";import{S as ee,a as ae,b as re,c as se,d as u}from"./select-1uZFFbj6.js";import{D as ne,a as te,b as oe,c as ce,d as ie,f as Te}from"./dialog-DFpN7EMj.js";import{A as Oe,a as Fe,b as Ie,c as qe,d as Re,e as je,f as Ge,g as Le}from"./alert-dialog-CCXu3Uc5.js";import{c as He,f as I}from"./employeeCostCalculator-CU8WI8hw.js";import{S as pe}from"./switch-DICV0CzG.js";import{S as xe}from"./shield-DRUKsB5S.js";import{E as ze}from"./eye-off-C4T-tUEa.js";import{E as Be}from"./eye-DrEQbBLD.js";import{f as K}from"./priceTiers-DYX_A2Du.js";import{f as Qe}from"./dateHelpers-CRc8Egvw.js";import{S as Ue}from"./shopping-cart-DPjTyRTn.js";import{D as le}from"./dollar-sign-D1d4GDdf.js";import{T as de}from"./trending-up-C2EwRYQE.js";import{C as $e}from"./clipboard-list-BLK0WHx6.js";import{F as Ne}from"./file-text-DgROvEGV.js";import{U as Ye}from"./UpgradePrompt-BKCkHV_2.js";import{u as We}from"./useLicense-B-OanmIu.js";import{P as Xe}from"./plane-CvKJJnfd.js";import{T as Je}from"./trophy-C72oDJoM.js";import{U as Ze}from"./user-cog-BB1uVMGx.js";import{U as Ke}from"./users-BRCZEtHr.js";import{B as ea}from"./briefcase-DMp0pphc.js";import{P as aa}from"./plus-B6bc_aKB.js";import{P as ra}from"./pencil-DiWWu1pX.js";import{T as ge}from"./trash-2-CEhUq0QO.js";import"./preload-helper-BxaVoaJg.js";import"./userStorage-BhzqXAfE.js";import"./index-BdQq_4o_.js";import"./index-DbXx9bUk.js";import"./index-Dab39HQC.js";import"./index-D9LsUG_D.js";import"./chevron-down-CYA6Q4p2.js";import"./check-C9VL1YF8.js";import"./chevron-up-fth9-Z__.js";import"./index-Dmb49cMn.js";import"./format-D2ynJLjf.js";import"./en-US-UHYFB6YK.js";import"./parseISO-CMVrCGvT.js";import"./trending-down-eskoO55j.js";import"./target-B9HivrzC.js";import"./megaphone-ClhL43LF.js";import"./house-uCduJntS.js";import"./chart-column-LAGQ_Df0.js";import"./message-circle-W-ylwqB8.js";import"./ticket-DTeI-PC4.js";import"./zap-BVZ3oraD.js";import"./crown-Zf2rVwBq.js";import"./LicenseService-BMWotS9y.js";import"./funnelTelemetry-pOivtfZb.js";const sa={canViewDashboard:"ð Ver Dashboard",canSell:"ð° Realizar Vendas (PDV)",canCreateQuotes:"ð Criar Orçamentos",canViewOrders:"ð¦ Ver Pedidos",canViewServiceOrders:"ð§ Ver Ordens de Serviço",canViewCustomers:"ð¥ Ver Clientes",canViewProducts:"ð¦ Ver Produtos",canManageCash:"ðµ Gerenciar Caixa",canManageStock:"ð¦ Gerenciar Estoque",canEditPrices:"ð² Editar Preços",canViewReports:"ð Ver Relatórios",canManageCoupons:"ðï¸ Gerenciar Cupons",canManageMarketing:"ð¢ Gerenciar Marketing",canAccessFinancial:"ð° Acessar Financeiro",canManageEmployees:"ð¨âð¼ Gerenciar Funcionários",canManageSuppliers:"ð Gerenciar Fornecedores",canAccessSettings:"âï¸ Acessar Configurações",canAccessIntelligence:"ð§ Acessar Inteligência",canAccessTools:"ð§ Acessar Ferramentas",canManageAICredits:"⨠Gerenciar Créditos IA"};function na({open:A,onOpenChange:w,employeeId:_,employeeName:M,currentCanAccess:D=!1,currentPermissions:H}){const[E,q]=t.useState(D),[c,R]=t.useState(""),[n,z]=t.useState(!1),[T,j]=t.useState(!1),[y,G]=t.useState(H||{canViewDashboard:!0,canSell:!0,canCreateQuotes:!0,canViewOrders:!0,canViewServiceOrders:!1,canViewCustomers:!0,canViewProducts:!0,canManageCash:!1,canManageStock:!1,canEditPrices:!1,canViewReports:!1,canManageCoupons:!1,canManageMarketing:!1,canAccessFinancial:!1,canManageEmployees:!1,canManageSuppliers:!1,canAccessSettings:!1,canAccessIntelligence:!1,canAccessTools:!1,canManageAICredits:!1}),l=o=>{G(v=>({...v,[o]:!v[o]}))},C={"operador-pdv":{canViewDashboard:!0,canSell:!0,canCreateQuotes:!0,canViewOrders:!0,canViewServiceOrders:!1,canViewCustomers:!0,canViewProducts:!0,canManageCash:!1,canManageStock:!1,canEditPrices:!1,canViewReports:!1,canManageCoupons:!1,canManageMarketing:!1,canAccessFinancial:!1,canManageEmployees:!1,canManageSuppliers:!1,canAccessSettings:!1,canAccessIntelligence:!1,canAccessTools:!1,canManageAICredits:!1},"gerente-loja":{canViewDashboard:!0,canSell:!0,canCreateQuotes:!0,canViewOrders:!0,canViewServiceOrders:!0,canViewCustomers:!0,canViewProducts:!0,canManageCash:!0,canManageStock:!0,canEditPrices:!0,canViewReports:!0,canManageCoupons:!0,canManageMarketing:!0,canAccessFinancial:!1,canManageEmployees:!1,canManageSuppliers:!1,canAccessSettings:!1,canAccessIntelligence:!1,canAccessTools:!0,canManageAICredits:!1},"gerente-producao":{canViewDashboard:!0,canSell:!1,canCreateQuotes:!1,canViewOrders:!0,canViewServiceOrders:!0,canViewCustomers:!1,canViewProducts:!0,canManageCash:!1,canManageStock:!0,canEditPrices:!1,canViewReports:!0,canManageCoupons:!1,canManageMarketing:!1,canAccessFinancial:!1,canManageEmployees:!0,canManageSuppliers:!0,canAccessSettings:!1,canAccessIntelligence:!1,canAccessTools:!0,canManageAICredits:!1},"gerente-geral":{canViewDashboard:!0,canSell:!0,canCreateQuotes:!0,canViewOrders:!0,canViewServiceOrders:!0,canViewCustomers:!0,canViewProducts:!0,canManageCash:!0,canManageStock:!0,canEditPrices:!0,canViewReports:!0,canManageCoupons:!0,canManageMarketing:!0,canAccessFinancial:!0,canManageEmployees:!0,canManageSuppliers:!0,canAccessSettings:!0,canAccessIntelligence:!0,canAccessTools:!0,canManageAICredits:!0},marketing:{canViewDashboard:!0,canSell:!1,canCreateQuotes:!1,canViewOrders:!0,canViewServiceOrders:!1,canViewCustomers:!0,canViewProducts:!0,canManageCash:!1,canManageStock:!1,canEditPrices:!1,canViewReports:!0,canManageCoupons:!0,canManageMarketing:!0,canAccessFinancial:!1,canManageEmployees:!1,canManageSuppliers:!1,canAccessSettings:!1,canAccessIntelligence:!0,canAccessTools:!1,canManageAICredits:!1}},B=o=>{const v=C[o];if(v){G(v);const Q={"operador-pdv":"Operador PDV","gerente-loja":"Gerente de Loja","gerente-producao":"Gerente de Produção","gerente-geral":"Gerente Geral",marketing:"Marketing"};i.success(`Perfil "${Q[o]||o}" aplicado!`)}},X=async()=>
1{if(E&&!c&&!D){i.error("Digite um PIN de 4 a 6 dÃgitos");return}if(c&&(c.length<4||c.length>6)){i.error("PIN deve ter entre 4 e 6 dÃgitos");return}j(!0);try{const o={can_access_system:E,permissions:y};if(c){const Q=await Ve.hash(c,10);o.pin_hash=Q}const{error:v}=await b.from("employees").update(o).eq("id",_);if(v)throw v;i.success("Configurações salvas com sucesso!"),w(!1),setTimeout(()=>{window.location.reload()},500)}catch(o){console.error("Erro ao salvar:",o),i.error("Erro ao salvar configurações")}finally{j(!1)}};return e(ne,{open:A,onOpenChange:w,children:a(te,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[a(oe,{children:[a(ce,{className:"flex items-center gap-2",children:[e(xe,{className:"h-5 w-5"}),"Gerenciar Acesso: ",M]}),e(ie,{children:"Configure o acesso ao sistema e as permissões do funcionário"})]}),a("div",{className:"space-y-6",children:[a(h,{children:[e(p,{children:a("div",{className:"flex items-center justify-between",children:[a("div",{children:[e(P,{className:"text-lg",children:"Acesso ao Sistema"}),e(k,{children:"Permitir que este funcionário faça login"})]}),e(pe,{checked:E,onCheckedChange:q})]})}),E&&e(g,{className:"space-y-4",children:a("div",{className:"space-y-2",children:[e(m,{htmlFor:"pin",children:"PIN de Acesso (4-6 dÃgitos)"}),a("div",{className:"relative",children:[e(x,{id:"pin",type:n?"text":"password",placeholder:D?"Digite para alterar o PIN":"â¢â¢â¢â¢",value:c,onChange:o=>R(o.target.value.replace(/\D/g,"").slice(0,6)),maxLength:6,className:"pr-10"}),e(f,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full",onClick:()=>z(!n),children:n?e(ze,{className:"h-4 w-4"}):e(Be,{className:"h-4 w-4"})})]}),D&&!c&&e("p",{className:"text-xs text-muted-foreground",children:"Deixe em branco para manter o PIN atual"})]})})]}),E&&a(h,{children:[a(p,{children:[e(P,{className:"text-lg",children:"Permissões"}),e(k,{children:"Selecione o que este funcionário pode fazer no sistema"})]}),a(g,{className:"space-y-4",children:[a("div",{className:"space-y-2",children:[e(m,{children:"Aplicar Perfil Padrão"}),a(ee,{onValueChange:B,children:[e(ae,{children:e(re,{placeholder:"Selecione um perfil pré-configurado"})}),a(se,{children:[e(u,{value:"operador-pdv",children:"ð° Operador PDV (vendas e orçamentos)"}),e(u,{value:"gerente-loja",children:"ðª Gerente de Loja (vendas + estoque + caixa)"}),e(u,{value:"gerente-producao",children:"ð· Gerente de Produção (OS + estoque + funcionários)"}),e(u,{value:"gerente-geral",children:"ð Gerente Geral (acesso completo)"}),e(u,{value:"marketing",children:"ð¢ Marketing (cupons + campanhas + análises)"})]})]}),e("p",{className:"text-xs text-muted-foreground",children:"Escolha um perfil padrão ou personalize as permissões abaixo"})]}),e("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:Object.keys(y).map(o=>a("div",{className:"flex items-center justify-between p-3 rounded-lg border hover:bg-accent cursor-pointer",onClick:()=>l(o),children:[e("span",{className:"text-sm",children:sa[o]}),e(pe,{checked:y[o],onCheckedChange:()=>l(o)})]},o))})]})]}),a("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e(f,{variant:"outline",onClick:()=>w(!1),disabled:T,children:"Cancelar"}),e(f,{onClick:X,disabled:T,children:T?"Salvando...":"Salvar Configurações"})]})]})]})})}function ta({employeeId:A,employeeName:w}){const{user:_}=ke(),[M,D]=t.useState({totalSales:0,totalAmount:0,averageTicket:0,totalOrders:0,totalQuotes:0}),[H,E]=t.useState([]),[q,c]=t.useState(!0);t.useEffect(()=>{R()},[A]);const R=async()=>{if(!(!_||!A))try{c(!0);const{data:n}=await b.from("sales").select("id, created_at, total_amount, subtotal, payment_method").eq("user_id",_.id).eq("employee_id",A).order("created_at",{ascending:!1}).limit(10),z=(n==null?void 0:n.length)||0,T=(n==null?void 0:n.reduce((l,C)=>l+(C.subtotal||0),0))||0,j=z>0?T/z:0;let y=0;try{const{count:l,error:C}=await b.from("orders").select("id",{count:"exact",head:!0}).eq("user_id",_.id).eq("employee_id",A);C?console.warn("â ï¸ employee_id não existe em orders. Execute ADICIONAR_EMPLOYEE_ID_TABELAS_RESTANTES.sql"):y=l||0}catch(l){console.warn("â ï¸ Erro ao buscar orders:",l)}let G=0;try{const{count:l,error:C}=await b.from("quotes").select("id",{count:"exact",head:!0}).eq("user_id",_.id).eq("employee_id",A);C?console.warn("â ï¸ employee_id não existe em quotes. Execute ADICIONAR_EMPLOYEE_ID_TABELAS_RESTANTES.sql"):G=l||0}catch(l){console.warn("â ï¸ Erro ao buscar quotes:",l)}D({totalSales:z,totalAmount:T,averageTicket:j,totalOrders:y||0,totalQuotes:G||0}),E(n||[])}catch(n){console.error("Erro ao carregar estatÃsticas do funcionário:",n)}finally{c(!1)}};return q?a(h,{children:[e(p,{children:e(P,{children:"Histórico de Vendas"})}),e(g,{children:e("p",{className:"text-muted-foreground",children:"Carregando..."})})]}):a("div",{className:"space-y-6",children:[a("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-5 ga
1p-4",children:[a(h,{children:[e(p,{className:"pb-2",children:a(k,{className:"flex items-center gap-2",children:[e(Ue,{className:"h-4 w-4"}),"Total de Vendas"]})}),e(g,{children:e("div",{className:"text-2xl font-bold",children:M.totalSales})})]}),a(h,{children:[e(p,{className:"pb-2",children:a(k,{className:"flex items-center gap-2",children:[e(le,{className:"h-4 w-4"}),"Valor Total"]})}),e(g,{children:e("div",{className:"text-2xl font-bold text-green-600",children:K(M.totalAmount)})})]}),a(h,{children:[e(p,{className:"pb-2",children:a(k,{className:"flex items-center gap-2",children:[e(de,{className:"h-4 w-4"}),"Ticket Médio"]})}),e(g,{children:e("div",{className:"text-2xl font-bold text-blue-600",children:K(M.averageTicket)})})]}),a(h,{children:[e(p,{className:"pb-2",children:a(k,{className:"flex items-center gap-2",children:[e($e,{className:"h-4 w-4"}),"Pedidos"]})}),e(g,{children:e("div",{className:"text-2xl font-bold",children:M.totalOrders})})]}),a(h,{children:[e(p,{className:"pb-2",children:a(k,{className:"flex items-center gap-2",children:[e(Ne,{className:"h-4 w-4"}),"Orçamentos"]})}),e(g,{children:e("div",{className:"text-2xl font-bold",children:M.totalQuotes})})]})]}),a(h,{children:[a(p,{children:[e(P,{children:"Ãltimas 10 Vendas"}),a(k,{children:["Vendas realizadas por ",w]})]}),e(g,{children:H.length===0?e("p",{className:"text-muted-foreground text-center py-8",children:"Nenhuma venda registrada ainda"}):a(ye,{children:[e(ve,{children:a(Y,{children:[e(S,{children:"Data"}),e(S,{children:"Valor"}),e(S,{children:"Pagamento"})]})}),e(_e,{children:H.map(n=>a(Y,{children:[e(N,{children:Qe(n.created_at)}),e(N,{className:"font-semibold",children:K(n.total_amount)}),e(N,{children:e(fe,{variant:"outline",children:n.payment_method==="cash"?"Dinheiro":n.payment_method==="pix"?"PIX":n.payment_method==="credit_card"?"Cartão Crédito":n.payment_method==="debit_card"?"Cartão Débito":n.payment_method})})]},n.id))})]})})]})]})}function or(){const{isPro:A}=We(),w=Pe(),[_,M]=t.useState([]),[D,H]=t.useState(!0),[E,q]=t.useState(!1),[c,R]=t.useState(null),[n,z]=t.useState(""),[T,j]=t.useState(!1),[y,G]=t.useState(null),[l,C]=t.useState(!1),[B,X]=t.useState(null),[o,v]=t.useState(!1),[Q,me]=t.useState(null),[s,d]=t.useState({name:"",position:"",phone:"",salary:"",category:"production",department:"production",commission_percentage:"",monthly_sales_goal:"",goal_bonus_percentage:"",work_hours_per_day:"8",work_days_per_month:"22"});t.useEffect(()=>{J()},[]);const J=async()=>{try{const{data:{user:r}}=await b.auth.getUser();if(!r)return;const L=await De("employees",async()=>{const{data:$,error:U}=await b.from("employees").select("*").eq("user_id",r.id).order("category, name");if(U)throw U;return($||[]).map(F=>({...F,category:F.category||"production",hourly_rate:F.hourly_rate||0,work_hours_per_day:F.work_hours_per_day||8,work_days_per_month:F.work_days_per_month||22}))},30);M(L.data)}catch(r){console.error("Erro ao carregar funcionários:",r),i.error("Erro ao carregar funcionários")}finally{H(!1)}},we=async()=>{if(!s.name){i.error("O nome é obrigatório");return}try{const{data:{user:r}}=await b.auth.getUser();if(!r)return;const L=parseFloat(s.salary)||0,$=parseFloat(s.work_hours_per_day)||8,U=parseInt(s.work_days_per_month)||22,W=parseFloat(s.commission_percentage)||0,F=parseFloat(s.monthly_sales_goal)||0,Z=parseFloat(s.goal_bonus_percentage)||0;if($<=0||U<=0){i.error("Horas/dia e Dias/mês devem ser maiores que zero");return}const ue=V=>Math.min(100,Math.max(0,V)),Ae=ue(W),Me=ue(Z);if(Ae!==W){i.error("Comissão (%) deve estar entre 0 e 100");return}if(Me!==Z){i.error("Bônus ao Atingir Meta (%) deve estar entre 0 e 100");return}if(L<0||F<0){i.error("Valores não podem ser negativos");return}const Ee=L/(U*$),he={user_id:r.id,name:s.name,position:s.position||null,phone:s.phone||null,salary:L,category:s.category,department:s.department||"production",commission_percentage:W,monthly_sales_goal:F,goal_bonus_percentage:Z,work_hours_per_day:$,work_days_per_month:U,hourly_rate:Ee};if(c){const{error:V}=await b.from("employees").update(he).eq("id",c.id);if(V)throw console.error("Erro completo:",V),V;i.success("Funcionário atualizado")}else{const{error:V}=await b.from("employees").insert(he);if(V)throw console.error("Erro completo:",V),V;i.success("Funcionário adicionado")}d({name:"",position:"",phone:"",salary:"",category:"production",department:"production",commission_percentage:"",monthly_sales_goal:"",goal_bonus_percentage:"",work_hours_per_day:"8",work_days_per_month:"22"}),R(null),q(!1),J()}catch(r){console.error("Erro ao salvar funcionário:",r);const L=typeof r=="object"&&r&&"message"in r?String(r.message):"Erro desconhecido";i.error(`Erro ao salvar funcionário: ${L}`)}},Ce=r=>{R(r),d({name:r.name,position:r.position||"",phone:r.phone||"",salary:r.salary.toString(),category:r.category,department:r.department||"production",commission_percentage:(r.commission_percentage||0).toString(),monthly_sales_goal:(r.monthly_sales_goal||0
1).toString(),goal_bonus_percentage:(r.goal_bonus_percentage||0).toString(),work_hours_per_day:r.work_hours_per_day.toString(),work_days_per_month:r.work_days_per_month.toString()}),q(!0)},Se=async r=>{me(r),v(!0)},be=async()=>{if(Q)try{const{error:r}=await b.from("employees").delete().eq("id",Q);if(r)throw r;i.success("Funcionário excluÃdo"),J()}catch(r){console.error("Erro ao excluir funcionário:",r),i.error("Erro ao excluir funcionário")}finally{me(null),v(!1)}};if(D)return e("div",{className:"flex items-center justify-center h-96",children:"Carregando..."});const O=He(_);return A?a("div",{className:"container mx-auto p-6 space-y-6",children:[a("div",{className:"flex items-center justify-between",children:[a("div",{children:[e("h1",{className:"text-3xl font-bold",children:"Funcionários"}),e("p",{className:"text-muted-foreground",children:"Gerencie sua equipe e custos de mão de obra"})]}),a("div",{className:"flex items-center gap-2",children:[a(f,{variant:"outline",onClick:()=>w("/employees/vacations"),children:[e(Xe,{className:"h-4 w-4 mr-2"}),"Férias"]}),a(f,{variant:"outline",onClick:()=>w("/employees/ranking"),children:[e(Je,{className:"h-4 w-4 mr-2"}),"Ranking"]}),a(f,{variant:"outline",onClick:()=>w("/employees/commissions"),children:[e(le,{className:"h-4 w-4 mr-2"}),"Comissões"]}),a(f,{variant:"outline",onClick:()=>w("/employees/audit-log"),children:[e(Ne,{className:"h-4 w-4 mr-2"}),"Logs de Auditoria"]}),e(Ze,{className:"h-8 w-8 text-primary"})]})]}),a("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[a(h,{children:[a(p,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e(P,{className:"text-sm font-medium",children:"Total Funcionários"}),e(Ke,{className:"h-4 w-4 text-muted-foreground"})]}),a(g,{children:[e("div",{className:"text-2xl font-bold",children:O.totalEmployees}),a("p",{className:"text-xs text-muted-foreground",children:[O.productionEmployees," produção / ",O.administrativeEmployees," admin"]})]})]}),a(h,{children:[a(p,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e(P,{className:"text-sm font-medium",children:"Custo Total Mensal"}),e(le,{className:"h-4 w-4 text-muted-foreground"})]}),a(g,{children:[e("div",{className:"text-2xl font-bold",children:I(O.totalMonthlyCost)}),a("p",{className:"text-xs text-muted-foreground",children:["Produção: ",I(O.productionMonthlyCost)]})]})]}),a(h,{children:[a(p,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e(P,{className:"text-sm font-medium",children:"Overhead/Hora"}),e(de,{className:"h-4 w-4 text-muted-foreground"})]}),a(g,{children:[e("div",{className:"text-2xl font-bold",children:I(O.overheadRate)}),a("p",{className:"text-xs text-muted-foreground",children:["Admin: ",I(O.administrativeMonthlyCost)]})]})]}),a(h,{children:[a(p,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e(P,{className:"text-sm font-medium",children:"Média Produção"}),e(ea,{className:"h-4 w-4 text-muted-foreground"})]}),a(g,{children:[a("div",{className:"text-2xl font-bold",children:[I(O.avgProductionRate),"/h"]}),e("p",{className:"text-xs text-muted-foreground",children:"Valor hora médio da produção"})]})]})]}),a(h,{children:[e(p,{children:a("div",{className:"flex items-center justify-between",children:[a("div",{children:[e(P,{children:"Lista de Funcionários"}),a(k,{children:["Total: ",_.length," funcionários cadastrados"]})]}),a(ne,{open:E,onOpenChange:q,children:[e(Te,{asChild:!0,children:a(f,{onClick:()=>{R(null),d({name:"",position:"",phone:"",salary:"",category:"production",department:"production",commission_percentage:"",monthly_sales_goal:"",goal_bonus_percentage:"",work_hours_per_day:"8",work_days_per_month:"22"})},children:[e(aa,{className:"mr-2 h-4 w-4"}),"Novo Funcionário"]})}),a(te,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[a(oe,{children:[e(ce,{children:c?"Editar Funcionário":"Novo Funcionário"}),e(ie,{children:c?"Atualize as informações do funcionário":"Cadastre um novo funcionário"})]}),a("div",{className:"space-y-4 py-4",children:[a("div",{className:"space-y-2",children:[e(m,{children:"Nome *"}),e(x,{placeholder:"Nome completo",value:s.name,onChange:r=>d({...s,name:r.target.value})})]}),a("div",{className:"space-y-2",children:[e(m,{children:"Categoria *"}),a(ee,{value:s.category,onValueChange:r=>d({...s,category:r}),children:[e(ae,{children:e(re,{placeholder:"Selecione a categoria"})}),a(se,{children:[e(u,{value:"production",children:"ð· Produção (selecionável por produto)"}),e(u,{value:"administrative",children:"ð¢ Administrativo (overhead distribuÃdo)"}),e(u,{value:"commission",children:"ð° Vendedor de Comissão (sem salário fixo)"})]})]}),e("p",{className:"text-xs text-muted-foreground",children:s.category==="production"?"Funcionário de produção pode ser selecionado especificamente para cada produto":s.category==="administrative"?"Custos administrativos são distribuÃdos automaticamente como overhead":"Vendedor que recebe apen
1as comissão â não gera entrada na folha de pagamento; a remuneração é registrada automaticamente ao liberar a comissão no financeiro"})]}),a("div",{className:"space-y-2",children:[e(m,{children:"Departamento *"}),a(ee,{value:s.department,onValueChange:r=>d({...s,department:r}),children:[e(ae,{children:e(re,{placeholder:"Selecione o departamento"})}),a(se,{children:[e(u,{value:"production",children:"ð· Produção"}),e(u,{value:"design",children:"ð¨ Design"}),e(u,{value:"marketing",children:"ð¢ Marketing"}),e(u,{value:"sales",children:"ð° Vendas"}),e(u,{value:"administrative",children:"ð Administrativo"}),e(u,{value:"support",children:"ð ï¸ Suporte"})]})]}),e("p",{className:"text-xs text-muted-foreground",children:s.department==="production"?"â ï¸ Salário NÃO conta automaticamente (você seleciona manualmente na precificação)":"â
Salário CONTA automaticamente como custo fixo mensal"})]}),a("div",{className:"space-y-2",children:[e(m,{children:"Cargo"}),e(x,{placeholder:"Ex: Designer Gráfico",value:s.position,onChange:r=>d({...s,position:r.target.value})})]}),a("div",{className:"space-y-2",children:[e(m,{children:"Telefone"}),e(x,{placeholder:"(00) 00000-0000",value:s.phone,onChange:r=>d({...s,phone:r.target.value})})]}),a("div",{className:"grid grid-cols-2 gap-4",children:[a("div",{className:"space-y-2",children:[e(m,{children:"Salário Mensal *"}),e(x,{type:"number",step:"0.01",placeholder:"0.00",value:s.salary,onChange:r=>d({...s,salary:r.target.value})})]}),a("div",{className:"space-y-2",children:[e(m,{children:"Valor/Hora"}),e(x,{type:"text",disabled:!0,value:s.salary&&parseFloat(s.salary)>0?I(parseFloat(s.salary)/(parseInt(s.work_days_per_month)*parseFloat(s.work_hours_per_day))):"R$ 0,00",className:"bg-muted"})]})]}),a("div",{className:"grid grid-cols-2 gap-4",children:[a("div",{className:"space-y-2",children:[e(m,{children:"Comissão (%)"}),e(x,{type:"number",step:"0.01",placeholder:"0.00",value:s.commission_percentage,onChange:r=>d({...s,commission_percentage:r.target.value})}),e("p",{className:"text-xs text-muted-foreground",children:"Ex: 5 = 5% sobre vendas"})]}),a("div",{className:"space-y-2",children:[e(m,{children:"Meta Mensal (R$)"}),e(x,{type:"number",step:"0.01",placeholder:"0.00",value:s.monthly_sales_goal,onChange:r=>d({...s,monthly_sales_goal:r.target.value})}),e("p",{className:"text-xs text-muted-foreground",children:"Meta de vendas do mês"})]})]}),a("div",{className:"space-y-2",children:[e(m,{children:"Bônus ao Atingir Meta (%)"}),e(x,{type:"number",step:"0.01",min:"0",max:"100",placeholder:"0.00",value:s.goal_bonus_percentage,onChange:r=>d({...s,goal_bonus_percentage:r.target.value})}),e("p",{className:"text-xs text-muted-foreground",children:"ð Percentual extra sobre base lÃquida quando a meta mensal é atingida (ex: 2 = +2%)"})]}),a("div",{className:"grid grid-cols-2 gap-4",children:[a("div",{className:"space-y-2",children:[e(m,{children:"Horas/Dia"}),e(x,{type:"number",step:"0.5",placeholder:"8",value:s.work_hours_per_day,onChange:r=>d({...s,work_hours_per_day:r.target.value})})]}),a("div",{className:"space-y-2",children:[e(m,{children:"Dias/Mês"}),e(x,{type:"number",placeholder:"22",value:s.work_days_per_month,onChange:r=>d({...s,work_days_per_month:r.target.value})})]})]}),e(f,{onClick:we,className:"w-full",children:c?"Atualizar":"Adicionar"})]})]})]})]})}),e(g,{children:a(ye,{children:[e(ve,{children:a(Y,{children:[e(S,{children:"Nome"}),e(S,{children:"Categoria"}),e(S,{children:"Cargo"}),e(S,{children:"Salário/Mês"}),e(S,{children:"Valor/Hora"}),e(S,{children:"Acesso"}),e(S,{children:"Ações"})]})}),e(_e,{children:_.length===0?e(Y,{children:e(N,{colSpan:7,className:"text-center text-muted-foreground",children:"Nenhum funcionário cadastrado"})}):_.map(r=>a(Y,{children:[e(N,{className:"font-medium",children:r.name}),e(N,{children:e(fe,{variant:r.category==="production"?"default":r.category==="commission"?"outline":"secondary",children:r.category==="production"?"ð· Produção":r.category==="commission"?"ð° Comissão":"ð¢ Admin"})}),e(N,{children:r.position||"-"}),e(N,{className:"font-bold",children:I(r.salary)}),a(N,{className:"text-primary font-semibold",children:[I(r.hourly_rate),"/h"]}),e(N,{children:a(f,{size:"sm",variant:r.can_access_system?"default":"outline",onClick:()=>{G(r),j(!0)},children:[e(xe,{className:"h-3 w-3 mr-1"}),r.can_access_system?"Ativo":"Config"]})}),e(N,{children:a("div",{className:"flex gap-2",children:[a(f,{size:"sm",variant:"secondary",onClick:()=>{X(r),C(!0)},children:[e(de,{className:"h-3 w-3 mr-1"}),"Vendas"]}),e(f,{size:"sm",variant:"outline",onClick:()=>Ce(r),children:e(ra,{className:"h-3 w-3"})}),e(f,{size:"sm",variant:"destructive",onClick:()=>
1Se(r.id),children:e(ge,{className:"h-3 w-3"})})]})})]},r.id))})]})})]}),y&&e(na,{open:T,onOpenChange:j,employeeId:y.id,employeeName:y.name,currentCanAccess:y.can_access_system,currentPermissions:y.permissions}),B&&e(ne,{open:l,onOpenChange:C,children:a(te,{className:"max-w-6xl max-h-[90vh] overflow-y-auto",children:[a(oe,{children:[a(ce,{children:["Histórico de Vendas - ",B.name]}),e(ie,{children:"Visualize todas as vendas, pedidos e orçamentos realizados por este funcionário"})]}),e(ta,{employeeId:B.id,employeeName:B.name})]})}),e(Oe,{open:o,onOpenChange:v,children:a(Fe,{className:"max-w-sm",children:[a(Ie,{children:[e("div",{className:"flex items-center justify-center w-12 h-12 mx-auto mb-2 rounded-full bg-red-100 dark:bg-red-950/40",children:e(ge,{className:"h-6 w-6 text-red-600 dark:text-red-400"})}),e(qe,{className:"text-center",children:"Excluir funcionário?"}),e(Re,{className:"text-center",children:"Esta ação não pode ser desfeita. O funcionário será removido permanentemente do sistema, incluindo seus dados de acesso e histórico."})]}),a(je,{className:"flex-col gap-2 sm:flex-row",children:[e(Ge,{className:"w-full sm:w-auto",children:"Cancelar"}),e(Le,{onClick:be,className:"w-full sm:w-auto bg-red-600 hover:bg-red-700 dark:bg-red-700 dark:hover:bg-red-600 focus:ring-red-600",children:"Sim, excluir"})]})]})})]}):e(Ye,{feature:"employees"})}export{or as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.