1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1507],{84191:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/dashboard/badges",function(){return a(61176)}])},61176:function(e,t,a){"use strict";a.r(t),a.d(t,{__N_SSP:function(){return q}});var r=a(52322),i=a(2784),l=a(77245),s=a(18292),n=a(43297),o=a(29117),d=a(74409),c=a(62614),h=a(56453),m=a(75397),p=a(70189),g=a(78534),x=a(80774),u=a(5832),j=a(66983),w=a(79443),v=a(82554),f=a(77533),T=a(14738),I=a(92139),S=a(55199),y=a(54326),C=a(2338),U=a(97217),b=a(35183),k=a(97166),z=a(85573),N=a(29494),L=a(41098),A=a(50250),E=a(5677),V=a(98078),_=a(92642);let O={name:"",question:"",isList:!1,isActive:!0,supportsVertical:!0,supportsHorizontal:!1,onlyShowWhenAwarded:!1,downloadImageUrlTemplate:"",downloadImageUrlTemplateSvg:"",watermarkedImageUrlTemplate:"",watermarkedImageUrlTemplateSvg:""},W=()=>{let[e,t]=(0,i.useState)([]),[a,W]=(0,i.useState)(!1),[q,H]=(0,i.useState)(O),[G,P]=(0,i.useState)(!1),{isOpen:R,onOpen:F,onClose:D}=(0,s.q)(),{setNotification:B}=(0,V.lm)(),X=async()=>{try{W(!0);let e=await fetch("/api/admin/badges");if(!e.ok)throw Error("Failed to fetch badges");let a=await e.json();t(a)}catch(e){(0,_.Tb)(e),B(V.FB)}finally{W(!1)}};(0,i.useEffect)(()=>{X()},[]);let K=()=>{P(!1),H(O),F()},Q=e=>{P(!0),H({id:e.id,name:e.name,question:e.question,isList:e.isList,isActive:e.isActive,supportsVertical:!1!==e.supportsVertical,supportsHorizontal:!0===e.supportsHorizontal,onlyShowWhenAwarded:!0===e.onlyShowWhenAwarded,downloadImageUrlTemplate:e.downloadImageUrlTemplate||"",downloadImageUrlTemplateSvg:e.downloadImageUrlTemplateSvg||"",watermarkedImageUrlTemplate:e.watermarkedImageUrlTemplate||"",watermarkedImageUrlTemplateSvg:e.watermarkedImageUrlTemplateSvg||""}),F()},Y=async()=>{try{var e,t,a,r;W(!0);let i={name:q.name,question:q.question,isList:q.isList,isActive:q.isActive,supportsVertical:q.supportsVertical,supportsHorizontal:q.supportsHorizontal,onlyShowWhenAwarded:q.onlyShowWhenAwarded,downloadImageUrlTemplate:(null===(e=q.downloadImageUrlTemplate)||void 0===e?void 0:e.trim())||void 0,downloadImageUrlTemplateSvg:(null===(t=q.downloadImageUrlTemplateSvg)||void 0===t?void 0:t.trim())||void 0,watermarkedImageUrlTemplate:(null===(a=q.watermarkedImageUrlTemplate)||void 0===a?void 0:a.trim())||void 0,watermarkedImageUrlTemplateSvg:(null===(r=q.watermarkedImageUrlTemplateSvg)||void 0===r?void 0:r.trim())||void 0},l=await fetch(G&&q.id?"/api/admin/badges/".concat(q.id):"/api/admin/badges",{method:G?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw Error("Failed to save badge");await X(),D()}catch(e){(0,_.Tb)(e),B(V.FB)}finally{W(!1)}},Z=async e=>{try{W(!0);let t=await fetch("/api/admin/badges/".concat(e),{method:"DELETE"});if(!t.ok&&204!==t.status)throw Error("Failed to delete badge");await X()}catch(e){(0,_.Tb)(e),B(V.FB)}finally{W(!1)}};return(0,r.jsx)(E.cl,{children:(0,r.jsxs)(E.$0,{icon:l.LVi,crumbs:[{children:"Dashboard",path:"/admin/dashboard"},{children:"Certifications",isCurrentPage:!0}],children:[(0,r.jsxs)(n.K,{spacing:6,children:[(0,r.jsxs)(o.U,{justify:"space-between",children:[(0,r.jsx)(d.X,{size:"md",children:"Certifications"}),(0,r.jsx)(c.z,{colorScheme:"blue",onClick:K,children:"Create Certification"})]}),(0,r.jsx)(h.Z,{children:(0,r.jsx)(m.e,{children:(0,r.jsxs)(p.i,{size:"sm",children:[(0,r.jsx)(g.h,{children:(0,r.jsxs)(x.Tr,{children:[(0,r.jsx)(u.Th,{children:"Name"}),(0,r.jsx)(u.Th,{children:"Type"}),(0,r.jsx)(u.Th,{children:"Question"}),(0,r.jsx)(u.Th,{children:"Active"}),(0,r.jsx)(u.Th,{children:"Vertical"}),(0,r.jsx)(u.Th,{children:"Horizontal"}),(0,r.jsx)(u.Th,{children:"Actions"})]})}),(0,r.jsx)(j.p,{children:e.map(e=>(0,r.jsxs)(x.Tr,{children:[(0,r.jsx)(w.Td,{children:e.name}),(0,r.jsx)(w.Td,{children:(0,r.jsx)(v.C,{colorScheme:e.isList?"purple":"blue",children:e.isList?"List":"Certification"})}),(0,r.jsx)(w.Td,{maxW:"320px",children:(0,r.jsx)(f.x,{noOfLines:2,children:e.question})}),(0,r.jsx)(w.Td,{children:(0,r.jsx)(v.C,{colorScheme:e.isActive?"green":"red",children:e.isActive?"Active":"Inactive"})}),(0,r.jsx)(w.Td,{children:!1!==e.supportsVertical?"Yes":"No"}),(0,r.jsx)(w.Td,{children:!0===e.supportsHorizontal?"Yes":"No"}),(0,r.jsx)(w.Td,{children:(0,r.jsxs)(o.U,{spacing:2,children:[(0,r.jsx)(c.z,{size:"xs",onClick:()=>Q(e),children:"Edit"}),(0,r.jsx)(c.z,{size:"xs",colorScheme:"red",variant:"outline",onClick:()=>Z(e.id),children:"Deactivate"})]})})]},e.id))})]})})})]}),(0,r.jsxs)(T.u_,{isOpen:R,onClose:D,size:"xl",children:[(0,r.jsx)(I.Z,{}),(0,r.jsxs)(S.h,{children:[(0,r.jsx)(y.x,{children:G?"Edit Certification":"Create Certification"}),(0,r.jsx)(C.o,{}),(0,r.jsx)(U.f,{children:(0,r.jsxs)(n.K,{spacing:4,children:[(0,r.jsxs)(b.NI,{isRequired:!0,children:[(0,r.jsx)(k.l,{children:"Name"}),(0,r.jsx)(z.I,{value:q.name,onChange:e=>H(t=>({...t,name:e.target.value}))})]}),(0,r.jsxs)(b.NI,{children:[(0,r.jsx)(k.l,{children:"Question"}),(0,r.jsx)(N.g,{value:q.question,onChange:e=>H(t=>({...t,question:e.target.value}))})]}),(0,r.jsxs)(b.NI,{display:"flex",alignItems:"center",children:[(0,r.jsx)(k.l,{mb:"0",children:"Type"}),(0,r.jsxs)(o.U,{children:[(0,r.jsx)(v.C,{as:"button",colorScheme:q.isList?"gray":"blue",onClick:()=>H(e=>({...e,isList:!1})),children:"Certification"}),(0,r.jsx)(v.C,{as:"button",colorScheme:q.isList?"purple":"gray",onClick:()=>H(e=>({...e,isList:!0})),children:"List"})]})]}),(0,r.jsxs)(b.NI,{display:"flex",alignItems:"center",children:[(0,r.jsx)(k.l,{mb:"0",children:"Active"}),(0,r.jsx)(L.r,{isChecked:q.isActive,onChange:e=>H(t=>({...t,isActive:e.target.checked}))})]}),(0,r.jsxs)(b.NI,{display:"flex",alignItems:"center",children:[(0,r.jsx)(k.l,{mb:"0",children:"Supports Vertical"}
1),(0,r.jsx)(L.r,{isChecked:q.supportsVertical,onChange:e=>H(t=>({...t,supportsVertical:e.target.checked}))})]}),(0,r.jsxs)(b.NI,{display:"flex",alignItems:"center",children:[(0,r.jsx)(k.l,{mb:"0",children:"Supports Horizontal"}),(0,r.jsx)(L.r,{isChecked:q.supportsHorizontal,onChange:e=>H(t=>({...t,supportsHorizontal:e.target.checked}))})]}),(0,r.jsxs)(b.NI,{display:"flex",alignItems:"center",children:[(0,r.jsx)(k.l,{mb:"0",children:"Only Show When Earned"}),(0,r.jsx)(L.r,{isChecked:q.onlyShowWhenAwarded,onChange:e=>H(t=>({...t,onlyShowWhenAwarded:e.target.checked}))}),(0,r.jsx)(f.x,{fontSize:"sm",color:"gray.500",ml:2,children:"If enabled, certification only appears for users who have earned it (hidden from Available section)"})]}),(0,r.jsxs)(b.NI,{children:[(0,r.jsx)(k.l,{children:"Download Image URL Template"}),(0,r.jsx)(z.I,{type:"text",value:q.downloadImageUrlTemplate,onChange:e=>{H(t=>({...t,downloadImageUrlTemplate:e.target.value}))},placeholder:"https://...{type}...{year}...{orientation}...{format}...{slug}..."}),(0,r.jsxs)(f.x,{fontSize:"xs",color:"gray.500",mt:1,children:["Enter a direct URL (e.g., http://example.com/image.png) or template with placeholders (e.g., http://example.com/","{slug}",".png). Used for PNG format or when SVG template is not provided."]})]}),(0,r.jsxs)(b.NI,{children:[(0,r.jsx)(k.l,{children:"Download Image URL Template (SVG)"}),(0,r.jsx)(z.I,{type:"text",value:q.downloadImageUrlTemplateSvg,onChange:e=>{H(t=>({...t,downloadImageUrlTemplateSvg:e.target.value}))},placeholder:"https://...{type}...{year}...{orientation}...{slug}..."}),(0,r.jsxs)(f.x,{fontSize:"xs",color:"gray.500",mt:1,children:["Optional: SVG-specific template. If provided, this will be used when format=svg. Otherwise, the regular template will be used with ","{format}"," replaced by 'svg'."]})]}),(0,r.jsxs)(b.NI,{children:[(0,r.jsx)(k.l,{children:"Watermarked Image URL Template"}),(0,r.jsx)(z.I,{type:"text",value:q.watermarkedImageUrlTemplate,onChange:e=>{H(t=>({...t,watermarkedImageUrlTemplate:e.target.value}))},placeholder:"https://...{type}...{year}...{orientation}...{format}...{slug}..."}),(0,r.jsxs)(f.x,{fontSize:"xs",color:"gray.500",mt:1,children:["Enter a direct URL (e.g., http://example.com/image.png) or template with placeholders (e.g., http://example.com/","{slug}",".png). Used for PNG format or when SVG template is not provided."]})]}),(0,r.jsxs)(b.NI,{children:[(0,r.jsx)(k.l,{children:"Watermarked Image URL Template (SVG)"}),(0,r.jsx)(z.I,{type:"text",value:q.watermarkedImageUrlTemplateSvg,onChange:e=>{H(t=>({...t,watermarkedImageUrlTemplateSvg:e.target.value}))},placeholder:"https://...{type}...{year}...{orientation}...{slug}..."}),(0,r.jsxs)(f.x,{fontSize:"xs",color:"gray.500",mt:1,children:["Optional: SVG-specific template. If provided, this will be used when format=svg. Otherwise, the regular template will be used with ","{format}"," replaced by 'svg'."]})]})]})}),(0,r.jsxs)(A.m,{children:[(0,r.jsx)(c.z,{variant:"ghost",mr:3,onClick:D,children:"Cancel"}),(0,r.jsx)(c.z,{colorScheme:"blue",onClick:Y,isLoading:a,children:"Save"})]})]})]})]})})};var q=!0;t.default=W}},function(e){e.O(0,[4424,8917,5789,6525,2123,8898,2445,1541,8278,4540,2812,5417,9410,6659,8257,9316,7029,6182,9774,2888,179],function(){return e(e.s=84191)}),_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.