PageSourceSearch

https://rohitpatil.me/_next/static/chunks/pages/admin-tools/challenges/create-1884e3ce4730900b.js

js rohitpatil.me collected 2026-09-28 07:14:33 UTC 13,132 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[311],{87690:(e,s,t)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin-tools/challenges/create",function(){return t(95809)}])},95809:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>f});var l=t(37876),a=t(14232),n=t(89099),r=t(48230),i=t.n(r),o=t(75870),d=t(18480),c=t(89311),u=t(21639),m=t(34321),g=t(71297),x=t(68827),h=t(83872),p=t(43490),b=t(16495),y=t(57994);let f=()=>{let{id:e}=(0,n.useRouter)().query,s=!!e,t=(0,p.A)({allowedRoles:[b.USER_ROLES.PL_TEAM_ACCESS]}),[r,f]=(0,a.useState)(!1),[j,N]=(0,a.useState)(!1),[v,C]=(0,a.useState)({title:"",subTitle:"",ogDetails:{title:"",description:"",keywords:[],ogImage:""},context:"",slug:"",startDate:(0,o.A)(new Date,"yyyy-MM-dd"),endDate:"",showSubmissions:!1,prizes:[],FAQs:[],problemStatements:[]}),[T,A]=(0,a.useState)({question:"",answer:""}),[S,w]=(0,a.useState)({id:"",name:"",description:"",htmlDescription:"",videoPlayBackId:"",challengeGIF:"",day:1}),[D,E]=(0,a.useState)({id:"",title:"",subtitle:"",logo:"",link:""}),P=async()=>{try{var s;f(!0);let t=(await m.hG.getBySlug(e)).data;if(null==t||null==(s=t.data)?void 0:s.challenges){let e=t.data.challenges[0];C({title:e.title||"",subTitle:e.subTitle||"",ogDetails:e.ogDetails||{title:"",description:"",keywords:[],ogImage:""},context:e.context||"",slug:e.slug||"",startDate:e.startDate?(0,o.A)(new Date(e.startDate),"yyyy-MM-dd"):"",endDate:e.endDate?(0,o.A)(new Date(e.endDate),"yyyy-MM-dd"):"",showSubmissions:e.showSubmissions||!1,prizes:e.prizes||[],FAQs:e.FAQs||[],problemStatements:e.problemStatements||[]})}else g.A.ErrorToast("Failed to load challenge data")}catch(e){console.error("Error loading challenge:",e),g.A.ErrorToast(x.A.GLOBAL.wrong)}finally{f(!1)}},k=(e,s)=>{if(e.includes(".")){let[t,l]=e.split(".");C(e=>({...e,[t]:{...e[t],[l]:s}}))}else C(t=>({...t,[e]:s}))},_=async e=>{if(e.preventDefault(),!v.title||!v.context||!v.slug)return void g.A.ErrorToast("Please fill in all required fields");try{if(N(!0),s){let e={title:v.title,subTitle:v.subTitle,ogDetails:v.ogDetails,context:v.context,startDate:v.startDate,endDate:v.endDate,showSubmissions:v.showSubmissions};v.prizes&&v.prizes.length>0&&(e.contentType=b.CHALLENGE_UPDATE_CONST.CONTENT_TYPES.PRIZES,e.action=b.CHALLENGE_UPDATE_CONST.ACTIONS.UPDATE,e.contentData=v.prizes),v.FAQs&&v.FAQs.length>0&&(e.contentType=b.CHALLENGE_UPDATE_CONST.CONTENT_TYPES.FAQS,e.action=b.CHALLENGE_UPDATE_CONST.ACTIONS.UPDATE,e.contentData=v.FAQs),v.problemStatements&&v.problemStatements.length>0&&(e.contentType=b.CHALLENGE_UPDATE_CONST.CONTENT_TYPES.PROBLEM_STATEMENTS,e.action=b.CHALLENGE_UPDATE_CONST.ACTIONS.UPDATE,e.contentData=v.problemStatements),await m.hG.update(v.slug,e),g.A.SuccessToast("Challenge updated successfully")}else await m.hG.create(v),g.A.SuccessToast("Challenge created successfully")}catch(e){console.error("Error saving challenge:",e),g.A.ErrorToast((null==e?void 0:e.message)||"Failed to save challenge")}finally{N(!1)}};return((0,a.useEffect)(()=>{s&&t&&P()},[e,t]),!1===t)?null:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(y.A.CenterTop,{children:[(0,l.jsx)(d.A,{title:s?"Edit Challenge":"Create Challenge"}),(0,l.jsxs)("div",{className:"flex items-center gap-1",children:[(0,l.jsx)(y.A.BackButton,{href:b.APP_PATHS.adminToolsChallenges}),(0,l.jsx)(y.A.PageHeading,{children:s?"Edit Challenge":"Create New Challenge"})]})]}),(0,l.jsx)("div",{className:"min-h-screen mt-14",children:(0,l.jsxs)("div",{className:"px-4 py-8",children:[r?(0,l.jsx)("div",{className:"max-w-7xl mx-auto px-4 py-8",children:(0,l.jsx)("div",{className:"animate-pulse",children:(0,l.jsx)("div",{className:"h-8 bg-gray-200 rounded w-1/4 mb-6"})})}):null,(0,l.jsxs)("form",{onSubmit:_,className:"space-y-8",children:[(0,l.jsxs)("div",{className:"bg-white rounded-lg shadow-sm p-6",children:[(0,l.jsx)(c.default.SemiBoldText,{lg:!0,className:"mb-4",children:"Basic Information"}),(0,l.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"title",className:"block text-sm font-medium text-gray-700 mb-2",children:"Title *"}),(0,l.jsx)("input",{id:"title",type:"text",value:v.title,onChange:e=>k("title",e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"context",className:"block text-sm font-medium text-gray-700 mb-2",children:"Context *"}),(0,l.jsx)("input",{id:"context",type:"text",value:v.context,onChange:e=>k("context",e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"slug",className:"block text-sm font-medium text-gray-700 mb-2",children:"Slug *"}),(0,l.jsx)("input",{id:"slug",type:"text",value:v.slug,onChange:e=>k("slug",e.target.value.toLowerCase().replace(/\s+/g,"-")),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"subTitle",className:"block text-sm font-medium text-gray-700 mb-2",children:"Subtitle"}),(0,l.jsx)("input",{id:"subTitle",type:"text",value:v.subTitle,onChange:e=>k("subTitle",e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"startDate",className:"block text-sm font-medium text-gray-700 mb-2",children:"Start Date *"}),(0,l.jsx)("input",{id:"startDate",type:"date",value:v.startDate,onChange:e=>k("startDate",e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"endDate",className:"block text-sm font-medium text-gray-700 mb-2",children:"End Date"}),(0,l.jsx)("input",{id:"endDate",type:"date",value:v.endDate,onChange:e=>k("endDate",e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]}),(0,l.jsx)("div",{className:"mt-4",children:(0,l.jsxs)("label",{className:"flex items-center",children:[(0,l.jsx)("input",{type:"checkbox",checked:v.showSubmissions,onChange:e=>k("showSubmissions",e.target.checked),className:"mr-2"}),(0,l.jsx)("span",{className:"text-sm text-gray-700",children:"Show submissions on challenge page"})]})})]}),(0,l.jsxs)("div",{className:"bg-white rounded-lg shadow-sm p-6",children:[(0,l.jsx)(c.default.SemiBoldText,{lg:!0,className:"mb-4",children:"Problem Statements"}),(0,l.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[(0,l.jsx)("input",{type:"number",placeholder:"Day number",value:S.day,onChange:e=>w(s=>({...s,day:parseInt(e.target.value,10)})),className:"px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",min:"1"}),(0,l.jsx)("input",{type:"text",placeholder:"Problem name",value:S.name,onChange:e=>w(s=>({...s,name:e.target.value})),className:"px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,l.jsx)("input",{type:"text",placeholder:"Challenge GIF",value:S.challengeGIF,onChange:e=>w(s=>({...s,challengeGIF:e.target.value})),className:"px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,l.jsx)("input",{type:"text",placeholder:"Video Playback ID",value:S.videoPlayBackId,onChange:e=>w(s=>({...s,videoPlayBackId:e.target.value})),className:"px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[(0,l.jsx)("textarea",{rows:4,cols:50,placeholder:"Description",value:S.description,onChange:e=>w(s=>({...s,description:e.target.value})),className:"px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,l.jsx)("textarea",{rows:4,cols:50,placeholder:"HTML Description",value:S.htmlDescription,onChange:e=>w(s=>({...s,htmlDescription:e.target.value})),className:"px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),(0,l.jsx)(u.Ay.CarbonOutline,{onClick:()=>{S.name&&S.description&&S.day&&(C(e=>({...e,problemStatements:[...e.problemStatements,{...S,id:"ps-".concat(Date.now())}]})),w({id:"",name:"",description:"",htmlDescription:"",videoPlayBackId:"",challengeGIF:"",day:v.problemStatements.length+1}))},iconLeft:(0,l.jsx)(h.PlusIcon,{size:16}),children:"Add Problem Statement"}),v.problemStatements.length>0&&(0,l.jsx)("div",{className:"mt-4 space-y-2",children:v.problemStatements.map((e,s)=>(0,l.jsxs)("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded",children:[(0,l.jsxs)("div",{children:[(0,l.jsxs)(c.default.SemiBoldText,{children:["Day ",e.day,": ",e.name]}),(0,l.jsx)(c.default.NormalText,{sm:!0,className:"text-gray-600",children:e.description})]}),(0,l.jsx)(u.Ay.CarbonOutline,{onClick:()=>{C(e=>({...e,problemStatements:e.problemStatements.filter((e,t)=>
1t!==s)}))},size:"sm",iconLeft:(0,l.jsx)(h.TrashIcon,{size:16}),children:"Remove"})]},e.id))})]}),(0,l.jsxs)("div",{className:"bg-white rounded-lg shadow-sm p-6",children:[(0,l.jsx)(c.default.SemiBoldText,{lg:!0,className:"mb-4",children:"FAQs"}),(0,l.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[(0,l.jsx)("input",{type:"text",placeholder:"Question",value:T.question,onChange:e=>A(s=>({...s,question:e.target.value})),className:"px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,l.jsx)("input",{type:"text",placeholder:"Answer",value:T.answer,onChange:e=>A(s=>({...s,answer:e.target.value})),className:"px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),(0,l.jsx)(u.Ay.CarbonOutline,{onClick:()=>{T.question&&T.answer&&(C(e=>({...e,FAQs:[...e.FAQs,{...T,id:"faq-".concat(Date.now())}]})),A({question:"",answer:""}))},iconLeft:(0,l.jsx)(h.PlusIcon,{size:16}),children:"Add FAQ"}),v.FAQs.length>0&&(0,l.jsx)("div",{className:"mt-4 space-y-2",children:v.FAQs.map((e,s)=>(0,l.jsxs)("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(c.default.SemiBoldText,{children:e.question}),(0,l.jsx)(c.default.NormalText,{sm:!0,className:"text-gray-600",children:e.answer})]}),(0,l.jsx)(u.Ay.CarbonOutline,{onClick:()=>{C(e=>({...e,FAQs:e.FAQs.filter((e,t)=>t!==s)}))},size:"sm",iconLeft:(0,l.jsx)(h.TrashIcon,{size:16}),children:"Remove"})]},e.id))})]}),(0,l.jsxs)("div",{className:"bg-white rounded-lg shadow-sm p-6",children:[(0,l.jsx)(c.default.SemiBoldText,{lg:!0,className:"mb-4",children:"Prizes"}),(0,l.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[(0,l.jsx)("input",{type:"text",placeholder:"Prize title",value:D.title,onChange:e=>E(s=>({...s,title:e.target.value})),className:"px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,l.jsx)("input",{type:"text",placeholder:"Subtitle",value:D.subtitle,onChange:e=>E(s=>({...s,subtitle:e.target.value})),className:"px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,l.jsx)("input",{type:"url",placeholder:"Logo URL",value:D.logo,onChange:e=>E(s=>({...s,logo:e.target.value})),className:"px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,l.jsx)("input",{type:"url",placeholder:"Link URL",value:D.link,onChange:e=>E(s=>({...s,link:e.target.value})),className:"px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),(0,l.jsx)(u.Ay.CarbonOutline,{onClick:()=>{D.title&&D.subtitle&&D.logo&&D.link&&(C(e=>({...e,prizes:[...e.prizes,{...D,id:"prize-".concat(Date.now())}]})),E({id:"",title:"",subtitle:"",logo:"",link:""}))},iconLeft:(0,l.jsx)(h.PlusIcon,{size:16}),children:"Add Prize"}),v.prizes.length>0&&(0,l.jsx)("div",{className:"mt-4 space-y-2",children:v.prizes.map((e,s)=>(0,l.jsxs)("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(c.default.SemiBoldText,{children:e.title}),(0,l.jsx)(c.default.NormalText,{sm:!0,className:"text-gray-600",children:e.subt
1itle})]}),(0,l.jsx)(u.Ay.CarbonOutline,{onClick:()=>{C(e=>({...e,prizes:e.prizes.filter((e,t)=>t!==s)}))},size:"sm",iconLeft:(0,l.jsx)(h.TrashIcon,{size:16}),children:"Remove"})]},e.id))})]}),(0,l.jsxs)("div",{className:"flex justify-end gap-4",children:[(0,l.jsx)(i(),{href:"/admin-tools/challenges",children:(0,l.jsx)(u.Ay.CarbonOutline,{children:"Cancel"})}),(0,l.jsx)(u.Ay.Primary,{type:"submit",loading:j,children:s?"Update Challenge":"Create Challenge"})]})]})]})})]})}}},e=>{e.O(0,[636,6593,8792],()=>e(e.s=87690)),_N_E=e.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.