"use strict";(self.webpackChunkclient=self.webpackChunkclient||[]).push([[5672],{65672:(e,t,a)=>{a.r(t),a.d(t,{default:()=>h});var s=a(89379),n=a(65043),c=a(75206),l=a(86319),i=(a(6839),a(60184)),o=a(89698),r=a(9435),d=a(1880),u=a(66580),p=a(70579);const h=e=>{let{mode:t}=e;const a=(0,r.A)(),{id:h}=(0,u.g)(),[m,x]=(0,n.useState)({title:"",accountName:"",accountNumber:"",ifscCode:"",bankName:"",openingBalance:"",type:"",details:""}),j=(0,u.Zp)();(0,n.useEffect)((()=>{if(t){(async()=>{const e=d.A.get("token"),t=await fetch("https://ezybill.ureshiiweightloss.com/api/v1/account/get",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e,id:h})}),a=await t.json();x((0,s.A)((0,s.A)({},m),a.data))})()}}),[t]);const g=e=>{x({title:"",accountName:"",accountNumber:"",ifscCode:"",bankName:"",openingBalance:"",type:""})};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(c.A,{title:"Account"}),(0,p.jsxs)("main",{id:"main",children:[(0,p.jsx)(l.A,{}),(0,p.jsx)("div",{className:"content__body",children:(0,p.jsxs)("div",{className:"content__body__main bg-white ",children:[(0,p.jsxs)("div",{className:"flex justify-between gap-6  flex-col lg:flex-row",children:[(0,p.jsxs)("div",{className:"w-full",children:[(0,p.jsxs)("div",{className:"p-2",children:[(0,p.jsx)("p",{className:"pb-1",children:"Title"}),(0,p.jsx)("input",{type:"text",onChange:e=>x((0,s.A)((0,s.A)({},m),{},{title:e.target.value})),value:m.title})]}),(0,p.jsxs)("div",{className:"p-2",children:[(0,p.jsx)("p",{className:"pb-1",children:"Account Holder Name (If Bank)"}),(0,p.jsx)("input",{type:"text",onChange:e=>x((0,s.A)((0,s.A)({},m),{},{accountName:e.target.value})),value:m.accountName})]}),(0,p.jsxs)("div",{className:"p-2",children:[(0,p.jsx)("p",{className:"pb-1",children:"Account Number (If Bank)"}),(0,p.jsx)("input",{type:"number",onChange:e=>x((0,s.A)((0,s.A)({},m),{},{accountNumber:e.target.value})),value:m.accountNumber})]})]}),(0,p.jsxs)("div",{className:"w-full",children:[(0,p.jsxs)("div",{className:"p-2",children:[(0,p.jsx)("p",{className:"pb-1",children:"IFSC Code (If Bank)"}),(0,p.jsx)("input",{type:"text",onChange:e=>x((0,s.A)((0,s.A)({},m),{},{ifscCode:e.target.value})),value:m.ifscCode})]}),(0,p.jsxs)("div",{className:"p-2",children:[(0,p.jsx)("p",{className:"pb-1",children:"Bank Name (If Bank)"}),(0,p.jsx)("input",{type:"text",onChange:e=>x((0,s.A)((0,s.A)({},m),{},{bankName:e.target.value})),value:m.bankName})]}),(0,p.jsxs)("div",{className:"p-2",children:[(0,p.jsx)("p",{className:"pb-1",children:"Opening Balance"}),(0,p.jsx)("input",{type:"text",onChange:e=>x((0,s.A)((0,s.A)({},m),{},{openingBalance:e.target.value})),value:m.openingBalance})]}),(0,p.jsxs)("div",{className:"ml-2 pt-2 ",children:[(0,p.jsx)("p",{className:"pb-2",children:"Type"}),(0,p.jsxs)("select",{onChange:e=>x((0,s.A)((0,s.A)({},m),{},{type:e.target.value})),value:m.type,children:[(0,p.jsx)("option",{value:"",children:"--Select--"}),(0,p.jsx)("option",{value:"cash",children:"Cash"}),(0,p.jsx)("option",{value:"bank",children:"Bank"})]})]})]})]}),(0,p.jsxs)("div",{className:"flex justify-center pt-9 mb-6",children:[(0,p.jsxs)("button",{className:"p-2 flex rounded-sm bg-green-500 text-white items-center gap-2",onClick:async e=>{if(""===m.title||""===m.type)return a("fill the blank","error");try{const e="https://ezybill.ureshiiweightloss.com/api/v1/account/add",n=d.A.get("token"),c=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?(0,s.A)((0,s.A)({},m),{},{token:n,update:!0,id:h}):(0,s.A)((0,s.A)({},m),{},{token:n}))}),l=await c.json();return 200!==c.status||l.err?a(l.err,"error"):t?a("Account updated successfully","success"):(a("Account created successfully","success"),j("/admin/account"),void g())}catch(n){console.log(n),a("Something went wrong","error")}},children:[(0,p.jsx)(i.yjt,{}),t?"Update":"Save"]}),(0,p.jsxs)("button",{className:"p-2 flex rounded-sm ml-4 bg-blue-500 text-white items-center gap-2",onClick:g,children:[(0,p.jsx)(o.A1o,{}),"Reset"]})]})]})})]})]})}}}]);
//# sourceMappingURL=5672.303f6f93.chunk.js.map