PageSourceSearch

https://giftlove-novo.lovable.app/assets/ExpenseNewPage-CABphwS2.js

js giftlove-novo.lovable.app collected 2026-10-03 03:29:17 UTC 4,174 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-motion-D_eWtC2i.js";import{u as x,r as h}from"./vendor-react-C5-rmG_I.js";import{P as y}from"./PageHeader-B-h5e2bL.js";import{B as i,A as g,m as j,K as v,O as c}from"./index-BB35H7Wo.js";import{I as d}from"./input-ChxEbcIp.js";import{L as l}from"./label-BS3ES4Lh.js";import{T as f}from"./textarea-B57HOCBF.js";import{S as N,a as C,b as E,c as k,d as S}from"./select-x5tgiaXZ.js";import{u as w,E as A,W as I}from"./useCompanyExpenses-BVQfeX1h.js";import b from"./trending-down-BVd6xgTD.js";import D from"./arrow-up-from-line-Dit3GB6j.js";import{f as T}from"./format-CXUDrD0n.js";import"./vendor-supabase-CfDyWxaF.js";import"./vendor-charts-BzSnLuq2.js";import"./index-BdQq_4o_.js";import"./index-Bnb-0OWf.js";import"./chevron-up-BItnVi1a.js";import"./en-US-BMDxpvZG.js";const m="/admin/financeiro/despesas",_=()=>T(new Date,"yyyy-MM-dd"),F=o=>{const n=o.trim();return n?n.includes(",")?Number(n.replace(/\./g,"").replace(",",".")):Number(n):NaN},Y=()=>{const o=x(),n=w(),[r,s]=h.useState({kind:"expense",entry_date:_(),category:"",amount:"",recipient:"",description:""}),p=r.kind==="expense"?A:I,u=async()=>{const a=F(r.amount);if(!r.category){c.error("Escolha a categoria.");return}if(!Number.isFinite(a)||a<=0){c.error("Informe um valor válido maior que zero.");return}if(!r.entry_date){c.error("Informe a data.");return}try{await n.mutateAsync({entry_date:r.entry_date,kind:r.kind,category:r.category,amount:a,recipient:r.recipient.trim()||null,description:r.description.trim()||null}),c.success(r.kind==="expense"?"Despesa lançada.":"Retirada registrada."),o(m)}catch(t){c.error((t==null?void 0:t.message)||"Erro ao salvar o lançamento.")}};return e.jsxs("div",{className:"p-4 md:p-6 space-y-6 max-w-2xl",children:[e.jsx(y,{title:"Novo lançamento",description:"Despesa da operação ou valor retirado da conta da empresa",children:e.jsxs(i,{variant:"outline",onClick:()=>o(m),children:[e.jsx(g,{className:"mr-2 h-4 w-4"})," Voltar"]})}),e.jsx(j,{children:e.jsxs(v,{className:"p-4 md:p-6 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs(i,{type:"button",variant:r.kind==="expense"?"default":"outline",onClick:()=>s(a=>({...a,kind:"expense",category:""})),children:[e.jsx(b,{className:"w-4 h-4 mr-1"})," Despesa"]}),e.jsxs(i,{type:"button",variant:r.kind==="withdrawal"?"default":"outline",onClick:()=>s(a=>({...a,kind:"withdrawal",category:""})),children:[e.jsx(D,{className:"w-4 h-4 mr-1"})," Retirada da conta"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(l,{htmlFor:"entry-date",children:"Data"}),e.jsx(d,{id:"entry-date",type:"date",value:r.entry_date,onChange:a=>s(t=>({...t,entry_date:a.target.value}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(l,{htmlFor:"entry-amount",children:"Valor (R$)"}),e.jsx(d,{id:"entry-amount",inputMode:"decimal",placeholder:"0,00",value:r.amount,onChange:a=>s(t=>({...t,amount:a.target.value}))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(l,{children:"Categoria"}),e.jsxs(N,{value:r.category,onValueChange:a=>s(t=>({...t,category:a})),children:[e.jsx(C,{children:e.jsx(E,{placeholder:"Selecione…"})}),e.jsx(k,{children:p.map(a=>e.jsx(S,{value:a,children:a},a))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(l,{htmlFor:"entry-recipient",children:r.kind==="expense"?"Fornecedor (opcional)":"Quem recebeu (opcional)"}),e.jsx(d,{id:"entry-recipient",placeholder:r.kind==="expense"?"Ex.: Contador, Google Ads…":"Ex.: Sócio, conta pessoal…",value:r.recipient,onChange:a=>s(t=>({...t,recipient:a.target.value}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(l,{htmlFor:"entry-desc",children:"Descrição (opcional)"}),e.jsx(f,{id:"entry-desc",rows:2,placeholder:"Detalhe do lançamento",value:r.description,onChange:a=>s(t=>({...t,description:a.target.value}))})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(i,{variant:"outline",onClick:()=>o(m),children:"Cancelar"}),e.jsx(i,{onClick:u,disabled:n.isPending,children:n.isPending?"Salvando…":"Salvar lançamento"})]})]})})]})};export{Y 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.