import{aJ as w,r as s,u as j,j as e,f}from"./index-7c7a558c.js";import{B as v}from"./Breadcrumb-f4cb0f42.js";import{P as N}from"./PageLoader-31c46f94.js";const B=()=>{const[C,l,S]=w(),[g,u]=s.useState(!1),[_,c]=s.useState(!1),[d,x]=s.useState(null),[D,h]=s.useState(!0),p=j(),[r,i]=s.useState({title:"",course_type:"1",subtitle:"",description:""}),[a,m]=s.useState({}),y=()=>{const t={};return r.description||(t.description="Description is required"),r.title||(t.title="Title is required"),r.subtitle||(t.subtitle="Subtitle is required"),t},k=async t=>{t.preventDefault();const o=y();if(Object.keys(o).length===0)try{const b=await f.post(`https://www.bdskilltech.com/backend/public/api/admin/course-overview/${p.courseid}`,r,{headers:{Authorization:"Bearer "+l}});m({}),u(!0),t.target.reset()}catch(b){c(b.response.data.error)}else m(o)};if(s.useEffect(()=>{l&&(async()=>{try{const o=await f.get(`https://www.bdskilltech.com/backend/public/api/admin/courses/${p.courseid}`,{headers:{Authorization:"Bearer "+l}});x(o.data.data)}catch(o){console.error("Error fetching data:",o)}})(),setTimeout(()=>{c(""),u(!1)},5e3),setTimeout(()=>{h(!1)},500)},[l]),!d)return e.jsx(N,{title:"Update Course"});const{title:z,course:n}=d;return e.jsxs(e.Fragment,{children:[e.jsx(v,{title:"Update Course"}),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:k,children:[e.jsx("div",{className:"grid md:grid-cols-2 md:gap-6",children:g?e.jsx("h4",{className:"text-green-500 font-bold pb-8",children:"Course Update Successfully."}):""}),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:t=>i({...r,title:t.target.value}),defaultValue:r.title?r.title:n.title,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-600 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-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:"Course Name"}),a.title&&e.jsx("span",{className:"text-red-500",children:a.title})]}),e.jsxs("div",{className:"relative z-0 w-full mb-6 group",children:[e.jsx("input",{type:"text",onChange:t=>i({...r,subtitle:t.target.value}),defaultValue:r.subtitle?r.subtitle:n.subtitle,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-600 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-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:"Course Sub Title"}),a.subtitle&&e.jsx("span",{className:"text-red-500",children:a.subtitle})]})]}),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:t=>i({...r,description:t.target.value}),className:"shadow-sm bg-gray-50 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-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 dark:shadow-sm-light",required:!0,defaultValue:r.description?r.description:n.description}),a.description&&e.jsx("span",{className:"text-red-500",children:a.description})]}),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-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800",children:"Create Course"})]})})})]})};export{B as default};
