@tantainnovative/ndpr-toolkit
Version:
Nigeria Data Protection Toolkit — enterprise-grade compliance components for the Nigeria Data Protection Act (NDPA) 2023
6 lines • 10.9 kB
JavaScript
import {a}from'./chunk-ITCY2Z66.mjs';import {a as a$1}from'./chunk-SFGW37LE.mjs';import {c}from'./chunk-PHA3YMFO.mjs';import T,{useMemo}from'react';import {jsxs,jsx}from'react/jsx-runtime';var G=({result:s,sections:c$1,showFullReport:g=true,allowPrint:v=true,allowExport:f=true,onExport:b,className:w="",buttonClassName:x="",classNames:h={},unstyled:k=false})=>{var I;let N=(I=c().dpia.reportTitle)!=null?I:"Data Protection Impact Assessment Report",m=useMemo(()=>new Date().toLocaleDateString(),[]),r=(a,n)=>{let i=n?h[n]:void 0;return !i&&n==="printButton"&&(i=h.primaryButton),a$1(a,i,k)},o=a=>new Date(a).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"}),R=a=>{let n=s.answers[a];return n==null?"Not answered":typeof n=="boolean"?n?"Yes":"No":Array.isArray(n)?n.join(", "):String(n)},p=()=>{window.print();},u=a=>{b&&b(a);},A=a=>jsx("span",{className:r(`px-2 py-1 rounded text-xs font-medium ${{low:"ndpr-badge ndpr-badge--success",medium:"ndpr-badge ndpr-badge--warning",high:"ndpr-badge ndpr-badge--warning",critical:"ndpr-badge ndpr-badge--destructive"}[a]}`,"riskBadge"),children:a.charAt(0).toUpperCase()+a.slice(1)});return jsxs("div",{"data-ndpr-component":"dpia-report",className:`${r("bg-white dark:bg-gray-800 rounded-lg shadow-md p-6 print:shadow-none print:p-0","root")} ${w}`,children:[jsxs("div",{className:r("mb-8 border-b border-gray-200 dark:border-gray-700 pb-6 print:pb-4","header"),children:[jsxs("div",{className:"flex justify-between items-start",children:[jsxs("div",{children:[jsx("h1",{className:r("ndpr-card__title","title"),children:N}),jsx("h2",{className:"text-xl ndpr-text-muted mb-4",children:s.title})]}),(v||f)&&jsxs("div",{className:"flex space-x-2 print:hidden",children:[v&&jsx("button",{onClick:p,className:`${r("px-3 py-1 bg-gray-200 text-gray-800 dark:bg-gray-700 dark:text-white rounded hover:bg-gray-300 dark:hover:bg-gray-600","printButton")} ${x}`,children:jsxs("span",{className:"flex items-center",children:[jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"})}),"Print"]})}),f&&jsx("div",{className:"relative inline-block",children:jsx("button",{onClick:()=>u("pdf"),className:`px-3 py-1 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] ${x}`,children:jsxs("span",{className:"flex items-center",children:[jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),"Export PDF"]})})})]})]}),jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[jsxs("div",{children:[jsxs("p",{className:"ndpr-form-field__hint",children:[jsx("span",{className:"font-medium",children:"Assessor:"})," ",s.assessor.name,", ",s.assessor.role]}),jsxs("p",{className:"ndpr-form-field__hint",children:[jsx("span",{className:"font-medium",children:"Contact:"})," ",s.assessor.email]})]}),jsxs("div",{children:[jsxs("p",{className:"ndpr-form-field__hint",children:[jsx("span",{className:"font-medium",children:"Started:"})," ",o(s.startedAt)]}),jsxs("p",{className:"ndpr-form-field__hint",children:[jsx("span",{className:"font-medium",children:"Completed:"})," ",s.completedAt?o(s.completedAt):"In progress"]}),jsxs("p",{className:"ndpr-form-field__hint",children:[jsx("span",{className:"font-medium",children:"Next review:"})," ",s.reviewDate?o(s.reviewDate):"Not scheduled"]})]})]})]}),jsxs("div",{className:r("mb-8","summary"),children:[jsx("h2",{className:"ndpr-section-heading",children:"Executive Summary"}),jsxs("div",{className:"ndpr-panel",children:[jsxs("div",{className:"flex items-center mb-2",role:"status","aria-live":"polite",children:[jsx("span",{className:"font-medium mr-2",children:"Overall Risk Level:"}),A(s.overallRiskLevel)]}),jsxs("div",{className:r("mb-2","conclusion"),children:[jsx("span",{className:"font-medium",children:"Conclusion:"})," ",s.conclusion]}),jsxs("div",{role:"status","aria-live":"polite",children:[jsx("span",{className:"font-medium",children:"Can Proceed:"})," ",s.canProceed?"Yes":"No"]})]}),jsxs("div",{children:[jsx("h3",{className:"font-medium ndpr-text-foreground mb-2",children:"Processing Activity Description"}),jsx("p",{className:"ndpr-text-muted mb-4",children:s.processingDescription}),s.recommendations&&s.recommendations.length>0&&jsxs("div",{children:[jsx("h3",{className:"font-medium ndpr-text-foreground mb-2",children:"Key Recommendations"}),jsx("ul",{className:"list-disc pl-5 ndpr-text-muted",children:s.recommendations.map((a,n)=>jsx("li",{className:r("","recommendation"),children:a},n))})]})]})]}),jsxs("div",{className:"mb-8",children:[jsx("h2",{className:"ndpr-section-heading",children:"Identified Risks"}),s.risks.length===0?jsx("p",{className:"ndpr-text-muted",children:"No risks identified."}):jsx("div",{className:"overflow-x-auto",children:jsxs("table",{className:r("min-w-full divide-y divide-gray-200 dark:divide-gray-700","riskTable"),children:[jsx("thead",{className:"ndpr-panel",children:jsxs("tr",{children:[jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Risk"}),jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Likelihood"}),jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Impact"}),jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Risk Level"}),jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Mitigated"})]})}),jsx("tbody",{className:"ndpr-table",children:s.risks.map(a=>jsxs("tr",{className:r("","riskRow"),children:[jsx("td",{className:"ndpr-table__cell",children:a.description}),jsxs("td",{className:"ndpr-table__cell ndpr-table__cell--muted",children:[a.likelihood," / 5"]}),jsxs("td",{className:"ndpr-table__cell ndpr-table__cell--muted",children:[a.impact," / 5"]}),jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm",children:A(a.level)}),jsx("td",{className:"ndpr-table__cell ndpr-table__cell--muted",children:a.mitigated?jsx("span",{className:"ndpr-text-success",children:"Yes"}):jsx("span",{className:"ndpr-text-destructive",children:"No"})})]},a.id))})]})})]}),g&&jsxs("div",{children:[jsx("h2",{className:"ndpr-section-heading",children:"Full Assessment Details"}),c$1.map(a=>{let n=a.questions.filter(i=>s.answers[i.id]!==void 0);return n.length===0?null:jsxs("div",{className:"mb-6",children:[jsx("h3",{className:"text-lg font-medium ndpr-text-foreground mb-2",children:a.title}),jsx("div",{className:"overflow-x-auto",children:jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[jsx("thead",{className:"ndpr-panel",children:jsxs("tr",{children:[jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Question"}),jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Answer"})]})}),jsx("tbody",{className:"ndpr-table",children:n.map(i=>jsxs("tr",{children:[jsx("td",{className:"ndpr-table__cell",children:i.text}),jsx("td",{className:"px-6 py-4 whitespace-normal text-sm ndpr-text-muted",children:R(i.id)})]},i.id))})]})})]},a.id)})]}),jsxs("div",{className:"mt-8 pt-4 border-t border-gray-200 dark:border-gray-700 text-sm ndpr-text-muted",children:[jsx("p",{children:"This DPIA was conducted in accordance with NDPA 2023 Section 28."}),jsxs("p",{children:["DPIA Report Version: ",s.version]}),jsxs("p",{children:["Generated on: ",m]}),jsx("p",{className:"mt-2 italic",role:"note",children:a})]})]})};var Y=({steps:s,onStepClick:c,clickable:g=true,orientation:v="horizontal",className:f="",activeStepClassName:b="",completedStepClassName:w="",incompleteStepClassName:x="",classNames:h={},unstyled:k=false})=>{let d=(r,o)=>a$1(r,o?h[o]:void 0,k),N=r=>{g&&c&&c(r);},m=v==="vertical";return jsx("div",{"data-ndpr-component":"dpia-step-indicator",role:"navigation","aria-label":"Step progress",className:`${d(m?"flex flex-col space-y-4":"flex items-center justify-between","root")} ${f}`,children:s.map((r,o)=>{let C=o===s.length-1,D=r.active?d(`font-medium ${b||"ndpr-text-primary"}`,"label"):r.completed?d(w||"ndpr-text-success","label"):d(x||"ndpr-card__subtitle","label"),R=r.active?d("flex items-center justify-center w-8 h-8 rounded-full bg-[rgb(var(--ndpr-primary)/0.1)] dark:bg-[rgb(var(--ndpr-primary)/0.2)] ndpr-text-primary border-2 border-[rgb(var(--ndpr-primary))] dark:border-[rgb(var(--ndpr-primary))]","stepActive"):r.completed?d("flex items-center justify-center w-8 h-8 rounded-full bg-green-100 dark:bg-green-900 ndpr-text-success border-2 border-green-600 dark:border-green-400","stepCompleted"):d("flex items-center justify-center w-8 h-8 rounded-full bg-gray-100 dark:bg-gray-700 ndpr-text-muted border-2 border-gray-300 dark:border-gray-600","stepPending"),p=g&&!!c;return jsxs(T.Fragment,{children:[jsxs("div",{className:d(`${m?"flex items-start":"flex flex-col items-center"} ${g?"cursor-pointer":""}`,"step"),role:p?"button":void 0,tabIndex:p?0:void 0,"aria-label":p?`Go to step ${o+1}: ${r.label}`:void 0,onClick:p?()=>N(r.id):void 0,onKeyDown:p?u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),N(r.id));}:void 0,"aria-current":r.active?"step":void 0,children:[jsx("div",{className:`
flex items-center justify-center
${m?"mr-4":""}
`,children:jsx("div",{className:R,children:r.icon?r.icon:r.completed?jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}):jsx("span",{children:o+1})})}),jsxs("div",{className:`
${m?"flex-1":"mt-2 text-center"}
`,children:[jsx("div",{className:`text-sm font-medium ${D}`,children:r.label}),r.description&&jsx("div",{className:"ndpr-form-field__hint",children:r.description})]})]}),!C&&jsx("div",{className:d(m?"ml-4 h-8 border-l-2 border-gray-300 dark:border-gray-600":"w-full border-t-2 border-gray-300 dark:border-gray-600 hidden sm:block","connector")})]},r.id)})})};export{G as a,Y as b};