import{c as w,b as j,r,j as t,i as k,n as s}from"./index-7c7a558c.js";import{B as N}from"./Breadcrumb-21e99ae5.js";import{o as S}from"./ObjectToFormData-bf0af219.js";import{p as _}from"./productManegeApi-122780af.js";const F=()=>{const o=w(),{isLoading:b,mutate:x}=j(_,{onSuccess:()=>{s.success("Successfully Created"),o("/admin/get-all-delivery-charge")},onError:e=>{var a,d,c,i,m,g,f,p;(d=(a=e==null?void 0:e.response)==null?void 0:a.data)!=null&&d.error?s.error((i=(c=e==null?void 0:e.response)==null?void 0:c.data)==null?void 0:i.error):(g=(m=e==null?void 0:e.response)==null?void 0:m.data)!=null&&g.message?s.error((p=(f=e==null?void 0:e.response)==null?void 0:f.data)==null?void 0:p.message):s.error("something went wrong!")}}),h=e=>{e.preventDefault(),x({formdata:S({location:l,amount:n})})},[l,y]=r.useState(""),[n,v]=r.useState("");r.useEffect(()=>{const e=localStorage.getItem("token"),a=localStorage.getItem("user");e&&a||o("/login")},[o]);let u=null;return u=t.jsxs("form",{className:"p-5",onSubmit:h,children:[t.jsxs("div",{className:"grid md:grid-cols-2 md:gap-6",children:[t.jsxs("div",{className:"relative z-0 w-full mb-6 group",children:[t.jsx("input",{type:"text",name:"floating_name",id:"floating_name",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:l,onChange:e=>y(e.target.value),required:!0}),t.jsx("label",{htmlFor:"floating_name",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"})]}),t.jsxs("div",{className:"relative z-0 w-full mb-6 group",children:[t.jsx("input",{type:"text",name:"floating_name",id:"floating_name",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:n,onChange:e=>v(e.target.value),required:!0}),t.jsx("label",{htmlFor:"floating_name",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"})]})]}),t.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:b?t.jsx(k,{color:"white",size:"lg",variant:"dots"}):"Submit"})]}),t.jsxs(t.Fragment,{children:[t.jsx(N,{title:"Add Delivery Charge"}),t.jsx("div",{className:"my-12",children:t.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:u})})]})};export{F as default};
