1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7597],{66242:function(e,n,t){"use strict";t.d(n,{Z:function(){return j}});var i=t(87462),s=t(63366),r=t(67294),a=t(86010),o=t(94780),l=t(90948),c=t(71657),d=t(90629),x=t(1588),u=t(34867);function m(e){return(0,u.Z)("MuiCard",e)}(0,x.Z)("MuiCard",["root"]);var h=t(85893);const v=["className","raised"],p=(0,l.ZP)(d.Z,{name:"MuiCard",slot:"Root",overridesResolver:(e,n)=>n.root})((()=>({overflow:"hidden"})));var j=r.forwardRef((function(e,n){const t=(0,c.Z)({props:e,name:"MuiCard"}),{className:r,raised:l=!1}=t,d=(0,s.Z)(t,v),x=(0,i.Z)({},t,{raised:l}),u=(e=>{const{classes:n}=e;return(0,o.Z)({root:["root"]},m,n)})(x);return(0,h.jsx)(p,(0,i.Z)({className:(0,a.Z)(u.root,r),elevation:l?8:void 0,ref:n,ownerState:x},d))}))},35412:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/dashboard/invoice/new",function(){return t(62737)}])},70442:function(e,n,t){"use strict";t.d(n,{Z:function(){return u}});var i=t(85893),s=t(87357),r=t(26447),a=t(15861),o=t(12963),l=t(23795),c=t(41664),d=t.n(c);function x(e){let{link:n,activeLast:t,disabled:r}=e;const{name:a,href:o,icon:c}=n,x={typography:"body2",alignItems:"center",color:"text.primary",display:"inline-flex",...r&&!t&&{cursor:"default",pointerEvents:"none",color:"text.disabled"}},u=(0,i.jsxs)(i.Fragment,{children:[c&&(0,i.jsx)(s.Z,{component:"span",sx:{mr:1,display:"inherit","& svg":{width:20,height:20}},children:c}),a]});return o?(0,i.jsx)(l.Z,{component:d(),href:o,sx:x,children:u}):(0,i.jsxs)(s.Z,{sx:x,children:[" ",u," "]})}function u(e){let{links:n,action:t,heading:c,moreLink:d,activeLast:u,sx:h,...v}=e;const p=n[n.length-1].name;return(0,i.jsxs)(s.Z,{sx:{mb:5,...h},children:[(0,i.jsxs)(r.Z,{direction:"row",alignItems:"center",children:[(0,i.jsxs)(s.Z,{sx:{flexGrow:1},children:[c&&(0,i.jsx)(a.Z,{variant:"h4",gutterBottom:!0,children:c}),!!n.length&&(0,i.jsx)(o.Z,{separator:(0,i.jsx)(m,{}),...v,children:n.map((e=>(0,i.jsx)(x,{link:e,activeLast:u,disabled:e.name===p},e.name||"")))})]}),t&&(0,i.jsxs)(s.Z,{sx:{flexShrink:0},children:[" ",t," "]})]}),!!d&&(0,i.jsx)(s.Z,{sx:{mt:2},children:d.map((e=>(0,i.jsx)(l.Z,{noWrap:!0,href:e,variant:"body2",target:"_blank",rel:"noopener",sx:{display:"table"},children:e},e)))})]})}function m(){return(0,i.jsx)(s.Z,{component:"span",sx:{width:4,height:4,borderRadius:"50%",bgcolor:"text.disabled"}})}},62737:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return u}});var i=t(85893),s=t(9008),r=t.n(s),a=t(53156),o=t(96259),l=t(8242),c=t(89108),d=t(70442),x=t(70651);function u(){const{themeStretch:e}=(0,c.K$)();return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(r(),{children:(0,i.jsx)("title",{children:" Invoices: Create a new invoice | Minimal UI"})}),(0,i.jsxs)(a.Z,{maxWidth:!e&&"lg",children:[(0,i.jsx)(d.Z,{heading:"Create a new invoice",links:[{name:"Dashboard",href:o.vB.root},{name:"Invoices",href:o.vB.invoice.list},{name:"New invoice"}]}),(0,i.jsx)(x.Z,{})]})]})}u.getLayout=e=>(0,i.jsx)(l.Z,{children:e})},70651:function(e,n,t){"use strict";t.d(n,{Z:function(){return F}});var i=t(85893),s=t(67294),r=t(16310),a=t(11163),o=t(87536),l=t(47533),c=t(31812),d=t(66242),x=t(26447),u=t(96259),m=t(45983),h=t(1677),v=t(12297),p=t.n(v),j=t(87357),f=t(15861),Z=t(67720),g=t(18972),b=t(87109),w=t(11057),y=t(13162),C=t(7065);const I=[{id:1,name:"full stack development",price:90.99},{id:2,name:"backend development",price:80.99},{id:3,name:"ui design",price:70.99},{id:4,name:"ui/ux design",price:60.99},{id:5,name:"front end development",price:40.99}];function k(){const{control:e,setValue:n,watch:t,resetField:r}=(0,o.Gc)(),{fields:a,append:l,remove:c}=(0,o.Dq)({control:e,name:"items"}),d=t(),u=d.items.map((e=>e.quantity*e.price)),m=p()(u)-d.discount+d.taxes;(0,s.useEffect)((()=>{n("totalPrice",m)}),[n,m]);const v=(0,s.useCallback)((e=>{r("items[".concat(e,"].quantity")),r("items[".concat(e,"].price")),r("items[".concat(e,"].total"))}),[r]),k=(0,s.useCallback)(((e,t)=>{var i;n("items[".concat(e,"].price"),null===(i=I.find((e=>e.name===t)))||void 0===i?void 0:i.price),n("items[".concat(e,"].total"),d.items.map((e=>e.quantity*e.price))[e])}),[n,d.items]),S=(0,s.useCallback)(((e,t)=>{n("items[".concat(t,"].quantity"),Number(e.target.value)),n("items[".concat(t,"].total"),d.items.map((e=>e.quantity*e.price))[t])}),[n,d.items]),N=(0,s.useCallback)(((e,t)=>{n("items[".concat(t,"].price"),Number(e.target.value)),n("items[".concat(t,"].total"),d.items.map((e=>e.quantity*e.price))[t])}),[n,d.items]);return(0,i.jsxs)(j.Z,{sx:{p:3},children:[(0,i.jsx)(f.Z,{variant:"h6",sx:{color:"text.disabled",mb:3},children:"Details:"}),(0,i.jsx)(x.Z,{divider:(0,i.jsx)(Z.Z,{flexItem:!0,sx:{borderStyle:"dashed"}}),spacing:3,children:a.map(((e,n)=>(0,i.jsxs)(x.Z,{alignItems:"flex-end",spacing:1.5,children:[(0,i.jsxs)(x.Z,{direction:{xs:"column",md:"row"},spacing:2,sx:{width:1},children:[(0,i.jsx)(h.au,{size:"small",name:"items[".concat(n,"].title"),label:"Title",InputLabelProps:{shrink:!0}}),(0,i.jsx)(h.au,{size:"small",name:"items[".concat(n,"].description"),label:"Description",InputLabelProps:{shrink:!0}}),(0,i.jsxs)(h.Cc,{name:"items[".concat(n,"].service"),size:"small",label:"Service",InputLabelProps:{shrink:!0},sx:{maxWidth:{md:160}},children:[(0,i.jsx)(g.Z,{value:"",onClick:()=>v(n),sx:{fontStyle:"italic",color:"text.secondary"},children:"None"}),(0,i.jsx)(Z.Z,{}),I.map((e=>(0,i.jsx)(g.Z,{value:e.name,onClick:()=>k(n,e.name),children:e.name},e.id)))]}),(0,i.jsx)(h.au,{size:"small",type:"number",name:"items[".concat(n,"].quantity"),label:"Quantity",placeholder:"0",onChange:e=>S(e,n),InputLabelProps:{shrink:!0},sx:{maxWidth:{md:96}}}),(0,i.jsx)(h.au,{size:"small",type:"number",name:"items[".concat(n,"].price"),label:"Price",placeholder:"0",onChange:e=>N(e,n),InputProps:{startAdornment:(0,i.jsx)(b.Z,{position:"start",children:"$"})},sx:{maxWidth:{md:96}}}),(0,i.jsx)(h.au,{disabled:!0,size:"small",name:"items[".concat(n,"].total"),label:"Total",placeholder:"0",value:u[n],InputProps:{startAdornment:(0,i.jsx)(b.Z,{position:"start",children:"$"})},sx:{maxWidth:{md:96}}})]}),(0,i.jsx)(w.Z,{size:"small",color:"error",startIcon:(0,i.jsx)(C.Z,{icon:"eva:tras
1h-2-outline"}),onClick:()=>(e=>{c(e)})(n),children:"Remove"})]},e.id)))}),(0,i.jsx)(Z.Z,{sx:{my:3,borderStyle:"dashed"}}),(0,i.jsxs)(x.Z,{spacing:2,direction:{xs:"column-reverse",md:"row"},alignItems:{xs:"flex-start",md:"center"},children:[(0,i.jsx)(w.Z,{size:"small",startIcon:(0,i.jsx)(C.Z,{icon:"eva:plus-fill"}),onClick:()=>{l({title:"",description:"",service:"",quantity:1,price:0,total:0})},sx:{flexShrink:0},children:"Add Item"}),(0,i.jsxs)(x.Z,{spacing:2,justifyContent:"flex-end",direction:{xs:"column",md:"row"},sx:{width:1},children:[(0,i.jsx)(h.au,{size:"small",label:"Discount",name:"discount",onChange:e=>n("discount",Number(e.target.value)),sx:{maxWidth:{md:200}}}),(0,i.jsx)(h.au,{size:"small",label:"Taxes",name:"taxes",onChange:e=>n("taxes",Number(e.target.value)),sx:{maxWidth:{md:200}}})]})]}),(0,i.jsxs)(x.Z,{spacing:2,sx:{mt:3},children:[(0,i.jsxs)(x.Z,{direction:"row",justifyContent:"flex-end",children:[(0,i.jsx)(f.Z,{children:"Subtotal :"}),(0,i.jsx)(f.Z,{sx:{textAlign:"right",width:120},children:(0,y.e_)(p()(u))||"-"})]}),(0,i.jsxs)(x.Z,{direction:"row",justifyContent:"flex-end",children:[(0,i.jsx)(f.Z,{children:"Discount :"}),(0,i.jsx)(f.Z,{sx:{textAlign:"right",width:120,...d.discount&&{color:"error.main"}},children:d.discount?"- ".concat((0,y.e_)(d.discount)):"-"})]}),(0,i.jsxs)(x.Z,{direction:"row",justifyContent:"flex-end",children:[(0,i.jsx)(f.Z,{children:"Taxes :"}),(0,i.jsx)(f.Z,{sx:{textAlign:"right",width:120},children:d.taxes?(0,y.e_)(d.taxes):"-"})]}),(0,i.jsxs)(x.Z,{direction:"row",justifyContent:"flex-end",children:[(0,i.jsx)(f.Z,{variant:"h6",children:"Total price :"}),(0,i.jsx)(f.Z,{variant:"h6",sx:{textAlign:"right",width:120},children:(0,y.e_)(m)||"-"})]})]})]})}var S=t(10653),N=t(64666),D=t(50135),T=t(98619),P=t(78966);function _(e){let{open:n,selected:t,onClose:r,onSelect:a,addressOptions:o}=e;const[l,c]=(0,s.useState)(""),d=function(e,n){if(n)return e.filter((e=>-1!==e.name.toLowerCase().indexOf(n.toLowerCase())||-1!==e.company.toLowerCase().indexOf(n.toLowerCase())||-1!==e.address.toLowerCase().indexOf(n.toLowerCase())));return e}(o,l),u=!d.length&&!!l;return(0,i.jsxs)(N.Z,{fullWidth:!0,maxWidth:"xs",open:n,onClose:r,children:[(0,i.jsxs)(x.Z,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{pt:2.5,px:3},children:[(0,i.jsx)(f.Z,{variant:"h6",children:" Select address "}),(0,i.jsx)(w.Z,{size:"small",startIcon:(0,i.jsx)(C.Z,{icon:"eva:plus-fill"}),sx:{alignSelf:"flex-end"},children:"Add New"})]}),(0,i.jsx)(x.Z,{sx:{p:2.5},children:(0,i.jsx)(D.Z,{value:l,onChange:e=>{c(e.target.value)},placeholder:"Search...",InputProps:{startAdornment:(0,i.jsx)(b.Z,{position:"start",children:(0,i.jsx)(C.Z,{icon:"eva:search-fill",sx:{color:"text.disabled"}})})}})}),u?(0,i.jsx)(P.Z,{query:l,sx:{px:3,pt:5,pb:10}}):(0,i.jsx)(x.Z,{sx:{p:1.5,pt:0,maxHeight:640,overflowX:"hidden"},children:d.map((e=>(0,i.jsxs)(T.Z,{selected:t(e.id),onClick:()=>(e=>{a(e),c(""),r()})(e),sx:{p:1.5,borderRadius:1,flexDirection:"column",alignItems:"flex-start","&.Mui-selected":{bgcolor:"action.selected","&:hover":{bgcolor:"action.selected"}}},children:[(0,i.jsx)(f.Z,{variant:"subtitle2",children:e.name}),(0,i.jsx)(f.Z,{variant:"caption",component:"div",sx:{my:.5,color:"info.main",fontWeight:"fontWeightMedium"},children:e.company}),(0,i.jsx)(f.Z,{variant:"body2",sx:{color:"text.secondary"},children:e.address})]},e.id)))})]})}function z(){var e;const{watch:n,setValue:t,formState:{errors:r}}=(0,o.Gc)(),a=(0,S.Z)("up","md"),l=n(),{invoiceFrom:c,invoiceTo:d}=l,[u,h]=(0,s.useState)(!1),[v,p]=(0,s.useState)(!1);return(0,i.jsxs)(x.Z,{spacing:{xs:2,md:5},direction:{xs:"column",md:"row"},divider:(0,i.jsx)(Z.Z,{flexItem:!0,orientation:a?"vertical":"horizontal",sx:{borderStyle:"dashed"}}),sx:{p:3},children:[(0,i.jsxs)(x.Z,{sx:{width:1},children:[(0,i.jsxs)(x.Z,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mb:1},children:[(0,i.jsx)(f.Z,{variant:"h6",sx:{color:"text.disabled"},children:"From:"}),(0,i.jsx)(w.Z,{size:"small",startIcon:(0,i.jsx)(C.Z,{icon:"eva:edit-fill"}),onClick:()=>{h(!0)},children:"Change"}),(0,i.jsx)(_,{open:u,onClose:()=>{h(!1)},selected:e=>(null===c||void 0===c?void 0:c.id)===e,onSelect:e=>t("invoiceFrom",e),addressOptions:m.Fr})]}),(0,i.jsx)(L,{name:c.name,address:c.address,phone:c.phone})]}),(0,i.jsxs)(x.Z,{sx:{width:1},children:[(0,i.jsxs)(x.Z,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mb:1},children:[(0,i.jsx)(f.Z,{variant:"h6",sx:{color:"text.disabled"},children:"To:"}),(0,i.jsx)(w.Z,{size:"small",startIcon:(0,i.jsx)(C.Z,{icon:d?"eva:edit-fill":"eva:plus-fill"}),onClick:()=>{p(!0)},children:d?"Change":"Add"}),(0,i.jsx)(_,{open:v,onClose:()=>{p(!1)},selected:e=>(null===d||void 0===d?void 0:d.id)===e,onSelect:e=>t("invoiceTo",e),addressOptions:m.yN})]}),d?(0,i.jsx)(L,{name:d.name,address:d.address,phone:d.phone}):(0,i.jsx)(f.Z,{typography:"caption",sx:{color:"error.main"},children:null===(e=r.invoiceTo)||void 0===e?void 0:e.message})]})]})}function L(e){let{name:n,address:t,phone:s}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(f.Z,{variant:"subtitle2",children:n}),(0,i.jsx)(f.Z,{variant:"body2",sx:{mt:1,mb:.5},children:t}),(0,i.jsxs)(f.Z,{variant:"body2",children:["Phone: ",s]})]})}var W=t(52377);const A=["paid","unpaid","overdue","draft"];function q(){const{control:e,watch:n}=(0,o.Gc)(),t=n();return(0,i.jsxs)(x.Z,{spacing:2,direction:{xs:"column",sm:"row"},sx:{p:3,bgcolor:"background.neutral"},children:[(0,i.jsx)(h.au,{disabled:!0,name:"invoiceNumber",label:"Invoice number",value:"INV-".concat(t.invoiceNumber)}),(0,i.jsx)(h.Cc,{fullWidth:!0,name:"status",label:"Status",InputLabelProps:{shrink:!0},children:A.map((e=>(0,i.jsx)(g.Z,{value:e,children:e},e)))}),(0,i.jsx)(o.Qr,{name:"createDate",control:e,render:e=>{let{field:n,fieldState:{error:t}}=e;return(0,i.jsx)(W.M,{label:"Date create",value:n.value,onChange:e=>{n.onChange(e)},renderInput:e=>(0,i.jsx)(D.Z,{...e,fullWidth:!0,error:!!t,helperText:null===t||void 0===t?void 0:t.message})})}}),(0,i.jsx)(o.Qr,{name:"dueDate",control:e,render:e=>{let{field:n,fieldState:{error:t}}=e;return(0,i.jsx)(W.M,{label:"Due date",value:n.value,onChange:e=>{n.onChange(e)},renderInput:e=>(0,i.jsx)(D.Z,{...e,fullWidth:!0,error:!!t,helperText:null===t||void 0===t?void 0:t.message})})}})]})}function F(e){let{isEdit:n,currentInvoice:t}=e;const{push:v}
1=(0,a.useRouter)(),[p,j]=(0,s.useState)(!1),[f,Z]=(0,s.useState)(!1),g=r.Ry().shape({invoiceTo:r.nK().required("Invoice to is required"),dueDate:r.hT().min(r.iH("createDate"),"Due date must be later than create date")}),b=(0,s.useMemo)((()=>({invoiceNumber:(null===t||void 0===t?void 0:t.invoiceNumber)||"17099",createDate:(null===t||void 0===t?void 0:t.createDate)||new Date,dueDate:(null===t||void 0===t?void 0:t.dueDate)||null,taxes:(null===t||void 0===t?void 0:t.taxes)||0,status:(null===t||void 0===t?void 0:t.status)||"draft",discount:(null===t||void 0===t?void 0:t.discount)||0,invoiceFrom:(null===t||void 0===t?void 0:t.invoiceFrom)||m.Fr[0],invoiceTo:(null===t||void 0===t?void 0:t.invoiceTo)||null,items:(null===t||void 0===t?void 0:t.items)||[{title:"",description:"",service:"",quantity:1,price:0,total:0}],totalPrice:(null===t||void 0===t?void 0:t.totalPrice)||0})),[t]),w=(0,o.cI)({resolver:(0,l.X)(g),defaultValues:b}),{reset:y,handleSubmit:C,formState:{isSubmitting:I}}=w;(0,s.useEffect)((()=>{n&&t&&y(b),n||y(b)}),[n,t]);return(0,i.jsxs)(h.ZP,{methods:w,children:[(0,i.jsxs)(d.Z,{children:[(0,i.jsx)(z,{}),(0,i.jsx)(q,{}),(0,i.jsx)(k,{})]}),(0,i.jsxs)(x.Z,{justifyContent:"flex-end",direction:"row",spacing:2,sx:{mt:3},children:[(0,i.jsx)(c.Z,{color:"inherit",size:"large",variant:"contained",loading:p&&I,onClick:C((async e=>{j(!0);try{await new Promise((e=>setTimeout(e,500))),y(),j(!1),v(u.vB.invoice.list),console.log("DATA",JSON.stringify(e,null,2))}catch(n){console.error(n),j(!1)}})),children:"Save as Draft"}),(0,i.jsxs)(c.Z,{size:"large",variant:"contained",loading:f&&I,onClick:C((async e=>{Z(!0);try{await new Promise((e=>setTimeout(e,500))),y(),Z(!1),v(u.vB.invoice.list),console.log("DATA",JSON.stringify(e,null,2))}catch(n){console.error(n),Z(!1)}})),children:[n?"Update":"Create"," & Send"]})]})]})}}},function(e){e.O(0,[1664,3461,4564,2679,8618,5464,7417,8360,4386,135,568,7423,2077,7918,4084,6628,4782,1812,6886,7964,5099,8159,141,9485,2377,3178,1677,5983,8242,9774,2888,179],(function(){return n=35412,e(e.s=n);var n}));var n=e.O();_N_E=n}]);
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.