1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6823],{78090:function(e,n,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/badges/generate",function(){return a(93934)}])},17320:function(e,n,a){"use strict";a.d(n,{H:function(){return createBadgeCredential},I:function(){return createCredentialForCourse}});var t=a(87066);async function createCredentialForCourse(e){let{courseName:n,email:a,name:l,override:r}=e;try{let e=await t.Z.post("/api/cert",{courseName:n,email:a,name:l,override:r});if("success"===e.data.status)return{status:"success",data:e.data.data};if("fail"===e.data.status)return{status:"fail",data:e.data.data};return e}catch(e){}}async function createBadgeCredential(e){let{badgeName:n,email:a,name:l,month:r}=e;try{let e=await t.Z.post("/api/cert/badges/",{badgeName:n,email:a,name:l,month:r});if("success"===e.data.status)return{status:"success",data:e.data.data};if("fail"===e.data.status)return{status:"fail",data:e.data.data};return e}catch(e){}}},93934:function(e,n,a){"use strict";a.r(n),a.d(n,{__N_SSP:function(){return d}});var t=a(82729),l=a(85893),r=a(67294),i=a(19521),s=a(99428),o=a(17320);function _templateObject(){let e=(0,t._)(["\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n\n margin-top: 7.5rem;\n font-family: Montserrat, sans-serif;\n color: ",";\n\n .input-container {\n display: flex;\n gap: 2rem;\n font-size: 1.2rem;\n\n label {\n font-size: 1.2rem;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n }\n\n .email-fetcher {\n display: flex;\n flex-flow: column;\n\n button {\n font-weight: bold;\n }\n }\n }\n\n form {\n display: flex;\n flex-direction: column;\n gap: 1rem;\n font-size: 1.2rem;\n\n label {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n }\n\n button {\n font-weight: bold;\n }\n img {\n margin-bottom: 1.5rem;\n }\n }\n\n .response-container {\n margin-top: 2rem;\n }\n"]);return _templateObject=function(){return e},e}let u=i.default.div.withConfig({componentId:"sc-f46584c2-0"})(_templateObject(),e=>e.theme.colors.text1),c={default:{value:"default",label:"Select a badge"},"summer-hackathon-2024-hacker":{value:"summer-hackathon-2024-hacker",label:"Cod\xe9dex Summer Hackathon 2024 Hacker"},"summer-hackathon-2024-winner":{value:"summer-hackathon-2024-winner",label:"Cod\xe9dex Summer Hackathon 2024 Winner"},"club-for-life":{value:"club-for-life",label:"Club for Life"},"monthly-challenge-2024":{value:"monthly-challenge-2024",label:"Cod\xe9dex Monthly Challenge 2024"},"mini-holiday-hackathon-2024-hacker":{value:"mini-holiday-hackathon-2024-hacker",label:"Cod\xe9dex Mini Holiday Hackathon 2024 Hacker"},"mini-holiday-hackathon-2024-winner":{value:"mini-holiday-hackathon-2024-winner",label:"Cod\xe9dex Mini Holiday Hackathon 2024 Winner"}};var d=!0;n.default=function(){var e,n;let[a,t]=(0,r.useState)({value:"default",label:"Select a badge"}),[i,d]=(0,r.useState)(""),[h,m]=(0,r.useState)(""),[f,p]=(0,r.useState)(null),[v,x]=(0,r.useState)(null),[g,b]=(0,r.useState)(""),[j,y]=(0,r.useState)(!1),[C,k]=(0,r.useState)("");console.log(f);let w=(0,r.useCallback)(async function(e){if(e.preventDefault(),"default"===a.value)return x("Please select a course");try{let e=await (0,o.H)({badgeName:a.value,email:i,name:h,month:g});if("success"===e.status)p(e.data),x(null),t({value:"default",label:"Select a course"});else{let n=e.data;if("provide-name"===n)return x("User doesn't have a name saved. Contact the engineers.");if("provide-email"===n)return x("User doesn't have an email saved. Contact the engineers.");if("user-not-found"===n)return x("User not found. Contact the engineers.");x("Something went wrong. Contact the engineers.")}}catch(e){console.error(e),x("Something went wrong. Contact the engineers.")}},[i,g,h,a.value]);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.Z,{}),(0,l.jsxs)(u,{children:[(0,l.jsx)("h1",{children:"Generate Badge for a User"}),(0,l.jsxs)("div",{className:"input-container",children:[(0,l.jsxs)("div",{className:"email-fetcher",children:[(0,l.jsxs)("label",{htmlFor:"unique-username",children:["Username to find email",(0,l.jsx)("input",{type:"text",placeholder:"username",value:C,onChange:e=>k(e.target.value)})]}),(0,l.jsx)("button",{className:"nes-btn is-primary",onClick:async()=>{let e=await fetch("/api/admin/certificates/getEmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({uniqueUsername:C})}),n=await e.json();"success"===n.status?d(n.email):(x("User not found"),d(""))},children:"Find Email"})]}),(0,l.jsxs)("form",{onSubmit:w,children:[(0,l.jsxs)("label",{htmlFor:"email-address",children:["User Email",(0,l.jsx)("input",{type:"email",name:"email-address",placeholder:"email",onChange:e=>{d(e.currentTarget.value)},id:"email-address",value:i})]}),(0,l.jsxs)("label",{htmlFor:"name",children:["User Full Name",(0,l.jsx)("input",{type:"text",name:"name",placeholder:"name on badge",onCh
1ange:e=>{m(e.currentTarget.value)},id:"name",value:h})]}),(0,l.jsxs)("label",{htmlFor:"course",children:["Badge",(0,l.jsx)("select",{value:a.value,onChange:e=>{t(c[e.currentTarget.value]),"monthly-challenge-2024"!==e.currentTarget.value&&b("")},children:Object.entries(c).map(e=>{let[n,a]=e;return(0,l.jsx)("option",{disabled:"default"===a.value,value:a.value,children:a.label},a.value)})})]}),"monthly-challenge-2024"===a.value&&(0,l.jsx)("label",{htmlFor:"month",children:(0,l.jsxs)("select",{value:g,onChange:e=>b(e.currentTarget.value),children:[(0,l.jsx)("option",{value:"default",children:"Select a month"}),(0,l.jsx)("option",{value:"january",children:"January"}),(0,l.jsx)("option",{value:"february",children:"February"}),(0,l.jsx)("option",{value:"march",children:"March"}),(0,l.jsx)("option",{value:"april",children:"April"}),(0,l.jsx)("option",{value:"may",children:"May"}),(0,l.jsx)("option",{value:"june",children:"June"}),(0,l.jsx)("option",{value:"july",children:"July"}),(0,l.jsx)("option",{value:"august",children:"August"}),(0,l.jsx)("option",{value:"september",children:"September"}),(0,l.jsx)("option",{value:"october",children:"October"}),(0,l.jsx)("option",{value:"november",children:"November"}),(0,l.jsx)("option",{value:"december",children:"December"})]})}),(0,l.jsx)("button",{type:"submit",className:"nes-btn is-primary",children:"Generate"})]})]}),(0,l.jsx)("div",{className:"response-container",children:j?(0,l.jsx)("p",{children:"Loading..."}):(0,l.jsxs)(l.Fragment,{children:[f&&(0,l.jsxs)("div",{children:[(0,l.jsx)("h2",{children:"Generated Badge"}),(0,l.jsx)("img",{src:null===(n=f.badge)||void 0===n?void 0:null===(e=n.image)||void 0===e?void 0:e.preview,alt:"badge"})]}),v&&(0,l.jsx)("p",{children:v})]})})]}),";"]})}}},function(e){e.O(0,[1272,8700,4153,1622,9280,9428,9774,2888,179],function(){return e(e.s=78090)}),_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.