PageSourceSearch

https://tailwindadmin-tanstack-pro-rtl.netlify.app/assets/create-Cj9aaIM0.js

js tailwindadmin-tanstack-pro-rtl.netlify.app collected 2026-10-03 11:32:35 UTC 11,912 bytes, 1 lines download raw bytes

1import{r as m,u as _,j as e}from"./main-BTsb_TkT.js";import{I as q,a as J}from"./index-CQNBjoja.js";import{I as x}from"./iconify-xhiJ4H-f.js";import{F as K}from"./FullLogo-7qaOY6QF.js";import{C as P}from"./calendar-b-YGXdHh.js";import{P as A,a as k,b as D}from"./popover-ZlZy2U8j.js";import{B as Q}from"./badge-CX36bWqx.js";import{L as I}from"./label-B7_dqY_a.js";import{I as a}from"./input-DA-TB8UA.js";import{T as V,a as Y,b as S,c as h,d as Z,e as u}from"./table-CAqty8jD.js";import{B as p}from"./button-DII730eo.js";import{T as ee,a as M,b as E,c as B}from"./tooltip-BStof0FZ.js";import{A as le,b as te}from"./alert-pd9T15HR.js";import{T as re}from"./triangle-alert-C6_ggeei.js";import{f as g}from"./format-CNjrC8BB.js";import{C as se}from"./card-Bh1lgiHk.js";import{B as oe}from"./BreadcrumbComp-7layM4V-.js";import"./_commonjsHelpers-CE1G-McA.js";import"./index-qkcOVSz3.js";import"./index-BNMeoaTf.js";import"./utils-4perknFd.js";import"./en-US-Dw4dfe3S.js";import"./toDate-BK_JsdFu.js";import"./addMonths-BQ1GswEf.js";import"./createLucideIcon-Bszk9sZd.js";import"./chevron-right-rCVi9TJd.js";import"./chevron-down-DAgYi0xW.js";import"./index-CS3pOZV7.js";import"./index-DG0fbyC2.js";import"./index-CAXKrP8A.js";import"./index-D2v5iztO.js";import"./index-DSnUsWEx.js";import"./index-DFI0GTlD.js";import"./tslib.es6-CmEaCU22.js";import"./index-D06O38ND.js";import"./index-C-zyHnB0.js";import"./floating-ui.dom-D7G01c1r.js";import"./index-9yXyaF83.js";import"./index-C1uOGo2u.js";import"./index-Cft9Cwv8.js";import"./index-D8gfQ8yF.js";import"./CardBox-BoZbvRb2.js";function ae(){const{addInvoice:O,invoices:b}=m.useContext(q),[U,N]=m.useState(!1),[T,w]=m.useState(!1),[y,$]=m.useState(!1),[j,G]=m.useState(new Date),F=_(),[l,i]=m.useState({id:0,billFrom:"Acme Corp",billTo:"Globex Industries",totalCost:0,status:"Pending",billFromAddress:"123 Market Street, San Francisco, CA 94103",billToAddress:"456 Innovation Ave, Austin, TX 73301",billFromPhone:"4151234567",billToPhone:"7379876543",billFromEmail:"[email protected]",billToEmail:"[email protected]",billFromFax:"1234567890",billToFax:"0987654321",orders:[{itemName:"",unitPrice:0,units:0,unitTotalPrice:0}],vat:0,grandTotal:0,subtotal:0,date:new Date().toISOString().split("T")[0],dueDate:""});m.useEffect(()=>{if(b.length>0){const t=b[b.length-1].id;i(r=>({...r,id:t+1}))}else i(t=>({...t,id:1}))},[b]);const f=t=>{let r=0;t.forEach(o=>{const c=o.unitPrice||0,W=o.units||0,C=c*W;r+=C,o.unitTotalPrice=C});const s=r*.1,d=r+s;return{subtotal:r,vat:s,grandTotal:d}},n=t=>{const{name:r,value:s}=t.target;i(d=>{const o={...d,[r]:s},c=f(o.orders);return{...o,...c}})},v=(t,r,s)=>{i(d=>{const o=[...d.orders];o[t]={...o[t],[r]:s};const c=f(o);return{...d,orders:o,...c}})},H=()=>{i(t=>{const r=[...t.orders,{itemName:"",unitPrice:0,units:0,unitTotalPrice:0}],s=f(r);return{...t,orders:r,...s}})},L=t=>{i(r=>{const s=r.orders.filter((o,c)=>c!==t),d=f(s);return{...r,orders:s,...d}})},R=async t=>{t.preventDefault();try{const r={...l,billFromPhone:Number(l.billFromPhone),billToPhone:Number(l.billToPhone),billFromFax:Number(l.billFromFax),billToFax:Number(l.billToFax),createdDate:l.date,dueDate:l.dueDate,orderDate:new Date,completed:!1,isSelected:!1};await O(r),i({id:0,billFrom:"",billTo:"",totalCost:0,status:"Pending",billFromAddress:"",billToAddress:"",billFromPhone:"",billToPhone:"",billFromEmail:"",billToEmail:"",billFromFax:"",billToFax:"",orders:[{itemName:"",unitPrice:0,units:0,unitTotalPrice:0}],vat:0,grandTotal:0,subtotal:0,date:new Date().toISOString().split("T")[0],dueDate:""}),N(!0),setTimeout(()=>{N(!1)},5e3),w(!1),F({to:"/apps/invoice/list"})}catch(r){console.error("Error adding invoice:",r)}},z=()=>w(t=>!t),X=()=>$(t=>!t);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex sm:flex-row flex-col justify-between items-start mb-6 gap-5",children:[e.jsxs("h3",{className:"items-center mt-1 text-xl sm:order-1 order-2",children:["# ",l.id]}),e.jsx("div",{className:"sm:order-2 order-1",children:e.jsx(K,{})}),e.jsx("div",{className:"sm:order-3 order-3",children:e.jsx(Q,{variant:"lightWarning",children:l.status})})]}),e.jsxs("form",{children:[e.jsx("div",{children:e.jsxs("div",{className:"grid grid-cols-12 gap-6",children:[e.jsxs("div",{className:"lg:col-span-6 md:col-span-6 col-span-12",children:[e.jsx("div",{className:"mb-2 block",children:e.jsx(I,{htmlFor:"billFrom",className:"text-base",children:"Bill From"})}),e.jsx("div",{className:"p-4 bg-body dark:bg-darkbody border border-ld rounded-md",children:e.jsxs("div",{className:"flex justify-between items-start gap-2",children:[T?e.jsxs("div",{className:"flex flex-col gap-1 flex-1",children:[e.jsx(a,{id:"billFrom",name:"billFrom",value:l.billFrom,onChange:n,type:"text",placeholder:"Acme Corp"}),e.jsx(a,{id:"billFromAddress",name:"billFromAddress",value:l.billFromAddress,onChange:n,type:"text",placeholder:"123 Market Street, San Francisco, CA 94103"}
1),e.jsx(a,{id:"billFromEmail",name:"billFromEmail",value:l.billFromEmail,onChange:n,type:"text",placeholder:"[email protected]"}),e.jsx(a,{id:"billFromPhone",name:"billFromPhone",value:l.billFromPhone,onChange:n,type:"text",placeholder:"4151234567"})]}):e.jsxs("div",{className:"flex flex-col gap-1 flex-1 text-foreground text-sm",children:[e.jsx("p",{children:l.billFrom}),e.jsx("p",{children:l.billFromEmail}),e.jsx("p",{children:l.billFromAddress}),e.jsx("p",{children:l.billFromPhone})]}),e.jsx("button",{className:"p-2 rounded-full hover:cursor-pointer hover:bg-lightprimary hover:text-primary",onClick:t=>{t.preventDefault(),z()},children:T?e.jsx(x,{icon:"solar:check-read-linear",width:20,height:20}):e.jsx(x,{icon:"solar:pen-linear",width:20,height:20})})]})}),e.jsxs("div",{className:"py-5",children:[e.jsx("h6",{className:"text-sm ",children:"Create date"}),e.jsxs(A,{children:[e.jsx(k,{asChild:!0,children:e.jsx(p,{disabled:!0,variant:"outline",className:` w-full justify-start text-left font-normal border border-ld hover:bg-transparent hover:border-primary ${j?"text-ld hover:text-ld":"text-foreground-foreground hover:text-foreground-foreground"}`,children:j?g(j,"MMMM d, yyyy"):""})}),e.jsx(D,{children:e.jsx(P,{mode:"single",selected:j,onSelect:G,initialFocus:!0})})]})]})]}),e.jsxs("div",{className:"lg:col-span-6 md:col-span-6 col-span-12",children:[e.jsx("div",{className:"mb-2 block",children:e.jsx(I,{htmlFor:"billTo",className:"text-base",children:"Bill To"})}),e.jsx("div",{className:"p-4 bg-body dark:bg-darkbody border border-ld rounded-md flex flex-col gap-1",children:e.jsxs("div",{className:"flex justify-between items-start gap-2",children:[y?e.jsxs("div",{className:"flex flex-col gap-1 flex-1",children:[e.jsx(a,{id:"billTo",name:"billTo",value:l.billTo,onChange:n,type:"text",placeholder:"Globex Industries"}),e.jsx(a,{id:"billToAddress",name:"billToAddress",value:l.billToAddress,onChange:n,type:"text",placeholder:"456 Innovation Ave, Austin, TX 73301"}),e.jsx(a,{id:"billToEmail",name:"billToEmail",value:l.billToEmail,onChange:n,type:"text",placeholder:"[email protected]"}),e.jsx(a,{id:"billToPhone",name:"billToPhone",value:l.billToPhone,onChange:n,type:"text",placeholder:"7379876543"})]}):e.jsxs("div",{className:"flex flex-col gap-1 flex-1 text-foreground text-sm",children:[e.jsx("p",{children:l.billTo}),e.jsx("p",{children:l.billToEmail}),e.jsx("p",{children:l.billToAddress}),e.jsx("p",{children:l.billToPhone})]}),e.jsx("button",{className:"p-2 rounded-full hover:cursor-pointer hover:bg-lightprimary hover:text-primary",onClick:t=>{t.preventDefault(),X()},children:y?e.jsx(x,{icon:"solar:check-read-linear",width:20,height:20}):e.jsx(x,{icon:"solar:pen-linear",width:20,height:20})})]})}),e.jsxs("div",{className:"py-5",children:[e.jsx("h6",{className:"text-sm",children:"Due date"}),e.jsxs(A,{children:[e.jsx(k,{asChild:!0,children:e.jsx(p,{variant:"outline",className:` w-full justify-start text-left font-normal border border-ld hover:bg-transparent hover:border-primary ${l.dueDate?"text-ld hover:text-ld":"text-foreground-foreground hover:text-foreground-foreground"}`,children:l.dueDate?g(new Date(l.dueDate),"MMMM d, yyyy"):g(new Date,"MMMM d, yyyy")})}),e.jsx(D,{children:e.jsx(P,{mode:"single",selected:l.dueDate?new Date(l.dueDate):new Date,onSelect:t=>{t&&i(r=>({...r,dueDate:t.toISOString()}))},initialFocus:!0})})]})]})]})]})}),e.jsx("div",{className:"mt-6",children:e.jsx("div",{className:"overflow-x-auto overflow-y-hidden",children:e.jsx("div",{className:"mt-4 mb-10 border border-ld !rounded-md",children:e.jsxs(V,{children:[e.jsx(Y,{children:e.jsxs(S,{children:[e.jsx(h,{children:"Item Name"}),e.jsx(h,{children:"Unit Price"}),e.jsx(h,{children:"Units"}),e.jsx(h,{children:"Total Cost"}),e.jsx(h,{}),e.jsx(h,{children:"Actions"})]})}),e.jsx(Z,{className:"divide-y divide-border dark:divide-darkborder",children:l.orders.map((t,r)=>e.jsxs(S,{children:[e.jsx(u,{className:"whitespace-nowrap min-w-44",children:e.jsx(a,{type:"text",value:t.itemName,placeholder:"Item Name",onChange:s=>v(r,"itemName",s.target.value)})}),e.jsx(u,{className:"whitespace-nowrap min-w-44",children:e.jsx(a,{type:"number",value:t.unitPrice,placeholder:"Unit Price",onChange:s=>v(r,"unitPrice",s.target.value)})}),e.jsx(u,{className:"whitespace-nowrap min-w-44",children:e.jsx(a,{type:"number",value:t.units,placeholder:"Units",onChange:s=>v(r,"units",s.target.value)})}),e.jsx(u,{className:"whitespace-nowrap min-w-32",children:t.unitTotalPrice}),e.jsx(u,{className:"whitespace-nowrap"}),e.jsx(u,{className:"whitespace-nowrap flex items-center gap-2",children:e.jsxs(ee,{children:[e.jsxs(M,{children:[e.jsx(E,{asChild:!0,children:e.jsx(p,{type:"button",variant:"lightprimary",size:"icon",onClick:H,children:e.jsx(x,{icon:"mdi:plus-circle",height:18})})}),e.jsx(B,{children:" Add Item "})]}),e.jsxs(M,{children:[e.jsx(E,{asChild:!0,children:e.jsx(p,{type:"button",variant:"lighterror",size:"icon",className:"group",onClick:()=>L(r),children:e.jsx(x,{icon:"solar:trash-bin-minimalistic-outline",height:18})})}),e.jsx(B,{children:" Delete Item "})]})]})})]},r))})]})})})}),e.jsxs("div",{className:"p-4 bg-body dark:bg-darkbody border border-ld rounded-md flex flex-col gap-1",children:[e.jsx("div",{className:"flex justify-end mb-3",children:e.jsxs("div",{className:"flex gap-3 lg:w-1/5",children:[e.jsx("h2",{className:"max-w-52 w-full text-black/60 dark:text-white/60 font-normal",children:"Sub Total:"}),e.jsxs("h3",{className:"ms-auto  text-black/60 dark:text-white/60 font-normal",children:["$",l.subtotal]})]})}),e.jsx("div",{className:"flex justify-end mb-3",children:e.jsxs("div",{className:"flex gap-3 lg:w-1/5 border-b border-ld",children:[e.jsx("h2",{className:"max-w-52 w-full text-black/60 dark:text-white/60 font-normal",children:"Tax:"}),e.jsxs("h3",{className:"ms-auto text-black/60 dark:text-white/60 font-normal",children:[l.vat,"%"]})]})}),e.jsx("div",{className:"flex justify-end",children:e.jsxs("div",{className:"flex gap-3 lg:w-1/5",children:[e.jsx("h2",{className:"max-w-52 w-full",children:"Grand Total:"}),e.jsxs("h3",{className:"ms-auto text-base",children:["$",l.grandTotal]})]})})]}),e.jsx("div",{className:"flex justify-end ",children:e.jsxs("div",{className:"flex justify-end gap-3 mt-2",children:[e.jsx(p,{className:"mt-6",onClick:R,children:"Create Invoice"}),e.jsx(p,{variant:"destructive",className:"mt-6",onClick:()=>{F({to:"/apps/invoice/list"})},children:"Cancel"})]})})]}),U&&e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs(le,{variant:"warning",className:"max-w-sm w-full text-center fixed top-3 rounded",children:[e.jsx(re,{className:"h-4 w-4 ",color:"white"}),e.jsx(te,{children:"Invoice added successfully."})]})})]})}function ie(){return e.jsx(J,{children:e.jsx(se,{children:e.jsx(ae,{})})})}const ne=[{to:"/",title:"Home"},{title:"Invoice Create"}];function Ve(){return e.jsxs(e.Fragment,{children:[e.jsx(oe,{title:" Create A New Invoice ",items:ne}),e.jsx(ie,{})]})}
1export{Ve as component};

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.