(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[405],{75557:function(e,n,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return a(53678)}])},53678:function(e,n,a){"use strict";a.r(n),a.d(n,{default:function(){return w}});var o=a(47568),l=a(41799),r=a(69396),t=a(97582),i=a(85893),u=a(67294),s=a(9008),c=a.n(s),d=a(21650),m=a(11163),$=a(82175),v=a(16310),p=a(1451),h=a(30846),y=a(13301),x=a(84252),f=a(91444),b=a(54200),_=a(91056),C=a(90271),g=a(88187),j=a(28059),k=a(58801),N=a(9041),Z=a(88091);function w(){var e,n,a=(0,u.useState)(1),s=a[0],w=a[1],L=(0,u.useState)(!0),P=L[0],S=L[1],q=(0,m.useRouter)(),E=(0,_.xq)(),W=E.mutate;E.isLoading;var A=(0,_.Z1)(),D=A.mutate;A.isLoading;var F=(0,_.x7)(),J=F.mutate;F.isLoading;var T,R=(0,u.useState)(!1),B=R[0],I=R[1],M=(0,u.useState)(!1),O=M[0],z=M[1],V=(0,u.useState)({}),X=V[0],G=V[1],H=(0,u.useState)(!1),Q=H[0],U=H[1],K=(0,u.useState)(N.EditorState.createEmpty()),Y=(K[0],K[1]),ee=function(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(e).toLowerCase())},en=v.Ry().shape({role:v.Z_().required("Role is required"),experienceLevel:v.Z_().required("Experience Level is required"),companyWebsite:v.Z_().required("Company Website is required"),email:v.Z_().required("Email is required"),companyName:v.Z_().required("Company Name is required"),fullName:v.Z_().required("FullName is required")}),ea=function(e){var n=(0,Z.ZP)(e),a=(0,N.convertFromHTML)(n),o=N.ContentState.createFromBlockArray(a.contentBlocks,a.entityMap);return Y(N.EditorState.createWithContent(o)),JSON.stringify((0,N.convertToRaw)(o))},eo=(0,$.TA)({initialValues:{role:"",experienceLevel:"",companyWebsite:"",email:"",companyName:"",fullName:""},validationSchema:en,onSubmit:(T=(0,o.Z)(function(e,n){var a,o,i,u,s,c,d;return(0,t.__generator)(this,function(t){a=n.resetForm,i={},d={};try{z(!0),o=(i.url=e.companyWebsite,i.job_role=e.role,i.experienceLevel=e.experienceLevel,i),s=(u=e.fullName.trim().split(" "))[0],c=u.length>1?u.slice(1).join(" "):s,J(o,(d.onSuccess=function(n){var a=null==n?void 0:n.data,o=ea(a.job_description),t={company_name:e.companyName,email:e.email,website:e.companyWebsite,first_name:s,last_name:c,phone_number:a.phone_number||"N/A",password:"123456789",is3p:!1,isFromJD:!0,hasResetJDPassword:!1,logo_url:null,about:a.about_company,company_size:a.company_size,headquaters:a.company_location,industry:a.industry||"N/A",year_founded:a.year_founded,why_you_should_work_for_us:a.why_you_should_work_for_us};a.job_description?W(t,{onSuccess:function(n){var t,i,u,s=null==n?void 0:null===(t=n.data)||void 0===t?void 0:t.company,c=null==n?void 0:null===(i=n.data)||void 0===i?void 0:i.user,d=null==n?void 0:null===(u=n.data)||void 0===u?void 0:u.message;"Company found"===d&&U(!0);var m=(0,r.Z)((0,l.Z)({},C.ZP),{jobDescription:o,jobLocation:[a.company_location],jobSkills:a.skills,jobTitle:null==e?void 0:e.role,collaborators:c,applicationDeadline:(0,Z.O8)(3),experienceLevel:[e.experienceLevel]});D({formDetails:m,employer:s,user:c},{onSuccess:function(e){var n;z(!1),I(!0),G(null==e?void 0:null===(n=e.data)||void 0===n?void 0:n.data)},onError:function(e){var n,a;return z(!1),f.Am.error("".concat(null==e?void 0:null===(n=e.response)||void 0===n?void 0:null===(a=n.data)||void 0===a?void 0:a.message)||"Error creating job listing"),e}})},onError:function(e){var n,a;return z(!1),f.Am.error("".concat(null==e?void 0:null===(n=e.response)||void 0===n?void 0:null===(a=n.data)||void 0===a?void 0:a.message)||"Error creating company profile on Loubby"),e}}):(z(!1),f.Am.error("".concat(null==n?void 0:n.data)))},d.onError=function(e){return z(!1),f.Am.error("Failed to generate JD"),e},d)),a(),w(1)}catch(m){return f.Am.error("Form submission failed."),[2,m]}return[2]})}),function(e,n){return T.apply(this,arguments)})});(0,u.useEffect)(function(){switch(s){case 1:S(""===eo.values.role);break;case 2:S(""===eo.values.experienceLevel);break;case 3:S(""===eo.values.companyWebsite);break;case 4:S(!ee(eo.values.email));break;case 5:S(""===eo.values.companyName);break;case 6:S(""===eo.values.fullName);break;default:S(!0)}},[eo.values,s]);var el=function(){1===s&&""!==eo.values.role?w(2):2===s&&""!==eo.values.experienceLevel?w(3):3===s&&""!==eo.values.companyWebsite?w(4):4===s&&""!==eo.values.email&&ee(eo.values.email)?w(5):5===s&&""!==eo.values.companyName?w(6):6===s&&""!==eo.values.fullName?eo.handleSubmit():f.Am.error("Please provide valid information")},er=function(){s>1&&w(s-1)};return(0,i.jsxs)("div",{children:[(0,i.jsxs)(c(),{children:[(0,i.jsx)("title",{children:"JD Builder"}),(0,i.jsx)("meta",{name:"JD Builder",content:"Get your job descriptions ready in few minutes by answering 3 questions"}),(0,i.jsx)("link",{rel:"icon",href:"/favicon.ico"})]}),(0,i.jsxs)(d.Z,{children:[(0,i.jsxs)("div",{className:"my-5 w-full max-w-[1000px] flex gap-2 items-center justify-center",children:[(0,i.jsx)(p.QWS,{className:"icon"}),(0,i.jsx)("button",{onClick:function(){return q.push("/upload")},className:"text-sm text-white opacity-65 underline",children:"Upload your Job description Instead"})]}),function(){switch(s){case 1:return(0,i.jsx)(h.Z,{id:"role",type:"text",placeholder:"What role are you hiring for?",subPlaceholder:"e.g. Product design, Customer support, etc.",value:eo.values.role,onChange:eo.handleChange,count:s,handleNextClick:el,handlePrevClick:er,maxCount:6});case 2:return(0,i.jsx)(h.Z,{id:"experienceLevel",isSelectable:!0,options:C.p9,type:"text",placeholder:"",subPlaceholder:"Click to select an option",value:eo.values.experienceLevel,onChange:function(e){return eo.setFieldValue("experienceLevel",e.target.value)},count:s,handleNextClick:el,handlePrevClick:er,maxCount:6});case 3:return(0,i.jsx)(h.Z,{id:"companyWebsite",type:"text",placeholder:"Link to your company website?",subPlaceholder:"e.g. www.example.com",value:eo.values.companyWebsite,onChange:eo.handleChange,count:s,handleNextClick:el,handlePrevClick:er,maxCount:6});case 4:return(0,i.jsx)(h.Z,{id:"email",type:"email",placeholder:"What's your company email?",subPlaceholder:"e.g. example@company.com",value:eo.values.email,onChange:eo.handleChange,count:s,handleNextClick:el,handlePrevClick:er,maxCount:6});case 5:return(0,i.jsx)(h.Z,{id:"companyName",type:"text",placeholder:"What's your company name?",subPlaceholder:"",value:eo.values.companyName,onChange:eo.handleChange,count:s,handleNextClick:el,handlePrevClick:er,maxCount:6});case 6:return(0,i.jsx)(h.Z,{id:"fullName",type:"text",placeholder:"What's your full name?",subPlaceholder:"",value:eo.values.fullName,onChange:eo.handleChange,count:s,handleNextClick:el,handlePrevClick:er,maxCount:6,submit:!0});default:return null}}(),(0,i.jsx)(x.Z,{count:s,handleNextClick:el,handlePrevClick:er,isNextDisabled:P}),(0,i.jsx)("div",{className:"flex smd:flex-row justify-start items-stretch gap-4 mt-12 flex-col pb-[3rem] smd:pb-2",children:null===b.Z||void 0===b.Z?void 0:b.Z.map(function(e){var n=e.title,a=e.Icon,o=e.content;return(0,i.jsx)(y.Z,{title:n,Icon:a,content:o},n)})}),O&&(0,i.jsx)(g.Z,{bgcolor:"transparent",children:(0,i.jsx)(k.Z,{})}),B&&(0,i.jsx)(g.Z,{bgcolor:"transparent",children:(0,i.jsx)(j.Z,{nameSlug:null==X?void 0:null===(e=X.employer)||void 0===e?void 0:e.name_slug,jobId:null==X?void 0:null===(n=X.listing)||void 0===n?void 0:n._id,existingCompany:Q,closeModal:function(){return I(!1)}})})]})]})}}},function(e){e.O(0,[445,570,866,556,238,434,774,888,179],function(){return e(e.s=75557)}),_N_E=e.O()}]);