import{b as k,r as _,j as e,i as F,a as f}from"./index-7c7a558c.js";import{B as z}from"./Breadcrumb-065f300e.js";import{q as L,r as D}from"./studentApi-6e4fac08.js";import{o as R}from"./ObjectToFormData-bf0af219.js";function m({typeName:s,refetchFn:u,afffiliateCreate:t}){var b,x,p,h,g,j,v,w,y,S;const{mutate:l,isLoading:a}=k(L,{onSuccess:()=>{u(),d({})}}),[r,d]=_.useState({link_1:""}),i=o=>{o.preventDefault();let n={...r,type:s};l({formdata:R(n)})},A=(o,n)=>{d(c=>({...c,[o]:n}))},N=o=>o==1?"Reviewed":o==2?"Rejected":o==3&&"Under Review";return e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl capitalize text-white my-4 px-4",children:(b=s==null?void 0:s.split("_"))==null?void 0:b.join(" ")}),(p=(x=t==null?void 0:t.data)==null?void 0:x.data)!=null&&p.allowed_submission?e.jsxs("form",{className:"p-5",onSubmit:i,children:[(h=Object.keys(r))==null?void 0:h.map((o,n)=>e.jsxs("div",{className:"relative z-0 w-full mb-6 group",children:[e.jsx("input",{type:"text",name:`${o}`,id:`${o}`,className:"block py-2.5 px-0 w-full text-sm bg-transparent border-0 border-b-2 border-blue-300 appearance-none text-white dark:border-gray-600 dark:focus:border-blue-500 focus:outline-none focus:ring-0 focus:border-blue-600 ",placeholder:" ",defaultValue:r==null?void 0:r[o],onChange:c=>A(o,c.target.value),required:!0}),e.jsxs("label",{htmlFor:`${o}`,className:"peer-focus:font-medium absolute text-sm text-gray-100 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:["Link ",n+1]})]},n)),((g=Object.keys(r))==null?void 0:g.length)!=0&&e.jsx("button",{type:"submit",className:"text-white bg-gradient-to-r from-green-400 to-blue-500 hover:from-pink-500 hover:to-yellow-500 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",disabled:a,children:a?e.jsx(F,{color:"white",size:"lg",variant:"dots"}):"Submit"})]}):e.jsxs("h2",{className:"text-xl capitalize text-white my-4 px-4",children:["You can","'","t submit untill 24hour passed. Your submission status:"," ",(v=(j=t==null?void 0:t.data)==null?void 0:j.data)!=null&&v.AffiliateSubmission?N((S=(y=(w=t==null?void 0:t.data)==null?void 0:w.data)==null?void 0:y.AffiliateSubmission)==null?void 0:S.status):"under review"]})]})}function O(){var a,r,d,i;const{data:s,isLoading:u,refetch:t,isFetching:l}=f("getAffiliateSubmissionCreate",()=>D());return e.jsxs(e.Fragment,{children:[e.jsx(z,{title:"Affiliate Program"}),e.jsx("div",{className:"container mx-auto my-5 p-5 min-h-screen",children:e.jsx("div",{className:"my-12",children:e.jsx("div",{className:"relative overflow-x-auto shadow-md bg-gradient-to-r from-main to-second p-6 border-dashed border rounded-tr-xl rounded-bl-xl",children:e.jsx("div",{className:"",children:u&&l?e.jsx(F,{}):(r=(a=s==null?void 0:s.data)==null?void 0:a.data)!=null&&r.photo_editing?e.jsx(m,{typeName:"photo_editing",refetchFn:t,afffiliateCreate:s},1):(i=(d=s==null?void 0:s.data)==null?void 0:d.data)!=null&&i.video_editing?e.jsx(m,{typeName:"video_editing",refetchFn:t,afffiliateCreate:s},1):e.jsx(m,{typeName:"photo_editing",refetchFn:t,afffiliateCreate:s},1)})})})})]})}export{O as default};
