PageSourceSearch

https://www.excelrs.dev/_next/static/chunks/9773-ba0f882b1a652ac2.js

js excelrs.dev collected 2026-10-02 01:54:08 UTC 18,688 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9773],{69773:function(e,t,a){a.r(t);var l=a(57437),i=a(58357),r=a(2265),n=a(92682),c=a(7222),s=a(14063),o=a(81173),d=a.n(o),f=a(97501),m=a(39315),g=a.n(m),u=a(72924),x=a(80106);let h={control:e=>({...e,width:"100%",minWidth:"220px",maxWidth:"100%",backgroundColor:"#fff",borderColor:"#d1d5db",boxShadow:"none",fontSize:"1rem",color:"#1f2937"}),menu:e=>({...e,width:"100%",minWidth:"220px",maxWidth:"100%",zIndex:20}),option:(e,t)=>({...e,color:t.isSelected?"#2563eb":"#1f2937",backgroundColor:t.isFocused?"#f3f4f6":"#fff",fontWeight:t.isSelected?600:400,fontSize:"1rem"}),singleValue:e=>({...e,color:"#1f2937"})};t.default=()=>{let[e,t]=(0,r.useState)(!1),[a,o]=(0,r.useState)(""),[m,p]=(0,r.useState)(""),[b,v]=(0,r.useState)(!1),[N,w]=(0,r.useState)(""),[y,j]=(0,r.useState)(""),[C,S]=(0,r.useState)([]),[D,_]=(0,r.useState)(!1),[P,E]=(0,r.useState)(!1),[A,L]=(0,r.useState)(!1),[T,k]=(0,r.useState)(!1),[F,I]=(0,r.useState)(!1),[O,R]=(0,r.useState)(null),[U,Z]=(0,r.useState)(null),[z,G]=(0,r.useState)(""),[W,H]=(0,r.useState)([]),[M,Y]=(0,r.useState)(""),B=(0,r.useRef)({}),J=e=>{G(e),setTimeout(()=>G(""),3e3)};(0,r.useEffect)(()=>{let e=C.map(e=>e.certificate._id);Object.keys(B.current).forEach(t=>{e.includes(t)||delete B.current[t]})},[C]),(0,r.useEffect)(()=>{(async()=>{try{let e=await fetch("".concat(i.CT,"/trainings")),t=await e.json(),a=Array.isArray(t)?t:Array.isArray(null==t?void 0:t.data)?t.data:Array.isArray(null==t?void 0:t.trainings)?t.trainings:[];H(a)}catch(e){H([])}finally{_(!1)}})()},[]);let X=async e=>{try{let t=await fetch("".concat(i.CT,"/trainings/").concat(encodeURIComponent(e)));if(t.ok)return await t.json()}catch(e){}return null},$=(e,t)=>e.map(e=>({...e,trainingDetail:t||e.trainingDetail})),V=async e=>{if(!e){J("Please select a training");return}_(!0);try{var t;let a=i.CT,l=await fetch("".concat(a,"/certificates/training/").concat(encodeURIComponent(e)),{method:"GET",headers:{"Content-Type":"application/json"}});if(!l.ok)throw Error("Failed to fetch certificates");let r=await l.json(),n=await X(e),c=$(r.certificates,n);S(c),Z(n||(null===(t=c[0])||void 0===t?void 0:t.trainingDetail)||null),J("Found ".concat(r.count," certificates"))}catch(e){J("Failed to fetch certificates"),S([])}finally{_(!1)}},q=async e=>{let t=B.current[e.certificate._id];if(!t)throw Error("Certificate element not found");return d()(t,{scale:2,backgroundColor:"#ffffff",useCORS:!0})},K=async e=>{let t=(await q(e)).toDataURL("image/png"),a=new f.ZP("landscape","mm","a4"),l=a.internal.pageSize.getWidth(),i=a.internal.pageSize.getHeight();return a.addImage(t,"PNG",0,0,l,i),a.output("blob")},Q=async e=>{let t=await q(e),a=await new Promise(e=>{t.toBlob(t=>e(t),"image/png")});if(!a)throw Error("Failed to create PNG");return a},ee=function(e,t){var a;let l=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=(e.fullName||"Unknown").replace(/[^a-zA-Z0-9\s]/g,"").replace(/\s+/g,"_"),r=(null==U?void 0:null===(a=U.title)||void 0===a?void 0:a.replace(/[^a-zA-Z0-9\s]/g,"").replace(/\s+/g,"_"))||"Certificate",n=l?"_".concat(String(e.certificate._id||"").slice(0,8)):"";return"".concat(i,"_").concat(r).concat(n,".").concat(t)},et=async e=>{R(e.certificate._id);try{let t=await K(e),a=URL.createObjectURL(t),l=document.createElement("a");l.href=a,l.download="".concat(e.fullName,"_").concat((null==U?void 0:U.title)||"Certificate",".pdf"),document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(a),J("Certificate downloaded for ".concat(e.fullName))}catch(t){console.error("Error downloading certificate:",t),J("Failed to download certificate for ".concat(e.fullName))}finally{R(null)}},ea=async()=>{if(0===C.length){J("No certificates to download");return}E(!0);try{for(let e=0;e<C.length;e++){let t=C[e];J("Downloading certificate ".concat(e+1," of ").concat(C.length,"..."));try{let e=await K(t),a=URL.createObjectURL(e),l=document.createElement("a");l.href=a,l.download="".concat(t.fullName,"_").concat((null==U?void 0:U.title)||"Certificate",".pdf"),document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(a),await new Promise(e=>setTimeout(e,1e3))}catch(e){console.error("Error downloading certificate for ".concat(t.fullName,":"),e),J("Failed to download certificate for ".concat(t.fullName))}}J("All certificates downloaded successfully!")}catch(e){console.error("Error downloading certificates:",e),J("Failed to download certificates")}finally{E(!1)}},el=async()=>
1{if(0===C.length){J("No certificates to download");return}I(!0);try{var e;J("Creating combined PDF with all certificates...");let t=new f.ZP("landscape","mm","a4"),a=t.internal.pageSize.getWidth(),l=t.internal.pageSize.getHeight();for(let e=0;e<C.length;e++){let i=C[e];J("Processing certificate ".concat(e+1," of ").concat(C.length,"..."));try{let r=B.current[i.certificate._id];if(!r)throw Error("Certificate element not found");let n=(await d()(r,{scale:2,backgroundColor:"#ffffff",useCORS:!0})).toDataURL("image/png");e>0&&t.addPage(),t.addImage(n,"PNG",0,0,a,l)}catch(e){console.error("Error generating certificate for ".concat(i.fullName,":"),e),J("Failed to generate certificate for ".concat(i.fullName))}}let i=(null==U?void 0:null===(e=U.title)||void 0===e?void 0:e.replace(/[^a-zA-Z0-9\s]/g,"").replace(/\s+/g,"_"))||"Training";t.save("".concat(i,"_All_Certificates_").concat(new Date().toISOString().split("T")[0],".pdf")),J("Combined PDF downloaded successfully!")}catch(e){console.error("Error creating combined PDF:",e),J("Failed to create combined PDF")}finally{I(!1)}},ei=async()=>{if(0===C.length){J("No certificates to download");return}k(!0);let e=new(g());try{var t;J("Creating PNG ZIP with all certificates...");for(let t=0;t<C.length;t++){let a=C[t];J("Processing PNG ".concat(t+1," of ").concat(C.length,"..."));try{let t=await Q(a);e.file(ee(a,"png",!0),t)}catch(e){console.error("Error generating PNG for ".concat(a.fullName,":"),e),J("Failed to generate PNG for ".concat(a.fullName))}}J("Compressing PNG files...");let a=await e.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:6}}),l=(null==U?void 0:null===(t=U.title)||void 0===t?void 0:t.replace(/[^a-zA-Z0-9\s]/g,"").replace(/\s+/g,"_"))||"Training",i="".concat(l,"_All_Certificates_").concat(new Date().toISOString().split("T")[0],"_png.zip"),r=URL.createObjectURL(a),n=document.createElement("a");n.href=r,n.download=i,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r),J("PNG ZIP downloaded successfully!")}catch(e){console.error("Error creating PNG ZIP file:",e),J("Failed to create PNG ZIP file")}finally{k(!1)}},er=async()=>{if(0===C.length){J("No certificates to download");return}L(!0);let e=new(g());try{var t,a;J("Creating ZIP file with all certificates...");for(let t=0;t<C.length;t++){let l=C[t];J("Processing certificate ".concat(t+1," of ").concat(C.length,"..."));try{let t=await K(l),i=l.fullName.replace(/[^a-zA-Z0-9\s]/g,"").replace(/\s+/g,"_"),r=(null==U?void 0:null===(a=U.title)||void 0===a?void 0:a.replace(/[^a-zA-Z0-9\s]/g,"").replace(/\s+/g,"_"))||"Certificate",n="".concat(i,"_").concat(r,".pdf");e.file(n,t)}catch(e){console.error("Error generating certificate for ".concat(l.fullName,":"),e),J("Failed to generate certificate for ".concat(l.fullName))}}J("Compressing files...");let l=await e.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:6}}),i=(null==U?void 0:null===(t=U.title)||void 0===t?void 0:t.replace(/[^a-zA-Z0-9\s]/g,"").replace(/\s+/g,"_"))||"Training",r="".concat(i,"_All_Certificates_").concat(new Date().toISOString().split("T")[0],".zip"),n=URL.createObjectURL(l),c=document.createElement("a");c.href=n,c.download=r,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(n),J("ZIP file downloaded successfully!")}catch(e){console.error("Error creating ZIP file:",e),J("Failed to create ZIP file")}finally{L(!1)}},en=D?(0,l.jsx)(x.Z,{}):null;return(0,l.jsxs)("div",{className:"min-h-screen bg-gradient-to-br p-0",children:[en,(0,l.jsxs)("div",{className:"w-full",children:[z&&(0,l.jsx)("div",{className:"fixed top-4 right-4 bg-blue-600 text-white px-6 py-3 rounded-lg shadow-lg z-50",children:z}),(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"bg-white rounded-lg shadow-lg p-4 mb-6 w-full",children:[(0,l.jsx)("div",{className:"flex items-center gap-3 mb-4",children:(0,l.jsxs)("h1",{className:"text-3xl font-bold text-gray-800 flex items-center gap-3",children:[(0,l.jsx)(c.NOg,{className:"text-blue-600"}),"Certificate Management"]})}),(0,l.jsx)("div",{className:"mb-4 w-full items-start",children:(0,l.jsx)(n.ZP,{options:W.map(e=>({value:e._id,label:"".concat(e.title," (").concat(e._id,")")})),value:W.map(e=>({value:e._id,label:"".concat(e.title," (").concat(e._id,")")})).find(e=>e.value===y)||null,onChange:e=>{j(e?e.value:""),e&&V(e.value)},isClearable:!0,placeholder:"Select training...",classNamePrefix:"react-select",styles:h})})]}),U&&(0,l.jsx)("div",{className:"bg-white rounded-lg shadow-lg p-6 mb-6 w-full",children:(0,l.jsxs)("div",{className:"flex items-start gap-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("h2",{className:"text-2xl font-semibold text-gray-800 mb
1-2",children:U.title}),(0,l.jsxs)("p",{className:"text-gray-600 mb-2",children:["Trainer: ",U.trainer_name]}),(0,l.jsxs)("p",{className:"text-gray-600 mb-2",children:["Date: ",new Date(U.date).toLocaleDateString()]}),(0,l.jsxs)("p",{className:"text-gray-600 flex items-center gap-2",children:[(0,l.jsx)(c.WY8,{}),C.length," Certificate(s) Found"]})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-3 w-full items-end",children:[(0,l.jsxs)("button",{onClick:ea,disabled:P||A||T||F||0===C.length,className:"px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 disabled:opacity-50 flex items-center gap-2 font-medium",children:[(0,l.jsx)(c._hL,{}),P?"Downloading All...":"Download All (Individual)"]}),(0,l.jsxs)("button",{onClick:el,disabled:P||A||T||F||0===C.length,className:"px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 flex items-center gap-2 font-medium",children:[(0,l.jsx)(c.NOg,{}),F?"Creating PDF...":"Download Single PDF (All)"]}),(0,l.jsxs)("button",{onClick:er,disabled:P||A||T||F||0===C.length,className:"px-6 py-3 bg-purple-600 text-white rounded-lg hover:bg-purple-700 disabled:opacity-50 flex items-center gap-2 font-medium",children:[(0,l.jsx)(c.JYw,{}),A?"Creating ZIP...":"Download PDF ZIP"]}),(0,l.jsxs)("button",{onClick:ei,disabled:P||A||T||F||0===C.length,className:"px-6 py-3 bg-orange-600 text-white rounded-lg hover:bg-orange-700 disabled:opacity-50 flex items-center gap-2 font-medium",children:[(0,l.jsx)(c.JYw,{}),T?"Creating PNG ZIP...":"Download PNG ZIP"]})]})]})}),C.length>0?(0,l.jsxs)("div",{className:"bg-white rounded-lg shadow-lg overflow-hidden w-full",children:[(0,l.jsx)("div",{className:"px-6 py-4 border-b border-gray-200",children:(0,l.jsx)("h3",{className:"text-lg font-semibold text-gray-800",children:"Certificates"})}),(0,l.jsx)("div",{className:"divide-y divide-gray-200",children:C.map((e,t)=>(0,l.jsx)("div",{className:"p-6 hover:bg-gray-50",children:(0,l.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,l.jsxs)("div",{className:"flex items-center gap-4",children:[e.photoUrl?(0,l.jsx)("img",{src:e.photoUrl,alt:e.fullName,className:"w-12 h-12 rounded-full object-cover"}):(0,l.jsx)("div",{className:"w-12 h-12 rounded-full bg-gray-200 flex items-center justify-center text-gray-500",children:(0,l.jsx)(s.Xws,{className:"w-7 h-7"})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("h4",{className:"text-lg font-medium text-gray-800",children:e.fullName||"No Name"}),(0,l.jsxs)("p",{className:"text-sm text-gray-600",children:["Created: ",e.createdAt?new Date(e.createdAt).toLocaleDateString():"N/A"]}),e.certificate.email&&(0,l.jsxs)("p",{className:"text-sm text-gray-600",children:["Email: ",e.certificate.email]}),!e.trainingDetail&&(0,l.jsx)("p",{className:"text-sm text-red-600",children:"Training details missing"})]})]}),(0,l.jsxs)("button",{onClick:()=>et(e),disabled:O===e.certificate._id,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 flex items-center gap-2 ",children:[(0,l.jsx)(c._hL,{}),O===e.certificate._id?"Downloading...":"Download"]})]})},e.certificate._id))})]}):(0,l.jsxs)("div",{className:"bg-white rounded-lg shadow-lg p-8 text-gray-500 w-full text-center",children:[(0,l.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"No certificates found"}),(0,l.jsx)("p",{children:"Please select a training or try a different one."})]}),(0,l.jsx)("div",{className:"absolute -left-[9999px] -top-[9999px]",children:C.length>0&&C.map(e=>{var t;return(null==e?void 0:e.fullName)&&(null==e?void 0:null===(t=e.certificate)||void 0===t?void 0:t._id)?(0,l.jsx)("div",{ref:t=>{t&&e.certificate._id&&(B.current[e.certificate._id]=t)},className:"w-[1056px] h-[816px] absolute top-0 left-0",style:{pointerEvents:"none"},children:e.trainingDetail?(0,l.jsx)(u.Z,{fullName:e.fullName,trainingDetail:e.trainingDetail,photoUrl:e.photoUrl||void 0,certificateUrl:"https://www.excelrs.dev/certificate?id=".concat(e.certificate._id),startDate:e.trainingDetail.date,days:e.trainingDetail.days,registrationNumber:e.registrationNumber||e.certificate.registrationNumber}):(0,l.jsxs)("div",{className:"flex flex-col items-center justify-center w-full h-full bg-gray-100 text-gray-500",children:[(0,l.jsx)("div",{className:"text-xl font-bold",children:"Training details missing"}),(0,l.jsx)("div",{children:e.fullName})]})},"hidden-".concat(e.certificate._id)):null})})]})]})]})}},72924:function(e,t,a){a.d(t,{Z:function(){return d}});
1var l=a(57437),i=a(2265),r=a(47586);let n=e=>{if(e)return"object"==typeof e&&e.$date?e.$date:e},c=e=>e.toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),s=(e,t)=>(function(e,t){var a;if(!e&&!(null==t?void 0:t.startOverride))return{start:"N/A",end:"N/A"};let l=n(null==e?void 0:e.trainingEnd);if(l){let a=(null==t?void 0:t.startOverride)||n(null==e?void 0:e.trainingStart)||n(null==e?void 0:e.startDate)||n(null==e?void 0:e.createdAt)||(null==e?void 0:e.date)||"";if(a){let e=new Date(a),t=new Date(l);if(!Number.isNaN(e.getTime())&&!Number.isNaN(t.getTime()))return{start:c(e),end:c(t)}}}let i=(null==t?void 0:t.startOverride)||n(null==e?void 0:e.trainingStart)||n(null==e?void 0:e.startDate)||n(null==e?void 0:e.createdAt)||(null==e?void 0:e.date)||"";if(!i)return{start:"N/A",end:"N/A"};let r=new Date(i);if(Number.isNaN(r.getTime()))return{start:i,end:i};let s=null==e?void 0:e.months,o=null!==(a=null==t?void 0:t.daysOverride)&&void 0!==a?a:null==e?void 0:e.days;if("number"==typeof s&&s>0){let e=new Date(r);return e.setMonth(e.getMonth()+s),e.setDate(e.getDate()-1),{start:c(r),end:c(e)}}if("number"==typeof o&&o>0){let e=new Date(r);return e.setDate(e.getDate()+o-1),{start:c(r),end:c(e)}}let d=c(r);return{start:d,end:d}})(e,t),o=(0,i.forwardRef)((e,t)=>{var a;let{fullName:i,trainingDetail:n,certificateUrl:c,startDate:o,days:d,formattedStart:f,formattedEnd:m,registrationNumber:g}=e,u=f,x=m;if(!u||!x){let e=s(n,{startOverride:o,daysOverride:d});u=u||e.start,x=x||e.end}let h=(null==n?void 0:n.title)||"N/A",p=(null==n?void 0:null===(a=n.certificateProgramLabel)||void 0===a?void 0:a.trim())||"program";return(0,l.jsxs)("div",{ref:t,className:"relative overflow-hidden flex flex-row w-full h-full",children:[(0,l.jsxs)("div",{className:"flex-1 basis-[70%] p-10 flex flex-col justify-between relative z-10 bg-transparent",children:[(0,l.jsxs)("div",{className:"mb-auto px-0",children:[(0,l.jsx)("div",{className:"mb-0 flex flex-col items-start",children:(0,l.jsx)("img",{src:"/excelrs-logo.png",alt:"EXCELRS Logo",className:"h-28 object-contain"})}),(0,l.jsx)("h1",{className:"text-center text-[3.8rem] font-extrabold uppercase font-serif text-[#3c295a] tracking-wide",style:{marginTop:"-30px",marginBottom:"35px"},children:"CERTIFICATE"}),(0,l.jsx)("div",{className:"absolute left-0 right-0 bg-orange-400 pb-6 mb-4 flex justify-center items-center",style:{top:"calc(100px + 8.5rem)",zIndex:1},children:(0,l.jsx)("span",{className:"text-white text-3xl font-semibold tracking-widest",children:"OF COMPLETION"})}),(0,l.jsx)("div",{style:{height:"56px"}}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-center text-2xl font-semibold tracking-wide text-gray-800 mb-2",children:"THIS IS TO CERTIFY THAT"}),(0,l.jsx)("h2",{className:"text-center text-5xl font-bold text-orange-500 mb-1 mt-2",children:i}),(0,l.jsx)("div",{className:"border-t border-gray-600 w-full mx-auto mb-3 mt-8"}),(0,l.jsxs)("p",{className:"text-center text-md text-gray-700 mb-2",children:["has successfully completed the"," ",(0,l.jsxs)("span",{className:"font-semibold text-[#1a2236]",children:['"',h,'"']})," ",p,(0,l.jsx)("br",{}),"from"," ",(0,l.jsx)("span",{className:"font-semibold text-[#1a2236]",children:u})," ","to"," ",(0,l.jsx)("span",{className:"font-semibold text-[#1a2236]",children:x}),"."]}),(null==n?void 0:n.description)&&(0,l.jsx)("p",{className:"text-center text-md text-gray-500 mt-2",children:n.description}),(0,l.jsx)("div",{className:"text-center mt-3 text-sm text-gray-700",children:(null==n?void 0:n.formName)&&(0,l.jsxs)("div",{children:["Form: ",n.formName]})}),g&&(0,l.jsxs)("p",{className:"text-center text-base font-semibold text-gray-700 mt-5 tracking-wide",children:["Reg. Number: ",g]})]})]}),(0,l.jsxs)("div",{className:"flex justify-between items-end mt-16",children:[(0,l.jsx)("div",{className:"flex flex-col items-center text-base text-gray-600",children:(0,l.jsx)("img",{src:"/lawazia_stamp.png",alt:"Stamp",className:"w-28 h-28 object-contain mb-1"})}),(0,l.jsx)("div",{className:"flex flex-col items-center text-center pl-7",children:(0,l.jsx)("img",{src:"/sjaiswal.png",alt:"Signature",className:"w-[80%] h-[80%
1] object-contain mb-1"})}),(0,l.jsxs)("div",{className:"flex flex-col items-center pr-5",children:[(0,l.jsx)(r.t,{value:c,size:80,level:"L"}),(0,l.jsx)("p",{className:"text-base text-gray-600 mt-2",children:"Scan to verify certificate"})]})]})]}),(0,l.jsx)("div",{className:"basis-[30%] flex items-stretch",children:(0,l.jsx)("img",{src:"/certificate_sidebar_1.png",alt:"Certificate Sidebar",className:"w-full h-full object-cover",style:{minWidth:0}})})]})});o.displayName="CertificateContent";var d=o},80106:function(e,t,a){var l=a(57437);a(2265),t.Z=()=>(0,l.jsx)("div",{className:"min-h-screen flex items-center justify-center",children:(0,l.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-teal-600"})})}}]);

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.