import{c as N,u as S,a as _,b as C,r,j as a,i as D,n as t}from"./index-7c7a558c.js";import{B as z}from"./Breadcrumb-21e99ae5.js";import{b as E,c as F}from"./productManegeApi-122780af.js";import{F as L}from"./FormSkeleton-15b9109d.js";const I=()=>{const v=N(),{id:o}=S(),{data:l,isLoading:n}=_("getAdminSingleDelivaryCharge",()=>E(o)),{isLoading:w,mutate:j}=C(F,{onSuccess:e=>{t.success("Successfully Created"),console.log(e==null?void 0:e.data),v("/admin/get-all-delivery-charge")},onError:e=>{var m,g,f,p,b,x,h,y;(g=(m=e==null?void 0:e.response)==null?void 0:m.data)!=null&&g.error?t.error((p=(f=e==null?void 0:e.response)==null?void 0:f.data)==null?void 0:p.error):(x=(b=e==null?void 0:e.response)==null?void 0:b.data)!=null&&x.message?t.error((y=(h=e==null?void 0:e.response)==null?void 0:h.data)==null?void 0:y.message):t.error("something went wrong!")}}),k=e=>{e.preventDefault(),j({id:o,formdata:{location:i,amount:d}})},[i,u]=r.useState(),[d,c]=r.useState("");r.useEffect(()=>{u(),c(),console.log(l)},[l]);let s=null;return n&&(s=a.jsx(L,{})),n||(s=a.jsxs("form",{className:"p-5",onSubmit:k,children:[a.jsxs("div",{className:"grid md:grid-cols-2 md:gap-6",children:[a.jsxs("div",{className:"relative z-0 w-full mb-6 group",children:[a.jsx("input",{type:"text",name:"floating_price",id:"floating_price",className:"block py-2.5 px-0 w-full text-sm text-gray-900 bg-transparent border-0 border-b-2 border-gray-300 appearance-none dark:text-white dark:border-gray-600 dark:focus:border-blue-500 focus:outline-none focus:ring-0 focus:border-blue-600",placeholder:" ",defaultValue:i,onChange:e=>u(e.target.value),required:!0}),a.jsx("label",{htmlFor:"floating_price",className:"peer-focus:font-medium absolute text-sm text-gray-500 dark:text-gray-400 duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-focus:left-0 peer-focus:text-blue-600 peer-focus:dark:text-blue-500 peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6",children:"Location"})]}),a.jsxs("div",{className:"relative z-0 w-full mb-6 group",children:[a.jsx("input",{type:"number",name:"floating_discount_price",id:"floating_discount_price",className:"block py-2.5 px-0 w-full text-sm text-gray-900 bg-transparent border-0 border-b-2 border-gray-300 appearance-none dark:text-white dark:border-gray-600 dark:focus:border-blue-500 focus:outline-none focus:ring-0 focus:border-blue-600",placeholder:" ",defaultValue:d,onChange:e=>c(e.target.value),required:!0}),a.jsx("label",{htmlFor:"floating_discount_price",className:"peer-focus:font-medium absolute text-sm text-gray-500 dark:text-gray-400 duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-focus:left-0 peer-focus:text-blue-600 peer-focus:dark:text-blue-500 peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6",children:"Amount"})]})]}),a.jsx("button",{type:"submit",className:"text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800",children:w?a.jsx(D,{color:"white",size:"lg",variant:"dots"}):"Submit"})]})),a.jsxs(a.Fragment,{children:[a.jsx(z,{title:"Edit Delivary Charge"}),a.jsx("div",{className:"my-12",children:a.jsx("div",{className:"relative overflow-x-auto p-2 bg-gradient-to-r from-main to-second shadow-md border-dashed border rounded-tr-xl rounded-bl-xl",children:s})})]})};export{I as default};
