import{c as f,b as g,r as p,j as e,n as a}from"./index-7c7a558c.js";import{B as x}from"./Breadcrumb-21e99ae5.js";import{p as h}from"./courseApi-e3b335b8.js";const v=()=>{const l=f(),{isLoading:d,mutate:c}=g(h,{onSuccess:r=>{var o,i,u,n;s({title:"",course_type:"1",subtitle:"",description:""}),a.success("Successfully Created!"),(i=(o=r==null?void 0:r.data)==null?void 0:o.data)!=null&&i.uuid?l(`/admin/updatecourse/${(n=(u=r==null?void 0:r.data)==null?void 0:u.data)==null?void 0:n.uuid}`):l("/admin/allcourse")},onError:r=>{r.response.data.error?a.error(`${r.response.data.error}`):a.error("something went wrong!")}}),[t,s]=p.useState({title:"",course_type:"1",subtitle:"",description:""}),m=()=>t.description?t.title?t.subtitle?!0:(a.error("Subtitle is required"),!1):(a.error("Title is required"),!1):(a.error("Description is required"),!1),b=async r=>{r.preventDefault(),m()&&!d&&c({formdata:t})};return e.jsxs(e.Fragment,{children:[e.jsx(x,{title:"Add New Course"}),e.jsx("div",{className:"my-12 h-screen",children:e.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:e.jsxs("form",{className:"p-5",onSubmit:b,children:[e.jsx("div",{className:"grid md:grid-cols-2 md:gap-6"}),e.jsxs("div",{className:"grid md:grid-cols-2 md:gap-6",children:[e.jsxs("div",{className:"relative z-0 w-full mb-6 group",children:[e.jsx("input",{type:"text",onChange:r=>s({...t,title:r.target.value}),name:"floating_first_name",id:"floating_first_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-300 dark:focus:border-blue-500 focus:outline-none focus:ring-0 focus:border-blue-600",placeholder:" ",required:!0}),e.jsx("label",{htmlFor:"floating_first_name",className:"peer-focus:font-medium absolute text-sm text-gray-200 dark:text-gray-200 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:"Course Name"})]}),e.jsxs("div",{className:"relative z-0 w-full mb-6 group",children:[e.jsx("input",{type:"text",onChange:r=>s({...t,subtitle:r.target.value}),name:"floating_last_name",id:"floating_last_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-300 dark:focus:border-blue-500 focus:outline-none focus:ring-0 focus:border-blue-600",placeholder:" ",required:!0}),e.jsx("label",{htmlFor:"floating_last_name",className:"peer-focus:font-medium absolute text-sm text-gray-200 dark:text-gray-200 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:"Course Sub Title"})]})]}),e.jsx("br",{}),e.jsxs("div",{className:"relative z-0 w-full mb-6 group",children:[e.jsx("label",{htmlFor:"message",className:"block mb-2 text-sm font-medium text-gray-900 dark:text-white",children:"Course Description"}),e.jsx("textarea",{rows:"18",onChange:r=>s({...t,description:r.target.value}),className:"shadow-sm bg-transparent border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-transparent dark:border-gray-300 dark:placeholder-[#422e9d] dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 dark:shadow-sm-light",required:!0})]}),e.jsx("br",{}),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-btn dark:hover:bg-btnHover dark:focus:ring-blue-800",children:d?"Creating...":"Create Course"})]})})})]})};export{v as default};
