import{aJ as v,r,j as e,f as b}from"./index-7c7a558c.js";import{B as S}from"./Breadcrumb-f4cb0f42.js";import{P as N}from"./PageLoader-31c46f94.js";function F(){const[D,o,E]=v(),[P,f]=r.useState(!0),[h,l]=r.useState(!1),[i,g]=r.useState(!1),[u,x]=r.useState(null),[s,p]=r.useState({description:""}),[c,m]=r.useState({}),y=a=>{p({...s,[a.target.name]:a.target.value})},k=async a=>{a.preventDefault();let t=!0;const n={};if(s.description||(t=!1,n.description="Description is required"),t)try{const d=await b.post("https://www.bdskilltech.com/backend/public/api/admin/privacy-policy",s,{headers:{Authorization:"Bearer "+o}});console.log(d),p({description:""}),m({}),l(!0)}catch(d){n.description=d.response.data.error}m(n)};if(r.useEffect(()=>{o&&(async()=>{try{const t=await b.get("https://www.bdskilltech.com/backend/public/api/admin/privacy-policy",{headers:{Authorization:"Bearer "+o}});x(t.data.data)}catch(t){console.error("Error fetching data:",t)}})(),setTimeout(()=>{g(""),l(!1)},5e3),setTimeout(()=>{f(!1)},500)},[o]),!u)return e.jsx(N,{title:"Privacy Policy"});const{title:w,policy:j}=u;return e.jsxs(e.Fragment,{children:[e.jsx(S,{title:w}),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:"Privacy Policy Updated Succesulful"}),i&&e.jsx("p",{className:"text-red-800 p-5 font-bold",children:i}),e.jsxs("form",{className:"p-5",onSubmit:k,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:y,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 ${c.password||i?" border-red-500 dark:border-red-500":" border-gray-300"}`,required:!0,defaultValue:s.description?s.description:j.description}),c.description&&e.jsx("span",{className:"text-red-500",children:c.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};
