import{aJ as x,r as l,j as e,f as b}from"./index-7c7a558c.js";import{B as p}from"./Breadcrumb-f4cb0f42.js";const v=()=>{const[f,d,h]=x(),[c,m]=l.useState(!1);l.useState("");const[a,o]=l.useState({name:"",image:null,is_feature:""}),[t,n]=l.useState({}),u=()=>{const r={};return a.name||(r.name="Name is required"),a.image||(r.image="Image is required"),a.is_feature||(r.is_feature="Feature is required"),r},g=async r=>{r.preventDefault();const i=u();if(Object.keys(i).length===0)try{const s=new FormData;s.append("name",a.name),s.append("image",a.image),s.append("is_feature",a.is_feature==1?"yes":"no");const y=await b.post("https://www.bdskilltech.com/backend/public/api/admin/category",s,{headers:{Authorization:"Bearer "+d}});n({}),m(!0),o({name:"",image:null})}catch(s){console.error(s)}else n(i);console.log(a)};return e.jsxs(e.Fragment,{children:[e.jsx(p,{title:"Create Category"}),e.jsx("div",{className:"my-12 h-screen",children:e.jsx("div",{className:"relative overflow-x-auto shadow-md sm:rounded-lg section-bg p-2",children:e.jsxs("form",{className:"p-5",onSubmit:g,children:[e.jsx("div",{className:"grid md:grid-cols-2 md:gap-6",children:c?e.jsx("h4",{className:"text-green-500 font-bold pb-8",children:"Category Created Successfully."}):""}),e.jsx("div",{className:"grid md:grid-cols-1 md:gap-6",children:e.jsxs("div",{className:"relative z-0 w-full mb-12 group",children:[e.jsx("input",{type:"text",onChange:r=>o({...a,name:r.target.value}),name:"name",id:"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:" ",required:!0}),e.jsx("label",{htmlFor:"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:"Category Name"}),t.name&&e.jsx("span",{className:"text-red-500",children:t.name})]})}),e.jsx("div",{className:"grid md:grid-cols-1 md:gap-6",children:e.jsxs("div",{className:"relative z-0 w-full mb-6 group",children:[e.jsx("label",{className:"block mb-2 text-sm font-medium text-gray-900 dark:text-white",htmlFor:"image",children:"Category Image"}),e.jsx("input",{className:"block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 dark:text-gray-400 focus:outline-none dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400","aria-describedby":"image_help",id:"image",type:"file",name:"image",onChange:r=>o({...a,image:r.target.files[0]})}),t.image&&e.jsx("span",{className:"text-red-500",children:t.image})]})}),e.jsx("div",{className:"grid md:grid-cols-1 md:gap-6",children:e.jsxs("div",{className:"relative z-0 w-full mb-6 group",children:[e.jsx("label",{className:"block mb-2 text-sm font-medium text-gray-900 dark:text-white",htmlFor:"is_feature",children:"Is Feature"}),e.jsxs("select",{className:"block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 dark:text-gray-400 focus:outline-none dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400",id:"is_feature",name:"is_feature",onChange:r=>o({...a,is_feature:r.target.value}),value:a.is_feature,children:[e.jsx("option",{value:"",children:"Select Option"}),e.jsx("option",{value:"1",children:"Yes"}),e.jsx("option",{value:"0",children:"No"})]}),t.is_feature&&e.jsx("span",{className:"text-red-500",children:t.is_feature})]})}),e.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:"Create Category"}),e.jsx("br",{}),e.jsx("br",{})]})})})]})};export{v as default};
