"use strict";(self.webpackChunkclient=self.webpackChunkclient||[]).push([[1099],{91099:(e,s,t)=>{t.r(s),t.d(s,{default:()=>h});var a=t(89379),l=t(65043),i=t(75206),n=t(86319),c=(t(6839),t(9435)),r=t(66580),d=t(1880),o=t(53435),x=t(70579);const h=e=>{let{mode:s}=e;const t=(0,c.A)(),[h,u]=((0,l.useRef)(null),(0,l.useState)({title:"",details:"",gst:"0",cess:"0"})),{id:m}=(0,r.g)(),p=(0,r.Zp)();(0,l.useEffect)((()=>{if(s){(async()=>{const e=d.A.get("token"),s=await fetch("https://ezybill.ureshiiweightloss.com/api/v1/tax/get",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e,id:m})}),t=await s.json();u((0,a.A)((0,a.A)({},h),t.data))})()}}),[s]);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(i.A,{title:s?"Upate Tax":"Add Tax"}),(0,x.jsxs)("main",{id:"main",children:[(0,x.jsx)(n.A,{}),(0,x.jsx)("div",{className:"content__body",children:(0,x.jsxs)("div",{className:"content__body__main bg-white ",children:[(0,x.jsxs)("div",{className:"flex flex-col",children:[(0,x.jsx)("div",{className:"w-full",children:(0,x.jsxs)("div",{className:"p-2",children:[(0,x.jsxs)("p",{className:"pb-1",children:["Title ",(0,x.jsx)("span",{className:"required__text",children:"*"})]}),(0,x.jsx)("input",{type:"text",onChange:e=>u((0,a.A)((0,a.A)({},h),{},{title:e.target.value})),value:h.title})]})}),(0,x.jsxs)("div",{className:"w-full flex flex-col lg:flex-row",children:[(0,x.jsxs)("div",{className:"p-2 w-full",children:[(0,x.jsxs)("p",{className:"pb-1",children:["GST (%)"," ",(0,x.jsx)("span",{className:"required__text",children:"*"})]}),(0,x.jsx)("input",{type:"text",onChange:e=>u((0,a.A)((0,a.A)({},h),{},{gst:e.target.value})),value:h.gst})]}),(0,x.jsxs)("div",{className:"p-2 w-full",children:[(0,x.jsx)("p",{className:"pb-1",children:"CESS (%)"}),(0,x.jsx)("input",{type:"text",onChange:e=>u((0,a.A)((0,a.A)({},h),{},{cess:e.target.value})),value:h.cess})]})]})]}),(0,x.jsxs)("div",{className:"flex justify-center pt-9 mb-6",children:[(0,x.jsxs)("div",{className:"flex rounded-sm bg-green-500 text-white",children:[(0,x.jsx)(o.F.CHECK,{className:"mt-3 ml-2"}),(0,x.jsx)("button",{className:"p-2",onClick:async e=>{if(""===h.title)return t("Please enter title","error");if(""===h.gst)return t("Please enter GST","error");try{const e="https://ezybill.ureshiiweightloss.com/api/v1/tax/add",l=d.A.get("token"),i=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s?(0,a.A)((0,a.A)({},h),{},{token:l,update:!0,id:m}):(0,a.A)((0,a.A)({},h),{},{token:l}))}),n=await i.json();return 200!==i.status||n.err?t(n.err,"error"):(s||u({title:"",details:"",gst:"0",cess:"0"}),t(s?"Tax update success":"Tax create success","success"),void p("/admin/tax"))}catch(l){return t("Something went wrong","error")}},children:s?"Update":"Save"})]}),(0,x.jsxs)("div",{className:"flex rounded-sm ml-4 bg-blue-500 text-white",children:[(0,x.jsx)(o.F.RESET,{className:"mt-3 ml-2"}),(0,x.jsx)("button",{className:"p-2",onClick:e=>{u({title:""})},children:"Reset"})]})]})]})})]})]})}}}]);
//# sourceMappingURL=1099.97459ce4.chunk.js.map