PageSourceSearch

https://www.codedex.io/_next/static/chunks/pages/admin/certificates/generate-bb3af3099ea00b8f.js

js codedex.io collected 2026-09-25 14:55:07 UTC 6,020 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2855],{94520:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/certificates/generate",function(){return a(59373)}])},17320:function(e,t,a){"use strict";a.d(t,{H:function(){return createBadgeCredential},I:function(){return createCredentialForCourse}});var n=a(87066);async function createCredentialForCourse(e){let{courseName:t,email:a,name:r,override:l}=e;try{let e=await n.Z.post("/api/cert",{courseName:t,email:a,name:r,override:l});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:t,email:a,name:r,month:l}=e;try{let e=await n.Z.post("/api/cert/badges/",{badgeName:t,email:a,name:r,month:l});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){}}},59373:function(e,t,a){"use strict";a.r(t),a.d(t,{__N_SSP:function(){return d}});var n=a(82729),r=a(85893),l=a(67294),i=a(19521),s=a(99428),c=a(17320);function _templateObject(){let e=(0,n._)(["\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      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.4rem;\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 o=i.default.div.withConfig({componentId:"sc-4f7472ca-0"})(_templateObject(),e=>e.theme.colors.text1),u={default:{value:"default",label:"Select a course"},python:{value:"python",label:"The Legend of Python"},html:{value:"html",label:"The Origin I: HTML"},css:{value:"css",label:"The Origin II: CSS"},javascript:{value:"javascript",label:"The Origin III: JavaScript"},react:{value:"react",label:"Framework Valley: React"},java:{value:"java",label:"Java"},cpp:{value:"cpp",label:"C++"}};var d=!0;t.default=function(){let[e,t]=(0,l.useState)({value:"default",label:"Select a course"}),[a,n]=(0,l.useState)(""),[i,d]=(0,l.useState)(""),[f,m]=(0,l.useState)(null),[h,p]=(0,l.useState)(null),[g,v]=(0,l.useState)(!1),[b,x]=(0,l.useState)("");console.log(f);let j=(0,l.useCallback)(async function(n){if(n.preventDefault(),"default"===e.value)return p("Please select a course");try{let n=await (0,c.I)({courseName:e.value,email:a,name:i,override:!0});if(console.log(n,"response"),"success"===n.status)m(n.data),p(null),t({value:"default",label:"Select a course"});else{let e=n.data;if("provide-name"===e)return p("User doesn't have a name saved. Contact the engineers.");if("provide-email"===e)return p("User doesn't have an email saved. Contact the engineers.");if("user-not-found"===e)return p("User not found. Contact the engineers.");p("Something went wrong. Contact the engineers.")}}catch(e){console.error(e),p("Something went wrong. Contact the engineers.")}},[a,i,e.value]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(s.Z,{}),(0,r.jsxs)(o,{children:[(0,r.jsx)("h1",{children:"Generate Certificate for a User"}),(0,r.jsxs)("div",{className:"input-container",children:[(0,r.jsxs)("div",{className:"email-fetcher",children:[(0,r.jsxs)("label",{htmlFor:"unique-username",children:["Username to find email",(0,r.jsx)("input",{type:"text",placeholder:"Enter username",value:b,onChange:e=>x(e.target.value)})]}),(0,r.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:b})}),t=await e.json();"success"===t.status?n(t.email):(p("User not found"),n(""))},children:"Find Email"})]}),(0,r.jsxs)("form",{onSubmit:j,children:[(0,r.jsxs)("label",{htmlFor:"email-address",children:["User Email",(0,r.jsx)("input",{type:"email",name:"email-address",placeholder:"email",onChange:e=>{n(e.currentTarget.value)},id:"email-address",value:a})]}),(0,r.jsxs)("label",{htmlFor:"name",children:["User Full Name",(0,r.jsx)("input",{type:"text",name:"name",placeholder:"name to be displayed on certificate",onCh
1ange:e=>{d(e.currentTarget.value)},id:"name",value:i})]}),(0,r.jsxs)("label",{htmlFor:"course",children:["Course",(0,r.jsx)("select",{value:e.value,onChange:e=>t(u[e.currentTarget.value]),children:Object.entries(u).map(e=>{let[t,a]=e;return(0,r.jsx)("option",{disabled:"default"===a.value,value:a.value,children:a.label},a.value)})})]}),(0,r.jsx)("button",{type:"submit",className:"nes-btn is-primary",children:"Generate"})]})]}),(0,r.jsx)("div",{className:"response-container",children:g?(0,r.jsx)("p",{children:"Loading..."}):(0,r.jsxs)(r.Fragment,{children:[f&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Generated Certificate"}),(0,r.jsx)("img",{src:f.certificate.image.preview,alt:"Certificate"}),(0,r.jsx)("h2",{children:"User Certificate URL"}),(0,r.jsx)("a",{href:"https://codedex.io/certificates/".concat(f.uuid),target:"_blank",rel:"noreferrer",children:"".concat(window.origin,"/certificates/").concat(f.uuid)}),(0,r.jsx)("button",{className:"copy-url nes-btn",style:{color:"black"},onClick:()=>{navigator.clipboard.writeText("".concat(window.origin,"/certificates/").concat(f.uuid))},children:"Copy"})]}),h&&(0,r.jsx)("p",{children:h})]})})]}),";"]})}}},function(e){e.O(0,[1272,8700,4153,1622,9280,9428,9774,2888,179],function(){return e(e.s=94520)}),_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.