@tantainnovative/ndpr-toolkit
Version:
Nigeria Data Protection Toolkit — enterprise-grade compliance components for the Nigeria Data Protection Act (NDPA) 2023
2 lines • 7.27 kB
JavaScript
"use client";
import {d,c as c$1}from'./chunk-LWIKDDSU.mjs';export{c as assessComplianceGaps,d as generateLawfulBasisSummary}from'./chunk-LWIKDDSU.mjs';import {a}from'./chunk-SFGW37LE.mjs';import {c}from'./chunk-PHA3YMFO.mjs';import'./chunk-5LJ652AH.mjs';import'./chunk-ZJYULEER.mjs';import {useMemo}from'react';import {jsxs,jsx}from'react/jsx-runtime';var I={consent:"Consent",contract:"Contract",legal_obligation:"Legal Obligation",vital_interests:"Vital Interests",public_interest:"Public Interest",legitimate_interests:"Legitimate Interests"},$={consent:"ndpr-badge ndpr-badge--info",contract:"ndpr-badge ndpr-badge--info",legal_obligation:"ndpr-badge ndpr-badge--info",vital_interests:"ndpr-badge ndpr-badge--destructive",public_interest:"ndpr-badge ndpr-badge--warning",legitimate_interests:"bg-indigo-100 text-indigo-800 dark:bg-indigo-900 dark:text-indigo-200"},H={active:"Active",inactive:"Inactive",under_review:"Under Review",archived:"Archived"},U={active:"ndpr-badge ndpr-badge--success",inactive:"ndpr-badge ndpr-badge--neutral",under_review:"ndpr-badge ndpr-badge--warning",archived:"ndpr-badge ndpr-badge--destructive"},K=p=>new Date(p).toLocaleDateString(),M=({activities:p,title:g,description:c$2,className:B="",classNames:e,unstyled:i,showSummary:A=true,showComplianceGaps:S=true,onActivityClick:u})=>{var h,L;let w=c(),k=(h=g!=null?g:w.lawfulBasis.title)!=null?h:"Lawful Basis Tracker",C=(L=c$2!=null?c$2:w.lawfulBasis.description)!=null?L:"Document and track the lawful basis for each processing activity as required by NDPA 2023 Section 25.",_=useMemo(()=>[...p].sort((r,d)=>d.updatedAt-r.updatedAt),[p]),l=useMemo(()=>d(p),[p]),o=useMemo(()=>c$1(p),[p]),m=useMemo(()=>o.filter(r=>r.severity==="high"),[o]),b=useMemo(()=>o.filter(r=>r.severity==="medium"),[o]),P=r=>jsx("span",{className:a(`px-2 py-1 rounded text-xs font-medium ${U[r]}`,e==null?void 0:e.statusBadge,i),children:H[r]}),T=r=>jsx("span",{className:`px-2 py-1 rounded text-xs font-medium ${$[r]}`,children:I[r]}),D=r=>r.dpoApproval?r.dpoApproval.approved?jsx("span",{className:"ndpr-badge ndpr-badge--success",children:"Approved"}):jsx("span",{className:"ndpr-badge ndpr-badge--warning",children:"Pending Approval"}):jsx("span",{className:"px-2 py-1 rounded text-xs font-medium bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400",children:"No DPO Review"}),R=()=>jsxs("div",{"data-ndpr-component":"lawful-basis-tracker-lite",className:a("grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",e==null?void 0:e.summary,i),role:"status","aria-label":"Compliance summary",children:[jsxs("div",{className:a("ndpr-alert ndpr-alert--info",e==null?void 0:e.summaryCard,i),children:[jsx("p",{className:"ndpr-stat__value ndpr-text-info",children:l.totalActivities}),jsx("p",{className:"text-sm ndpr-text-info",children:"Total Activities"})]}),jsxs("div",{className:a("bg-orange-50 dark:bg-orange-900/20 p-4 rounded-lg",e==null?void 0:e.summaryCard,i),children:[jsx("p",{className:"ndpr-stat__value ndpr-text-warning",children:l.sensitiveDataActivities}),jsx("p",{className:"text-sm ndpr-text-warning",children:"Sensitive Data"})]}),jsxs("div",{className:a("ndpr-alert ndpr-alert--info",e==null?void 0:e.summaryCard,i),children:[jsx("p",{className:"ndpr-stat__value ndpr-text-info",children:l.crossBorderActivities}),jsx("p",{className:"text-sm ndpr-text-info",children:"Cross-Border Transfers"})]}),jsxs("div",{className:a("ndpr-alert ndpr-alert--destructive",e==null?void 0:e.summaryCard,i),children:[jsx("p",{className:"ndpr-stat__value ndpr-text-destructive",children:l.activitiesWithoutApproval.length}),jsx("p",{className:"text-sm ndpr-text-destructive",children:"Pending Approval"})]})]}),G=()=>o.length===0?jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 p-4 rounded-lg mb-6",role:"status","aria-label":"No compliance gaps",children:[jsx("p",{className:"text-sm ndpr-text-success font-medium",children:"No compliance gaps detected."}),jsx("p",{className:"text-xs ndpr-text-success mt-1",children:"All processing activities appear to be properly documented."})]}):jsxs("div",{className:"mb-6",role:"status","aria-label":`${o.length} compliance gaps detected`,children:[m.length>0&&jsxs("div",{className:a("bg-red-50 dark:bg-red-900/20 p-4 rounded-lg mb-3",e==null?void 0:e.gapAlert,i),children:[jsxs("p",{className:"text-sm ndpr-text-destructive font-medium mb-2",children:["High Priority (",m.length,")"]}),jsx("ul",{className:"space-y-1",children:m.map((r,d)=>jsx("li",{className:"text-xs ndpr-text-destructive",children:r.description},d))})]}),b.length>0&&jsxs("div",{className:a("ndpr-alert ndpr-alert--warning",e==null?void 0:e.gapAlert,i),children:[jsxs("p",{className:"text-sm ndpr-text-warning font-medium mb-2",children:["Medium Priority (",b.length,")"]}),jsx("ul",{className:"space-y-1",children:b.map((r,d)=>jsx("li",{className:"text-xs ndpr-text-warning",children:r.description},d))})]})]});return jsxs("div",{className:a(`bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md ${B}`,e==null?void 0:e.root,i),children:[jsxs("div",{className:a("",e==null?void 0:e.header,i),children:[jsx("h2",{className:a("ndpr-section-heading",e==null?void 0:e.title,i),children:k}),jsx("p",{className:"ndpr-card__subtitle",children:C})]}),A&&R(),S&&G(),_.length===0?jsx("div",{className:"flex items-center justify-center h-32 bg-gray-50 dark:bg-gray-700 rounded-md",children:jsx("p",{className:"ndpr-card__subtitle",children:"No processing activities found."})}):jsx("div",{className:"overflow-x-auto",children:jsxs("table",{className:a("w-full text-sm text-left",e==null?void 0:e.table,i),children:[jsx("thead",{className:a("ndpr-table__head",e==null?void 0:e.tableHeader,i),children:jsxs("tr",{children:[jsx("th",{className:"ndpr-table__cell",children:"Activity"}),jsx("th",{className:"ndpr-table__cell",children:"Lawful Basis"}),jsx("th",{className:"ndpr-table__cell",children:"Status"}),jsx("th",{className:"ndpr-table__cell",children:"DPO Approval"}),jsx("th",{className:"ndpr-table__cell",children:"Sensitive Data"}),jsx("th",{className:"ndpr-table__cell",children:"Last Updated"})]})}),jsx("tbody",{children:_.map(r=>{let d=typeof u=="function",E=d?f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),u(r));}:void 0;return jsxs("tr",{className:a(`border-b border-gray-200 dark:border-gray-600${d?" hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer":""}`,e==null?void 0:e.tableRow,i),onClick:d?()=>u(r):void 0,onKeyDown:E,role:d?"button":void 0,tabIndex:d?0:void 0,"aria-label":d?`View ${r.name}`:void 0,children:[jsxs("td",{className:"ndpr-table__cell",children:[jsx("span",{className:"font-medium ndpr-text-primary",children:r.name}),jsx("p",{className:"text-xs ndpr-text-muted mt-1 truncate max-w-xs",children:r.description})]}),jsx("td",{className:"ndpr-table__cell",children:T(r.lawfulBasis)}),jsx("td",{className:"ndpr-table__cell",children:P(r.status)}),jsx("td",{className:"ndpr-table__cell",children:D(r)}),jsx("td",{className:"ndpr-table__cell",children:jsx("span",{className:`text-xs ${r.involvesSensitiveData?"ndpr-text-warning font-medium":"ndpr-card__subtitle"}`,children:r.involvesSensitiveData?"Yes":"No"})}),jsx("td",{className:"ndpr-table__cell ndpr-table__cell--muted",children:K(r.updatedAt)})]},r.id)})})]})})]})};export{M as LawfulBasisTrackerLite};