import{aJ as S,r as t,j as e,f as b}from"./index-7c7a558c.js";import{B as N}from"./Breadcrumb-f4cb0f42.js";import{P as v}from"./PageLoader-31c46f94.js";function F(){const[D,o,E]=S(),[C,f]=t.useState(!0),[h,l]=t.useState(!1),[i,g]=t.useState(!1),[u,x]=t.useState(null),[s,m]=t.useState({description:""}),[n,p]=t.useState({}),k=a=>{m({...s,[a.target.name]:a.target.value})},w=async a=>{a.preventDefault();let r=!0;const d={};if(s.description||(r=!1,d.description="Description is required"),r)try{const c=await b.post("https://www.bdskilltech.com/backend/public/api/admin/term-conditions",s,{headers:{Authorization:"Bearer "+o}});console.log(c),m({description:""}),p({}),l(!0)}catch(c){d.description=c.response.data.error}p(d)};if(t.useEffect(()=>{o&&(async()=>{try{const r=await b.get("https://www.bdskilltech.com/backend/public/api/admin/term-conditions",{headers:{Authorization:"Bearer "+o}});x(r.data.data)}catch(r){console.error("Error fetching data:",r)}})(),setTimeout(()=>{g(""),l(!1)},5e3),setTimeout(()=>{f(!1)},500)},[o]),!u)return e.jsx(v,{title:"Terms & Conditions"});const{title:y,policy:j}=u;return e.jsxs(e.Fragment,{children:[e.jsx(N,{title:y}),e.jsx("div",{className:"my-12 h-screen",children:e.jsxs("div",{className:"relative overflow-x-auto shadow-md sm:rounded-lg section-bg p-2",children:[h&&e.jsx("p",{className:"text-green-800 p-5 font-bold",children:"Terms & Condition Updated Succesulful"}),i&&e.jsx("p",{className:"text-red-800 p-5 font-bold",children:i}),e.jsxs("form",{className:"p-5",onSubmit:w,children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{htmlFor:"description",className:"block mb-2 text-sm font-medium text-gray-900 dark:text-white",children:"Description"}),e.jsx("textarea",{id:"description",name:"description",rows:"18",onChange:k,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 ${n.password||i?" border-red-500 dark:border-red-500":" border-gray-300"}`,required:!0,defaultValue:s.description?s.description:j.description}),n.description&&e.jsx("span",{className:"text-red-500",children:n.description})]}),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 px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800",children:"Update Data"})]})]})})]})}export{F as default};
