@redacto.io/consent-sdk-react 10.0.0-beta.8 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.md +17 -0
- package/README.md +141 -3
- package/dist/chunk-FEGTW73Q.mjs +182 -0
- package/dist/{chunk-6A665OPR.mjs → chunk-OGL6OC3A.mjs} +4 -0
- package/dist/fonts.d.mts +35 -0
- package/dist/fonts.d.ts +35 -0
- package/dist/fonts.js +183 -0
- package/dist/fonts.mjs +10 -0
- package/dist/index.d.mts +41 -4
- package/dist/index.d.ts +41 -4
- package/dist/index.js +881 -416
- package/dist/index.mjs +502 -253
- package/dist/montserrat.generated-NBTECYRW.mjs +22 -0
- package/dist/privacy-center.d.mts +51 -11
- package/dist/privacy-center.d.ts +51 -11
- package/dist/privacy-center.js +252 -136
- package/dist/privacy-center.mjs +251 -137
- package/dist/types-6Aj7faxL.d.mts +57 -0
- package/dist/types-6Aj7faxL.d.ts +57 -0
- package/package.json +10 -1
- package/.turbo/turbo-build.log +0 -22
- package/.turbo/turbo-test.log +0 -203
- package/.turbo/turbo-verify-pack.log +0 -6
- package/CHANGELOG.md +0 -343
- package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.test.tsx +0 -934
- package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.tsx +0 -2160
- package/src/RedactoNoticeAssisted/api/index.ts +0 -275
- package/src/RedactoNoticeAssisted/api/types.ts +0 -182
- package/src/RedactoNoticeAssisted/assets/redacto-logo.png +0 -0
- package/src/RedactoNoticeAssisted/constants.ts +0 -51
- package/src/RedactoNoticeAssisted/i18n.ts +0 -1408
- package/src/RedactoNoticeAssisted/index.ts +0 -1
- package/src/RedactoNoticeAssisted/injectStyles.ts +0 -251
- package/src/RedactoNoticeAssisted/styles.ts +0 -730
- package/src/RedactoNoticeAssisted/types.ts +0 -26
- package/src/RedactoNoticeAssisted/useMediaQuery.ts +0 -36
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.test.tsx +0 -1152
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +0 -4258
- package/src/RedactoNoticeConsent/api/index.ts +0 -512
- package/src/RedactoNoticeConsent/api/types.ts +0 -469
- package/src/RedactoNoticeConsent/assets/redacto-logo.png +0 -0
- package/src/RedactoNoticeConsent/components/DigiLockerCallback.tsx +0 -602
- package/src/RedactoNoticeConsent/components/index.ts +0 -7
- package/src/RedactoNoticeConsent/constants.ts +0 -20
- package/src/RedactoNoticeConsent/index.ts +0 -1
- package/src/RedactoNoticeConsent/injectStyles.ts +0 -151
- package/src/RedactoNoticeConsent/language-codes.ts +0 -95
- package/src/RedactoNoticeConsent/services/storage.ts +0 -122
- package/src/RedactoNoticeConsent/styles.ts +0 -409
- package/src/RedactoNoticeConsent/types.ts +0 -54
- package/src/RedactoNoticeConsent/useMediaQuery.ts +0 -36
- package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.test.tsx +0 -369
- package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx +0 -687
- package/src/RedactoNoticeConsentInline/api/index.ts +0 -106
- package/src/RedactoNoticeConsentInline/api/types.ts +0 -183
- package/src/RedactoNoticeConsentInline/assets/redacto-logo.png +0 -0
- package/src/RedactoNoticeConsentInline/index.ts +0 -1
- package/src/RedactoNoticeConsentInline/injectStyles.ts +0 -40
- package/src/RedactoNoticeConsentInline/styles.ts +0 -397
- package/src/RedactoNoticeConsentInline/types.ts +0 -51
- package/src/RedactoNoticeConsentInline/useMediaQuery.ts +0 -36
- package/src/RedactoPrivacyCenter/NotificationsPage.tsx +0 -182
- package/src/RedactoPrivacyCenter/PrivacyCenterActivityPage.tsx +0 -19
- package/src/RedactoPrivacyCenter/PrivacyCenterCaseDetailsPage.tsx +0 -156
- package/src/RedactoPrivacyCenter/PrivacyCenterConsentManagerPage.tsx +0 -17
- package/src/RedactoPrivacyCenter/PrivacyCenterFormPage.tsx +0 -79
- package/src/RedactoPrivacyCenter/PrivacyCenterHomePage.tsx +0 -36
- package/src/RedactoPrivacyCenter/PrivacyCenterLayout.tsx +0 -177
- package/src/RedactoPrivacyCenter/PrivacyCenterMyReceiptPage.tsx +0 -26
- package/src/RedactoPrivacyCenter/RedactoPrivacyCenter.tsx +0 -58
- package/src/RedactoPrivacyCenter/api/actions.ts +0 -695
- package/src/RedactoPrivacyCenter/api/client.ts +0 -911
- package/src/RedactoPrivacyCenter/api/config.ts +0 -33
- package/src/RedactoPrivacyCenter/api/fetcher.ts +0 -260
- package/src/RedactoPrivacyCenter/api/orgBranding.ts +0 -16
- package/src/RedactoPrivacyCenter/api/upload.ts +0 -93
- package/src/RedactoPrivacyCenter/assets/character.svg +0 -31
- package/src/RedactoPrivacyCenter/assets/fileAttach.svg +0 -9
- package/src/RedactoPrivacyCenter/assets/greenTick.svg +0 -4
- package/src/RedactoPrivacyCenter/assets/mail.svg +0 -3
- package/src/RedactoPrivacyCenter/assets/poweredByRedacto.svg +0 -9
- package/src/RedactoPrivacyCenter/assets/sentImg.svg +0 -9
- package/src/RedactoPrivacyCenter/assets/uploadFileIcon.svg +0 -9
- package/src/RedactoPrivacyCenter/components/ActivitiesList.tsx +0 -252
- package/src/RedactoPrivacyCenter/components/ActivityTimeline.tsx +0 -239
- package/src/RedactoPrivacyCenter/components/AppShell/AppShell.tsx +0 -268
- package/src/RedactoPrivacyCenter/components/AppShell/MobileNavDrawer.tsx +0 -218
- package/src/RedactoPrivacyCenter/components/AppShell/NavItem.tsx +0 -205
- package/src/RedactoPrivacyCenter/components/AppShell/PageHeader.tsx +0 -107
- package/src/RedactoPrivacyCenter/components/AppShell/SidebarNav.tsx +0 -100
- package/src/RedactoPrivacyCenter/components/AppShell/TopAppBar.tsx +0 -339
- package/src/RedactoPrivacyCenter/components/AppShell/UserMenu.tsx +0 -245
- package/src/RedactoPrivacyCenter/components/AppShell/hooks/useIsTruncated.ts +0 -28
- package/src/RedactoPrivacyCenter/components/AppShell/hooks/useKeyboardShortcut.ts +0 -40
- package/src/RedactoPrivacyCenter/components/AppShell/hooks/useSidebarState.ts +0 -62
- package/src/RedactoPrivacyCenter/components/AppShell/usePrivacyCenterExitAction.ts +0 -36
- package/src/RedactoPrivacyCenter/components/CaseDetails/AttachmentCard.tsx +0 -38
- package/src/RedactoPrivacyCenter/components/CaseDetails/ChatBubble.tsx +0 -31
- package/src/RedactoPrivacyCenter/components/CaseDetails/DocumentRequestCard.tsx +0 -79
- package/src/RedactoPrivacyCenter/components/CaseDetails/FinalizedTooltipWrapper.tsx +0 -25
- package/src/RedactoPrivacyCenter/components/CaseDetails/MessageComposer.tsx +0 -96
- package/src/RedactoPrivacyCenter/components/CaseDetails/MessageItem.tsx +0 -97
- package/src/RedactoPrivacyCenter/components/CaseDetails/MessagesTab.tsx +0 -156
- package/src/RedactoPrivacyCenter/components/CaseDetails/RequestDetailsTab.tsx +0 -171
- package/src/RedactoPrivacyCenter/components/CaseDetails/StatusEvent.tsx +0 -23
- package/src/RedactoPrivacyCenter/components/CaseDetails/useFileUpload.ts +0 -116
- package/src/RedactoPrivacyCenter/components/CaseDetails/useMessagePolling.ts +0 -43
- package/src/RedactoPrivacyCenter/components/CaseDetails/utils.ts +0 -71
- package/src/RedactoPrivacyCenter/components/CaseDetailsModal.tsx +0 -469
- package/src/RedactoPrivacyCenter/components/CaseHistory.tsx +0 -426
- package/src/RedactoPrivacyCenter/components/ConsentManager.tsx +0 -1206
- package/src/RedactoPrivacyCenter/components/ConsentManagerCells.tsx +0 -218
- package/src/RedactoPrivacyCenter/components/ConsentManagerColumns.tsx +0 -138
- package/src/RedactoPrivacyCenter/components/ConsentManagerConstants.ts +0 -7
- package/src/RedactoPrivacyCenter/components/ConsentManagerExpandedRow.tsx +0 -179
- package/src/RedactoPrivacyCenter/components/ConsentManagerGroupedColumns.tsx +0 -318
- package/src/RedactoPrivacyCenter/components/ConsentManagerProductCards.tsx +0 -333
- package/src/RedactoPrivacyCenter/components/ConsentManagerPurposeCards.tsx +0 -102
- package/src/RedactoPrivacyCenter/components/ConsentManagerTableSkeleton.tsx +0 -159
- package/src/RedactoPrivacyCenter/components/DataRequest/CorrectionDataSection.tsx +0 -189
- package/src/RedactoPrivacyCenter/components/DataRequest/GrievanceDataSection.tsx +0 -118
- package/src/RedactoPrivacyCenter/components/DataRequest/NominationDataSection.tsx +0 -66
- package/src/RedactoPrivacyCenter/components/DataRequest/ProductSelectionSection.tsx +0 -222
- package/src/RedactoPrivacyCenter/components/DataRequest/PurposeSelectionSection.tsx +0 -331
- package/src/RedactoPrivacyCenter/components/Form.tsx +0 -1796
- package/src/RedactoPrivacyCenter/components/GrievanceTable.tsx +0 -174
- package/src/RedactoPrivacyCenter/components/GrievanceTablePagination.tsx +0 -337
- package/src/RedactoPrivacyCenter/components/ModifyConsentModal.tsx +0 -334
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationBell.tsx +0 -173
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationCTAButton.tsx +0 -18
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdown.tsx +0 -54
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdownItem.tsx +0 -57
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationIcon.tsx +0 -19
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationListPanel.tsx +0 -92
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRefreshButton.tsx +0 -20
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRow.tsx +0 -58
- package/src/RedactoPrivacyCenter/components/NotificationHub/StatCard.tsx +0 -10
- package/src/RedactoPrivacyCenter/components/NotificationHub/useNotificationActions.ts +0 -112
- package/src/RedactoPrivacyCenter/components/NotificationHub/utils.ts +0 -27
- package/src/RedactoPrivacyCenter/components/Pagination.tsx +0 -140
- package/src/RedactoPrivacyCenter/components/PrivacyCenterEmptyState.tsx +0 -76
- package/src/RedactoPrivacyCenter/components/PrivacyCenterSessionExpired.tsx +0 -97
- package/src/RedactoPrivacyCenter/components/ReceiptsList.tsx +0 -454
- package/src/RedactoPrivacyCenter/components/RequestSubmit.tsx +0 -270
- package/src/RedactoPrivacyCenter/components/SelectUser.tsx +0 -95
- package/src/RedactoPrivacyCenter/components/SelectUserGate.tsx +0 -187
- package/src/RedactoPrivacyCenter/components/SideMenuBarPC/constants.tsx +0 -25
- package/src/RedactoPrivacyCenter/components/SideMenuBarPC/types.ts +0 -21
- package/src/RedactoPrivacyCenter/components/caseHistoryColumns.tsx +0 -159
- package/src/RedactoPrivacyCenter/components/constant.ts +0 -52
- package/src/RedactoPrivacyCenter/components/groupHelpers.ts +0 -119
- package/src/RedactoPrivacyCenter/components/receiptColumns.tsx +0 -203
- package/src/RedactoPrivacyCenter/components/types.ts +0 -123
- package/src/RedactoPrivacyCenter/components/utils.tsx +0 -10
- package/src/RedactoPrivacyCenter/config/routes.ts +0 -9
- package/src/RedactoPrivacyCenter/config/table.ts +0 -25
- package/src/RedactoPrivacyCenter/context/AuthContext.tsx +0 -160
- package/src/RedactoPrivacyCenter/context/BaseUrlContext.tsx +0 -47
- package/src/RedactoPrivacyCenter/context/BrandingContext.tsx +0 -52
- package/src/RedactoPrivacyCenter/context/DataAvailabilityContext.session-expired.test.tsx +0 -92
- package/src/RedactoPrivacyCenter/context/DataAvailabilityContext.tsx +0 -181
- package/src/RedactoPrivacyCenter/context/LocaleContext.tsx +0 -11
- package/src/RedactoPrivacyCenter/context/NavigationContext.tsx +0 -96
- package/src/RedactoPrivacyCenter/context/OrganizationContext.tsx +0 -30
- package/src/RedactoPrivacyCenter/context/PageChromeContext.tsx +0 -80
- package/src/RedactoPrivacyCenter/context/ProfileSwitchContext.tsx +0 -15
- package/src/RedactoPrivacyCenter/context/types.ts +0 -19
- package/src/RedactoPrivacyCenter/lib/api.ts +0 -759
- package/src/RedactoPrivacyCenter/lib/consent-manager/utils.tsx +0 -67
- package/src/RedactoPrivacyCenter/lib/constants.ts +0 -276
- package/src/RedactoPrivacyCenter/lib/i18n.ts +0 -81
- package/src/RedactoPrivacyCenter/lib/locales.ts +0 -102
- package/src/RedactoPrivacyCenter/lib/queries.ts +0 -141
- package/src/RedactoPrivacyCenter/lib/types.ts +0 -876
- package/src/RedactoPrivacyCenter/lib/useCurrentLanguage.ts +0 -37
- package/src/RedactoPrivacyCenter/lib/utils.refresh-circuit.test.ts +0 -127
- package/src/RedactoPrivacyCenter/lib/utils.refresh-storage.test.ts +0 -85
- package/src/RedactoPrivacyCenter/lib/utils.session-expired.test.ts +0 -109
- package/src/RedactoPrivacyCenter/lib/utils.ts +0 -783
- package/src/RedactoPrivacyCenter/locales/as/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/bn/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/brx/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/doi/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/en/translation.json +0 -357
- package/src/RedactoPrivacyCenter/locales/gom/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/gu/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/hi/translation.json +0 -345
- package/src/RedactoPrivacyCenter/locales/kn/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/ks/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/mai/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/ml/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/mni-Mtei/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/mr/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/ne/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/or/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/pa/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/sa/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/sat/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/sd/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/ta/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/te/translation.json +0 -342
- package/src/RedactoPrivacyCenter/locales/ur/translation.json +0 -342
- package/src/RedactoPrivacyCenter/styles/applyBrandingTheme.ts +0 -66
- package/src/RedactoPrivacyCenter/styles/base.css +0 -117
- package/src/RedactoPrivacyCenter/styles/injectStyles.ts +0 -3108
- package/src/RedactoPrivacyCenter/styles/pcStyles.ts +0 -831
- package/src/RedactoPrivacyCenter/styles/responsive.ts +0 -138
- package/src/RedactoPrivacyCenter/styles/variables.css +0 -96
- package/src/RedactoPrivacyCenter/table/AdvancedTable.tsx +0 -387
- package/src/RedactoPrivacyCenter/table/AdvancedTablePagination.tsx +0 -468
- package/src/RedactoPrivacyCenter/table/index.ts +0 -2
- package/src/RedactoPrivacyCenter/types/images.d.ts +0 -29
- package/src/RedactoPrivacyCenter/ui/Footer.tsx +0 -69
- package/src/RedactoPrivacyCenter/ui/FormBlockWrapper.tsx +0 -54
- package/src/RedactoPrivacyCenter/ui/PCAccordion.tsx +0 -93
- package/src/RedactoPrivacyCenter/ui/PCActionIcon.tsx +0 -47
- package/src/RedactoPrivacyCenter/ui/PCAvatar.test.tsx +0 -83
- package/src/RedactoPrivacyCenter/ui/PCAvatar.tsx +0 -93
- package/src/RedactoPrivacyCenter/ui/PCBadge.tsx +0 -48
- package/src/RedactoPrivacyCenter/ui/PCButton.tsx +0 -77
- package/src/RedactoPrivacyCenter/ui/PCCheckbox.tsx +0 -55
- package/src/RedactoPrivacyCenter/ui/PCCollapse.tsx +0 -107
- package/src/RedactoPrivacyCenter/ui/PCEmpty.tsx +0 -35
- package/src/RedactoPrivacyCenter/ui/PCInput.tsx +0 -132
- package/src/RedactoPrivacyCenter/ui/PCLoader.tsx +0 -31
- package/src/RedactoPrivacyCenter/ui/PCModal.tsx +0 -106
- package/src/RedactoPrivacyCenter/ui/PCPopover.tsx +0 -206
- package/src/RedactoPrivacyCenter/ui/PCSelect.tsx +0 -433
- package/src/RedactoPrivacyCenter/ui/PCTable.tsx +0 -149
- package/src/RedactoPrivacyCenter/ui/PCText.tsx +0 -41
- package/src/RedactoPrivacyCenter/ui/PCTextarea.tsx +0 -43
- package/src/RedactoPrivacyCenter/ui/PCTitle.tsx +0 -37
- package/src/RedactoPrivacyCenter/ui/PCTooltip.tsx +0 -121
- package/src/RedactoPrivacyCenter/ui/SimpleBar.tsx +0 -25
- package/src/RedactoPrivacyCenter/ui/StatusBadge.tsx +0 -53
- package/src/RedactoPrivacyCenter/ui/index.ts +0 -18
- package/src/RedactoPrivacyCenter/utils/cn.ts +0 -28
- package/src/RedactoPrivacyCenter/utils/date.ts +0 -48
- package/src/RedactoPrivacyCenter/utils/status.ts +0 -111
- package/src/RedactoPrivacyCenter/utils/toast.ts +0 -130
- package/src/index.ts +0 -19
- package/src/privacy-center.ts +0 -113
- package/src/shared/api-errors.ts +0 -180
- package/src/shared/notice-consent-status.ts +0 -190
- package/src/types/css.d.ts +0 -4
- package/src/types/images.d.ts +0 -19
- package/src/types/react-jsx.d.ts +0 -26
- package/tests/DataAvailabilityContext.test.tsx +0 -123
- package/tests/Form.test.tsx +0 -1287
- package/tests/ManageConsentErrorMapping.test.tsx +0 -85
- package/tests/ProductSelectionSection.test.tsx +0 -328
- package/tests/RequestSubmit.test.tsx +0 -135
- package/tests/RevocablePurpose.test.tsx +0 -146
- package/tests/RevokeWarningMessage.test.tsx +0 -151
- package/tests/consentClient.test.ts +0 -217
- package/tests/manageConsentServer.test.ts +0 -38
- package/tests/mocks.ts +0 -257
- package/tests/resolveContactFromJwt.test.ts +0 -44
- package/tests/setup.ts +0 -16
- package/tsconfig.json +0 -16
- package/tsup.config.ts +0 -31
- package/vitest.config.ts +0 -16
|
@@ -1,1206 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect, useCallback, useMemo } from 'react';
|
|
2
|
-
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import { PCInput, PCSelect, PCButton, PCText, PCModal, type SelectOption } from '../ui';
|
|
4
|
-
import { Search, ArrowUpToLine, Filter, Circle } from 'lucide-react';
|
|
5
|
-
import { pcStyles } from '../styles/pcStyles';
|
|
6
|
-
import { AdvancedTable, AdvancedTablePagination } from '../table';
|
|
7
|
-
import {
|
|
8
|
-
getCoreRowModel,
|
|
9
|
-
getExpandedRowModel,
|
|
10
|
-
useReactTable,
|
|
11
|
-
type ExpandedState,
|
|
12
|
-
type PaginationState,
|
|
13
|
-
type Row,
|
|
14
|
-
type Updater,
|
|
15
|
-
} from '@tanstack/react-table';
|
|
16
|
-
import {
|
|
17
|
-
fetchUserConsents,
|
|
18
|
-
fetchGroupPurposes,
|
|
19
|
-
manageConsent,
|
|
20
|
-
} from '../lib/api';
|
|
21
|
-
import { useOrganization } from '../context/OrganizationContext';
|
|
22
|
-
import { useAuth } from '../context/AuthContext';
|
|
23
|
-
import { useBaseUrl } from '../context/BaseUrlContext';
|
|
24
|
-
import { usePageChrome } from '../context/PageChromeContext';
|
|
25
|
-
import { ConsentStatusEnum } from '../lib/types';
|
|
26
|
-
import type {
|
|
27
|
-
ConsentAction,
|
|
28
|
-
ConsentGroup,
|
|
29
|
-
ConsentModalRecord,
|
|
30
|
-
DisplayProductGroup,
|
|
31
|
-
DisplayPurposeRow,
|
|
32
|
-
PurposeItem,
|
|
33
|
-
UserConsentDetail,
|
|
34
|
-
} from '../lib/types';
|
|
35
|
-
import { useCurrentLanguage } from '../lib/useCurrentLanguage';
|
|
36
|
-
import { exportTableToCSV, useStatusOptions } from '../lib/consent-manager/utils';
|
|
37
|
-
import { toast } from '../utils/toast';
|
|
38
|
-
import { ConsentManagerTableSkeleton } from './ConsentManagerTableSkeleton';
|
|
39
|
-
import { ModifyConsentModal } from './ModifyConsentModal';
|
|
40
|
-
import { useConsentManagerGroupedColumns } from './ConsentManagerGroupedColumns';
|
|
41
|
-
import { useConsentManagerColumns } from './ConsentManagerColumns';
|
|
42
|
-
import { getStatusLabel, getGivenDateLabel, getValidTillLabel } from './ConsentManagerCells';
|
|
43
|
-
import { ConsentManagerExpandedRow } from './ConsentManagerExpandedRow';
|
|
44
|
-
import { ConsentManagerProductCards } from './ConsentManagerProductCards';
|
|
45
|
-
import { ConsentManagerPurposeCards } from './ConsentManagerPurposeCards';
|
|
46
|
-
import type {
|
|
47
|
-
ConsentManagerProps,
|
|
48
|
-
StatusFilterOption,
|
|
49
|
-
ProductFilterOption,
|
|
50
|
-
} from './types';
|
|
51
|
-
import {
|
|
52
|
-
SEARCH_DEBOUNCE_DELAY,
|
|
53
|
-
DEFAULT_PAGE,
|
|
54
|
-
DEFAULT_PAGE_SIZE,
|
|
55
|
-
} from './ConsentManagerConstants';
|
|
56
|
-
|
|
57
|
-
type ConsentViewMode = 'product' | 'purpose';
|
|
58
|
-
|
|
59
|
-
export default function ConsentManager({ variant }: ConsentManagerProps) {
|
|
60
|
-
const { t } = useTranslation();
|
|
61
|
-
const statusOptions = useStatusOptions();
|
|
62
|
-
const { organization } = useOrganization();
|
|
63
|
-
const { accessToken, refreshToken, onError, updateTokens } = useAuth();
|
|
64
|
-
const { consentClient } = useBaseUrl();
|
|
65
|
-
const { setHeaderStatus } = usePageChrome();
|
|
66
|
-
const organizationId = organization?.uuid;
|
|
67
|
-
const workspaceId = organization?.workspaces[0]?.uuid;
|
|
68
|
-
const contact = sessionStorage.getItem('email') || '';
|
|
69
|
-
|
|
70
|
-
// Create auth context object for API calls - memoized to prevent infinite loops
|
|
71
|
-
const authContext = useMemo(() => ({
|
|
72
|
-
accessToken,
|
|
73
|
-
refreshToken,
|
|
74
|
-
onError,
|
|
75
|
-
updateTokens,
|
|
76
|
-
}), [accessToken, refreshToken, onError, updateTokens]);
|
|
77
|
-
|
|
78
|
-
// Track language changes for localized API calls
|
|
79
|
-
const { langParam } = useCurrentLanguage();
|
|
80
|
-
|
|
81
|
-
// State management
|
|
82
|
-
const [activeTab, setActiveTab] = useState<'direct' | 'nominated'>('direct');
|
|
83
|
-
const [viewMode, setViewMode] = useState<ConsentViewMode>('product');
|
|
84
|
-
const [consentDetail, setConsentDetail] = useState<UserConsentDetail | null>(null);
|
|
85
|
-
const [consentGroups, setConsentGroups] = useState<DisplayProductGroup[]>([]);
|
|
86
|
-
const [consentRows, setConsentRows] = useState<DisplayPurposeRow[]>([]);
|
|
87
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
88
|
-
const [searchQuery, setSearchQuery] = useState('');
|
|
89
|
-
const [debouncedSearch, setDebouncedSearch] = useState('');
|
|
90
|
-
const [statusFilter, setStatusFilter] = useState<StatusFilterOption | null>(
|
|
91
|
-
null
|
|
92
|
-
);
|
|
93
|
-
const [productFilter, setProductFilter] =
|
|
94
|
-
useState<ProductFilterOption | null>(null);
|
|
95
|
-
const [productOptions, setProductOptions] = useState<ProductFilterOption[]>(
|
|
96
|
-
[]
|
|
97
|
-
);
|
|
98
|
-
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
99
|
-
const [selectedRecord, setSelectedRecord] = useState<ConsentModalRecord | null>(
|
|
100
|
-
null
|
|
101
|
-
);
|
|
102
|
-
const [exportModal, setExportModal] = useState(false);
|
|
103
|
-
const [isManageLoading, setIsManageLoading] = useState(false);
|
|
104
|
-
const [currentPage, setCurrentPage] = useState(DEFAULT_PAGE);
|
|
105
|
-
const [pageSize, setPageSize] = useState(DEFAULT_PAGE_SIZE);
|
|
106
|
-
const [expanded, setExpanded] = useState<ExpandedState>({});
|
|
107
|
-
const [extraPurposesByKey, setExtraPurposesByKey] = useState<Record<string, PurposeItem[]>>({});
|
|
108
|
-
const [hasMoreByKey, setHasMoreByKey] = useState<Record<string, boolean>>({});
|
|
109
|
-
const [loadingMoreByKey, setLoadingMoreByKey] = useState<Record<string, boolean>>({});
|
|
110
|
-
const composedSearchPlaceholder = useMemo(
|
|
111
|
-
() => `${t('search')} ${t('consent')}, ${t('product')}, ${t('purpose')}...`,
|
|
112
|
-
[t]
|
|
113
|
-
);
|
|
114
|
-
const allStatusOption = useMemo<StatusFilterOption>(
|
|
115
|
-
() => ({
|
|
116
|
-
label: `${t('all')} ${t('status')}`,
|
|
117
|
-
value: '__all__',
|
|
118
|
-
}),
|
|
119
|
-
[t]
|
|
120
|
-
);
|
|
121
|
-
const allProductOption = useMemo<ProductFilterOption>(
|
|
122
|
-
() => ({
|
|
123
|
-
label: `${t('all')} ${t('product')}`,
|
|
124
|
-
value: '__all__',
|
|
125
|
-
}),
|
|
126
|
-
[t]
|
|
127
|
-
);
|
|
128
|
-
const statusFilterOptions = useMemo<StatusFilterOption[]>(
|
|
129
|
-
() => [allStatusOption, ...statusOptions],
|
|
130
|
-
[allStatusOption, statusOptions]
|
|
131
|
-
);
|
|
132
|
-
const productFilterOptions = useMemo<ProductFilterOption[]>(
|
|
133
|
-
() => [allProductOption, ...productOptions],
|
|
134
|
-
[allProductOption, productOptions]
|
|
135
|
-
);
|
|
136
|
-
const statusSelectValue = statusFilter ?? allStatusOption;
|
|
137
|
-
const productSelectValue = productFilter ?? allProductOption;
|
|
138
|
-
|
|
139
|
-
// Sync selected status filter label when language changes
|
|
140
|
-
useEffect(() => {
|
|
141
|
-
if (statusFilter) {
|
|
142
|
-
const updated = statusOptions.find(opt => opt.value === statusFilter.value);
|
|
143
|
-
if (updated && updated.label !== statusFilter.label) {
|
|
144
|
-
setStatusFilter(updated);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}, [statusOptions, statusFilter]);
|
|
148
|
-
|
|
149
|
-
// Sync selected product filter label when language changes
|
|
150
|
-
useEffect(() => {
|
|
151
|
-
if (productFilter) {
|
|
152
|
-
const updated = productOptions.find(opt => opt.value === productFilter.value);
|
|
153
|
-
if (updated && updated.label !== productFilter.label) {
|
|
154
|
-
setProductFilter(updated);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}, [productOptions, productFilter]);
|
|
158
|
-
|
|
159
|
-
// Push user_status into the page header so it renders inline with the page title
|
|
160
|
-
useEffect(() => {
|
|
161
|
-
const status = consentDetail?.user_status;
|
|
162
|
-
if (status === 'TRANSFERRED') {
|
|
163
|
-
setHeaderStatus({ label: t('statusTransferred'), variant: 'warning' });
|
|
164
|
-
} else if (status === 'ACTIVE') {
|
|
165
|
-
setHeaderStatus({ label: t('statusActive'), variant: 'success' });
|
|
166
|
-
} else {
|
|
167
|
-
setHeaderStatus(null);
|
|
168
|
-
}
|
|
169
|
-
return () => setHeaderStatus(null);
|
|
170
|
-
}, [consentDetail?.user_status, setHeaderStatus, t]);
|
|
171
|
-
|
|
172
|
-
// Debounce search query
|
|
173
|
-
useEffect(() => {
|
|
174
|
-
const timer = setTimeout(() => {
|
|
175
|
-
setDebouncedSearch(searchQuery);
|
|
176
|
-
}, SEARCH_DEBOUNCE_DELAY);
|
|
177
|
-
return () => clearTimeout(timer);
|
|
178
|
-
}, [searchQuery]);
|
|
179
|
-
|
|
180
|
-
const handleOpenModal = useCallback((record: ConsentModalRecord) => {
|
|
181
|
-
setSelectedRecord(record);
|
|
182
|
-
setIsModalOpen(true);
|
|
183
|
-
}, []);
|
|
184
|
-
|
|
185
|
-
const getCardKey = useCallback(
|
|
186
|
-
(group: ConsentGroup): string =>
|
|
187
|
-
group.nominator
|
|
188
|
-
? `nominated:${group.nominator.uuid}:${group.product_uuid}`
|
|
189
|
-
: `direct:${group.product_uuid}`,
|
|
190
|
-
[]
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
const handleCloseModal = useCallback(() => {
|
|
194
|
-
setIsModalOpen(false);
|
|
195
|
-
setSelectedRecord(null);
|
|
196
|
-
}, []);
|
|
197
|
-
|
|
198
|
-
const matchesPurpose = useCallback(
|
|
199
|
-
(
|
|
200
|
-
purpose: PurposeItem,
|
|
201
|
-
group: ConsentGroup,
|
|
202
|
-
normalizedSearch: string,
|
|
203
|
-
statusValue?: string
|
|
204
|
-
) => {
|
|
205
|
-
const matchesSearch =
|
|
206
|
-
!normalizedSearch ||
|
|
207
|
-
[
|
|
208
|
-
purpose.name,
|
|
209
|
-
purpose.description,
|
|
210
|
-
group.product_name,
|
|
211
|
-
group.product_description,
|
|
212
|
-
purpose.method,
|
|
213
|
-
purpose.status,
|
|
214
|
-
]
|
|
215
|
-
.filter(Boolean)
|
|
216
|
-
.some((value) => String(value).toLowerCase().includes(normalizedSearch));
|
|
217
|
-
|
|
218
|
-
const matchesStatus =
|
|
219
|
-
!statusValue || purpose.status?.toLowerCase() === statusValue.toLowerCase();
|
|
220
|
-
|
|
221
|
-
return matchesSearch && matchesStatus;
|
|
222
|
-
},
|
|
223
|
-
[]
|
|
224
|
-
);
|
|
225
|
-
|
|
226
|
-
const buildDisplayGroups = useCallback(
|
|
227
|
-
(
|
|
228
|
-
groups: ConsentGroup[] | undefined,
|
|
229
|
-
search: string,
|
|
230
|
-
statusValue?: string,
|
|
231
|
-
productUuid?: string
|
|
232
|
-
): DisplayProductGroup[] => {
|
|
233
|
-
if (!groups || groups.length === 0) return [];
|
|
234
|
-
const normalizedSearch = search.trim().toLowerCase();
|
|
235
|
-
|
|
236
|
-
return groups.reduce<DisplayProductGroup[]>((acc, group) => {
|
|
237
|
-
if (productUuid && group.product_uuid !== productUuid) {
|
|
238
|
-
return acc;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const filteredPurposes = (group.purposes || []).filter((purpose) =>
|
|
242
|
-
matchesPurpose(purpose, group, normalizedSearch, statusValue)
|
|
243
|
-
);
|
|
244
|
-
|
|
245
|
-
if (filteredPurposes.length === 0) {
|
|
246
|
-
return acc;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const counts = filteredPurposes.reduce(
|
|
250
|
-
(totals, purpose) => {
|
|
251
|
-
const normalized = (typeof purpose.status === 'string' ? purpose.status : '').toUpperCase();
|
|
252
|
-
switch (normalized) {
|
|
253
|
-
case ConsentStatusEnum.ACTIVE:
|
|
254
|
-
totals.active += 1;
|
|
255
|
-
break;
|
|
256
|
-
case ConsentStatusEnum.WITHDRAWN:
|
|
257
|
-
case ConsentStatusEnum.REVOKED:
|
|
258
|
-
totals.withdrawn += 1;
|
|
259
|
-
break;
|
|
260
|
-
case ConsentStatusEnum.EXPIRED:
|
|
261
|
-
totals.expired += 1;
|
|
262
|
-
break;
|
|
263
|
-
case ConsentStatusEnum.DECLINED:
|
|
264
|
-
totals.declined += 1;
|
|
265
|
-
break;
|
|
266
|
-
default:
|
|
267
|
-
break;
|
|
268
|
-
}
|
|
269
|
-
return totals;
|
|
270
|
-
},
|
|
271
|
-
{ active: 0, withdrawn: 0, expired: 0, declined: 0 }
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
const latestGivenDate = filteredPurposes.reduce<string | null>((latest, purpose) => {
|
|
275
|
-
if (!purpose.given_date) return latest;
|
|
276
|
-
if (!latest) return purpose.given_date;
|
|
277
|
-
return new Date(purpose.given_date).getTime() > new Date(latest).getTime()
|
|
278
|
-
? purpose.given_date
|
|
279
|
-
: latest;
|
|
280
|
-
}, null);
|
|
281
|
-
|
|
282
|
-
acc.push({
|
|
283
|
-
...group,
|
|
284
|
-
purposes: filteredPurposes,
|
|
285
|
-
active_purposes: counts.active,
|
|
286
|
-
withdrawn_purposes: counts.withdrawn,
|
|
287
|
-
expired_purposes: counts.expired,
|
|
288
|
-
declined_purposes: counts.declined,
|
|
289
|
-
latest_given_date: latestGivenDate,
|
|
290
|
-
});
|
|
291
|
-
return acc;
|
|
292
|
-
}, []);
|
|
293
|
-
},
|
|
294
|
-
[matchesPurpose]
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
const flattenProductGroups = useCallback(
|
|
298
|
-
(groups: ConsentGroup[] | undefined): DisplayPurposeRow[] => {
|
|
299
|
-
if (!groups || groups.length === 0) return [];
|
|
300
|
-
return groups.flatMap((group) =>
|
|
301
|
-
(group.purposes || []).map((purpose) => ({
|
|
302
|
-
...purpose,
|
|
303
|
-
product_uuid: group.product_uuid,
|
|
304
|
-
product_name: group.product_name,
|
|
305
|
-
product_description: group.product_description,
|
|
306
|
-
nominator: group.nominator,
|
|
307
|
-
}))
|
|
308
|
-
);
|
|
309
|
-
},
|
|
310
|
-
[]
|
|
311
|
-
);
|
|
312
|
-
|
|
313
|
-
const filterConsentRows = useCallback(
|
|
314
|
-
(
|
|
315
|
-
rows: DisplayPurposeRow[],
|
|
316
|
-
search: string,
|
|
317
|
-
statusValue?: string,
|
|
318
|
-
productUuid?: string
|
|
319
|
-
): DisplayPurposeRow[] => {
|
|
320
|
-
const normalizedSearch = search.trim().toLowerCase();
|
|
321
|
-
return rows.filter((row) => {
|
|
322
|
-
const matchesSearch =
|
|
323
|
-
!normalizedSearch ||
|
|
324
|
-
[
|
|
325
|
-
row.name,
|
|
326
|
-
row.description,
|
|
327
|
-
row.product_name,
|
|
328
|
-
row.product_description,
|
|
329
|
-
row.method,
|
|
330
|
-
row.status,
|
|
331
|
-
]
|
|
332
|
-
.filter(Boolean)
|
|
333
|
-
.some((value) =>
|
|
334
|
-
String(value).toLowerCase().includes(normalizedSearch)
|
|
335
|
-
);
|
|
336
|
-
|
|
337
|
-
const matchesStatus =
|
|
338
|
-
!statusValue || row.status?.toLowerCase() === statusValue.toLowerCase();
|
|
339
|
-
const matchesProduct = !productUuid || row.product_uuid === productUuid;
|
|
340
|
-
|
|
341
|
-
return matchesSearch && matchesStatus && matchesProduct;
|
|
342
|
-
});
|
|
343
|
-
},
|
|
344
|
-
[]
|
|
345
|
-
);
|
|
346
|
-
|
|
347
|
-
const buildProductOptionsFromGroups = useCallback(
|
|
348
|
-
(groups: ConsentGroup[] | undefined) => {
|
|
349
|
-
if (!groups || groups.length === 0) return [];
|
|
350
|
-
const productMap = new Map<string, { label: string; value: string }>();
|
|
351
|
-
groups.forEach((group) => {
|
|
352
|
-
if (!productMap.has(group.product_uuid)) {
|
|
353
|
-
productMap.set(group.product_uuid, {
|
|
354
|
-
label: group.product_name,
|
|
355
|
-
value: group.product_uuid,
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
return Array.from(productMap.values());
|
|
360
|
-
},
|
|
361
|
-
[]
|
|
362
|
-
);
|
|
363
|
-
|
|
364
|
-
const groupedColumns = useConsentManagerGroupedColumns();
|
|
365
|
-
const purposeColumns = useConsentManagerColumns({
|
|
366
|
-
onOpenModal: handleOpenModal,
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
const groupedTableClassNames = useMemo(
|
|
370
|
-
() => ({
|
|
371
|
-
container: 'pc-consent-table-container',
|
|
372
|
-
tableClassName: 'pc-consent-table',
|
|
373
|
-
headerClassName: 'pc-consent-table-header',
|
|
374
|
-
bodyClassName: 'pc-consent-table-body',
|
|
375
|
-
rowClassName: 'pc-consent-table-row',
|
|
376
|
-
cellClassName: 'pc-consent-table-cell',
|
|
377
|
-
headerCellClassName: 'pc-consent-table-head-cell',
|
|
378
|
-
expandedRowClassName: 'pc-consent-table-expanded-row',
|
|
379
|
-
expandedCellClassName: 'pc-consent-table-expanded-cell',
|
|
380
|
-
}),
|
|
381
|
-
[]
|
|
382
|
-
);
|
|
383
|
-
|
|
384
|
-
const purposeTableClassNames = useMemo(
|
|
385
|
-
() => ({
|
|
386
|
-
container: 'pc-consent-table-container',
|
|
387
|
-
tableClassName: 'pc-consent-table pc-consent-table-purpose',
|
|
388
|
-
headerClassName: 'pc-consent-table-header',
|
|
389
|
-
bodyClassName: 'pc-consent-table-body',
|
|
390
|
-
rowClassName: 'pc-consent-table-row',
|
|
391
|
-
cellClassName: 'pc-consent-table-cell',
|
|
392
|
-
headerCellClassName: 'pc-consent-table-head-cell',
|
|
393
|
-
}),
|
|
394
|
-
[]
|
|
395
|
-
);
|
|
396
|
-
|
|
397
|
-
// Single data fetch function
|
|
398
|
-
const fetchData = useCallback(async () => {
|
|
399
|
-
if (!organizationId || !workspaceId) {
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
setIsLoading(true);
|
|
404
|
-
try {
|
|
405
|
-
const offset = (currentPage - 1) * pageSize;
|
|
406
|
-
const searchParam = debouncedSearch.trim() || undefined;
|
|
407
|
-
const statusParam = statusFilter?.value;
|
|
408
|
-
const productUuidParam = productFilter?.value;
|
|
409
|
-
|
|
410
|
-
const response = await fetchUserConsents({
|
|
411
|
-
organizationId,
|
|
412
|
-
workspaceId,
|
|
413
|
-
offset: activeTab === 'direct' ? offset : undefined,
|
|
414
|
-
limit: activeTab === 'direct' ? pageSize : undefined,
|
|
415
|
-
nominatedOffset: activeTab === 'nominated' ? offset : undefined,
|
|
416
|
-
nominatedLimit: activeTab === 'nominated' ? pageSize : undefined,
|
|
417
|
-
search: searchParam,
|
|
418
|
-
status: statusParam,
|
|
419
|
-
product_uuid: productUuidParam,
|
|
420
|
-
language: langParam,
|
|
421
|
-
authContext,
|
|
422
|
-
consentClient,
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
if (!response) {
|
|
426
|
-
throw new Error('Failed to fetch consent data');
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
setConsentDetail(response);
|
|
430
|
-
setExtraPurposesByKey({});
|
|
431
|
-
setHasMoreByKey({});
|
|
432
|
-
setLoadingMoreByKey({});
|
|
433
|
-
|
|
434
|
-
const selectedGroups =
|
|
435
|
-
activeTab === 'direct' ? response.direct : response.nominated;
|
|
436
|
-
const displayGroups = buildDisplayGroups(
|
|
437
|
-
selectedGroups,
|
|
438
|
-
debouncedSearch,
|
|
439
|
-
statusParam,
|
|
440
|
-
productUuidParam
|
|
441
|
-
);
|
|
442
|
-
setConsentGroups(displayGroups);
|
|
443
|
-
const flattenedRows = flattenProductGroups(selectedGroups);
|
|
444
|
-
const filteredRows = filterConsentRows(
|
|
445
|
-
flattenedRows,
|
|
446
|
-
debouncedSearch,
|
|
447
|
-
statusParam,
|
|
448
|
-
productUuidParam
|
|
449
|
-
);
|
|
450
|
-
setConsentRows(filteredRows);
|
|
451
|
-
|
|
452
|
-
// Only refresh the product filter options from an unfiltered fetch.
|
|
453
|
-
// When a product filter is active the API returns rows for that one
|
|
454
|
-
// product, so re-deriving options here would shrink the dropdown to
|
|
455
|
-
// just the selected product (forcing the user to refresh to recover).
|
|
456
|
-
if (!productFilter) {
|
|
457
|
-
const combinedGroups = [
|
|
458
|
-
...(response.direct || []),
|
|
459
|
-
...(response.nominated || []),
|
|
460
|
-
];
|
|
461
|
-
setProductOptions(buildProductOptionsFromGroups(combinedGroups));
|
|
462
|
-
}
|
|
463
|
-
} catch (error) {
|
|
464
|
-
console.error(error);
|
|
465
|
-
setConsentDetail(null);
|
|
466
|
-
setConsentGroups([]);
|
|
467
|
-
setConsentRows([]);
|
|
468
|
-
setProductOptions([]);
|
|
469
|
-
setExtraPurposesByKey({});
|
|
470
|
-
setHasMoreByKey({});
|
|
471
|
-
setLoadingMoreByKey({});
|
|
472
|
-
toast.error(t('failedToFetchConsentData'));
|
|
473
|
-
} finally {
|
|
474
|
-
setIsLoading(false);
|
|
475
|
-
}
|
|
476
|
-
}, [
|
|
477
|
-
organizationId,
|
|
478
|
-
workspaceId,
|
|
479
|
-
currentPage,
|
|
480
|
-
pageSize,
|
|
481
|
-
debouncedSearch,
|
|
482
|
-
statusFilter?.value,
|
|
483
|
-
productFilter?.value,
|
|
484
|
-
activeTab,
|
|
485
|
-
authContext,
|
|
486
|
-
consentClient,
|
|
487
|
-
langParam,
|
|
488
|
-
buildDisplayGroups,
|
|
489
|
-
flattenProductGroups,
|
|
490
|
-
filterConsentRows,
|
|
491
|
-
buildProductOptionsFromGroups,
|
|
492
|
-
t,
|
|
493
|
-
]);
|
|
494
|
-
|
|
495
|
-
// Single effect for data fetching
|
|
496
|
-
useEffect(() => {
|
|
497
|
-
fetchData();
|
|
498
|
-
}, [fetchData]);
|
|
499
|
-
|
|
500
|
-
const groupedPurposeCount = useMemo(
|
|
501
|
-
() => consentGroups.reduce((sum, group) => sum + group.purposes.length, 0),
|
|
502
|
-
[consentGroups]
|
|
503
|
-
);
|
|
504
|
-
|
|
505
|
-
const visibleConsentCount =
|
|
506
|
-
viewMode === 'product' ? groupedPurposeCount : consentRows.length;
|
|
507
|
-
|
|
508
|
-
const visibleProductCount = useMemo(() => {
|
|
509
|
-
if (viewMode === 'product') {
|
|
510
|
-
return consentGroups.length;
|
|
511
|
-
}
|
|
512
|
-
const productIds = new Set(
|
|
513
|
-
consentRows.map((row) => row.product_uuid || row.product_name || '')
|
|
514
|
-
);
|
|
515
|
-
productIds.delete('');
|
|
516
|
-
return productIds.size;
|
|
517
|
-
}, [viewMode, consentGroups, consentRows]);
|
|
518
|
-
|
|
519
|
-
const tableTotalCount = useMemo(() => {
|
|
520
|
-
const pagination =
|
|
521
|
-
activeTab === 'direct'
|
|
522
|
-
? consentDetail?.direct_pagination
|
|
523
|
-
: consentDetail?.nominated_pagination;
|
|
524
|
-
return pagination?.total_count ?? 0;
|
|
525
|
-
}, [activeTab, consentDetail]);
|
|
526
|
-
|
|
527
|
-
const tablePageCount = Math.ceil(tableTotalCount / pageSize) || 0;
|
|
528
|
-
|
|
529
|
-
const handlePaginationChange = useCallback(
|
|
530
|
-
(updater: Updater<PaginationState>) => {
|
|
531
|
-
const next =
|
|
532
|
-
typeof updater === 'function'
|
|
533
|
-
? updater({ pageIndex: currentPage - 1, pageSize })
|
|
534
|
-
: updater;
|
|
535
|
-
const nextPage = next.pageIndex + 1;
|
|
536
|
-
const nextSize = next.pageSize;
|
|
537
|
-
if (nextPage === currentPage && nextSize === pageSize) return;
|
|
538
|
-
setCurrentPage(nextPage);
|
|
539
|
-
setPageSize(nextSize);
|
|
540
|
-
},
|
|
541
|
-
[currentPage, pageSize]
|
|
542
|
-
);
|
|
543
|
-
|
|
544
|
-
const productTable = useReactTable<DisplayProductGroup>({
|
|
545
|
-
data: consentGroups,
|
|
546
|
-
columns: groupedColumns,
|
|
547
|
-
getCoreRowModel: getCoreRowModel(),
|
|
548
|
-
getExpandedRowModel: getExpandedRowModel(),
|
|
549
|
-
getRowCanExpand: () => true,
|
|
550
|
-
manualPagination: true,
|
|
551
|
-
pageCount: tablePageCount,
|
|
552
|
-
state: {
|
|
553
|
-
pagination: {
|
|
554
|
-
pageIndex: currentPage - 1,
|
|
555
|
-
pageSize: pageSize,
|
|
556
|
-
},
|
|
557
|
-
expanded,
|
|
558
|
-
},
|
|
559
|
-
onExpandedChange: (updater) => {
|
|
560
|
-
const next = typeof updater === 'function' ? updater(expanded) : updater;
|
|
561
|
-
if (next === true) {
|
|
562
|
-
setExpanded(next);
|
|
563
|
-
return;
|
|
564
|
-
}
|
|
565
|
-
if (!next) {
|
|
566
|
-
setExpanded({});
|
|
567
|
-
return;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
const nextMap = next as Record<string, boolean>;
|
|
571
|
-
const nextOpenIds = Object.keys(nextMap).filter((rowId) => nextMap[rowId]);
|
|
572
|
-
if (nextOpenIds.length <= 1) {
|
|
573
|
-
setExpanded(nextOpenIds.length === 1 ? { [nextOpenIds[0]]: true } : {});
|
|
574
|
-
return;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
const prevMap =
|
|
578
|
-
expanded && expanded !== true ? (expanded as Record<string, boolean>) : {};
|
|
579
|
-
const newlyOpenedId =
|
|
580
|
-
nextOpenIds.find((rowId) => !prevMap[rowId]) ??
|
|
581
|
-
nextOpenIds[nextOpenIds.length - 1];
|
|
582
|
-
|
|
583
|
-
setExpanded(newlyOpenedId ? { [newlyOpenedId]: true } : {});
|
|
584
|
-
},
|
|
585
|
-
onPaginationChange: (updater) => {
|
|
586
|
-
handlePaginationChange(updater);
|
|
587
|
-
setExpanded({});
|
|
588
|
-
},
|
|
589
|
-
meta: {
|
|
590
|
-
onRowClick: (_row: DisplayProductGroup, tableRow?: Row<DisplayProductGroup>) => {
|
|
591
|
-
tableRow?.toggleExpanded();
|
|
592
|
-
},
|
|
593
|
-
},
|
|
594
|
-
});
|
|
595
|
-
|
|
596
|
-
const purposeTable = useReactTable<DisplayPurposeRow>({
|
|
597
|
-
data: consentRows,
|
|
598
|
-
columns: purposeColumns,
|
|
599
|
-
getCoreRowModel: getCoreRowModel(),
|
|
600
|
-
manualPagination: true,
|
|
601
|
-
pageCount: tablePageCount,
|
|
602
|
-
state: {
|
|
603
|
-
pagination: {
|
|
604
|
-
pageIndex: currentPage - 1,
|
|
605
|
-
pageSize: pageSize,
|
|
606
|
-
},
|
|
607
|
-
},
|
|
608
|
-
onPaginationChange: handlePaginationChange,
|
|
609
|
-
});
|
|
610
|
-
|
|
611
|
-
const handleStatusFilterChange = (data: SelectOption | null) => {
|
|
612
|
-
if (!data || String(data.value) === allStatusOption.value) {
|
|
613
|
-
setStatusFilter(null);
|
|
614
|
-
} else {
|
|
615
|
-
setStatusFilter(data as StatusFilterOption);
|
|
616
|
-
}
|
|
617
|
-
setCurrentPage(DEFAULT_PAGE);
|
|
618
|
-
setExpanded({});
|
|
619
|
-
};
|
|
620
|
-
|
|
621
|
-
const handleProductFilterChange = (data: SelectOption | null) => {
|
|
622
|
-
if (!data || String(data.value) === allProductOption.value) {
|
|
623
|
-
setProductFilter(null);
|
|
624
|
-
} else {
|
|
625
|
-
setProductFilter(data as ProductFilterOption);
|
|
626
|
-
}
|
|
627
|
-
setCurrentPage(DEFAULT_PAGE);
|
|
628
|
-
setExpanded({});
|
|
629
|
-
};
|
|
630
|
-
|
|
631
|
-
const handleTabChange = (tab: 'direct' | 'nominated') => {
|
|
632
|
-
setActiveTab(tab);
|
|
633
|
-
setCurrentPage(DEFAULT_PAGE);
|
|
634
|
-
setExpanded({});
|
|
635
|
-
};
|
|
636
|
-
|
|
637
|
-
const handleViewModeChange = (mode: ConsentViewMode) => {
|
|
638
|
-
if (mode === viewMode) return;
|
|
639
|
-
setViewMode(mode);
|
|
640
|
-
setCurrentPage(DEFAULT_PAGE);
|
|
641
|
-
setExpanded({});
|
|
642
|
-
};
|
|
643
|
-
|
|
644
|
-
const handleExport = useCallback(() => {
|
|
645
|
-
// Build CSV rows whose cells exactly match the on-screen table: formatted
|
|
646
|
-
// dates, translated status labels, and the "Until Withdrawal (no expiry)" /
|
|
647
|
-
// "-" valid-till labels. Keys are the localized column headers.
|
|
648
|
-
const toRow = (purpose: PurposeItem, productName: string | null) => ({
|
|
649
|
-
[t('purpose')]: purpose.name,
|
|
650
|
-
[t('descriptionLabel')]: purpose.description ?? '',
|
|
651
|
-
[t('product')]: productName ?? '-',
|
|
652
|
-
[t('status')]: getStatusLabel(String(purpose.status), t),
|
|
653
|
-
[t('givenDate')]: getGivenDateLabel(purpose.given_date),
|
|
654
|
-
[t('validTill')]: getValidTillLabel(purpose, t),
|
|
655
|
-
[t('method')]: purpose.method ?? '',
|
|
656
|
-
});
|
|
657
|
-
|
|
658
|
-
const rows = viewMode === 'product'
|
|
659
|
-
? productTable.getRowModel().rows.flatMap((row) =>
|
|
660
|
-
row.original.purposes.map((purpose) => toRow(purpose, row.original.product_name))
|
|
661
|
-
)
|
|
662
|
-
: purposeTable.getRowModel().rows.map((row) =>
|
|
663
|
-
toRow(row.original, row.original.product_name)
|
|
664
|
-
);
|
|
665
|
-
|
|
666
|
-
exportTableToCSV(rows);
|
|
667
|
-
setExportModal(false);
|
|
668
|
-
}, [viewMode, productTable, purposeTable, t]);
|
|
669
|
-
|
|
670
|
-
const handleLoadMorePurposes = useCallback(
|
|
671
|
-
async (group: DisplayProductGroup) => {
|
|
672
|
-
if (!organizationId || !workspaceId) return;
|
|
673
|
-
const cardKey = getCardKey(group);
|
|
674
|
-
if (loadingMoreByKey[cardKey]) return;
|
|
675
|
-
|
|
676
|
-
const alreadyLoaded = extraPurposesByKey[cardKey]?.length ?? 0;
|
|
677
|
-
const inlineCount = group.purposes.length;
|
|
678
|
-
const offset = inlineCount + alreadyLoaded;
|
|
679
|
-
const statusParam = statusFilter?.value;
|
|
680
|
-
const searchParam = debouncedSearch.trim() || undefined;
|
|
681
|
-
|
|
682
|
-
setLoadingMoreByKey((prev) => ({ ...prev, [cardKey]: true }));
|
|
683
|
-
try {
|
|
684
|
-
const result = await fetchGroupPurposes({
|
|
685
|
-
organizationId,
|
|
686
|
-
workspaceId,
|
|
687
|
-
productUuid: group.product_uuid,
|
|
688
|
-
offset,
|
|
689
|
-
limit: 50,
|
|
690
|
-
status: statusParam,
|
|
691
|
-
search: searchParam,
|
|
692
|
-
language: langParam,
|
|
693
|
-
nominatorUuid: group.nominator?.uuid,
|
|
694
|
-
authContext,
|
|
695
|
-
consentClient,
|
|
696
|
-
});
|
|
697
|
-
if (!result) {
|
|
698
|
-
throw new Error('Failed to load more purposes');
|
|
699
|
-
}
|
|
700
|
-
setExtraPurposesByKey((prev) => ({
|
|
701
|
-
...prev,
|
|
702
|
-
[cardKey]: [...(prev[cardKey] ?? []), ...result.purposes],
|
|
703
|
-
}));
|
|
704
|
-
const fetchedTotal = offset + result.purposes.length;
|
|
705
|
-
const hasMore = fetchedTotal < result.pagination.total_count;
|
|
706
|
-
setHasMoreByKey((prev) => ({ ...prev, [cardKey]: hasMore }));
|
|
707
|
-
} catch (error) {
|
|
708
|
-
console.error('Failed to load more purposes:', error);
|
|
709
|
-
toast.error(t('failedToFetchConsentData'));
|
|
710
|
-
} finally {
|
|
711
|
-
setLoadingMoreByKey((prev) => ({ ...prev, [cardKey]: false }));
|
|
712
|
-
}
|
|
713
|
-
},
|
|
714
|
-
[
|
|
715
|
-
organizationId,
|
|
716
|
-
workspaceId,
|
|
717
|
-
authContext,
|
|
718
|
-
consentClient,
|
|
719
|
-
langParam,
|
|
720
|
-
statusFilter?.value,
|
|
721
|
-
debouncedSearch,
|
|
722
|
-
extraPurposesByKey,
|
|
723
|
-
loadingMoreByKey,
|
|
724
|
-
getCardKey,
|
|
725
|
-
t,
|
|
726
|
-
]
|
|
727
|
-
);
|
|
728
|
-
|
|
729
|
-
const handleManageConsent = useCallback(
|
|
730
|
-
async (
|
|
731
|
-
purposeId: string,
|
|
732
|
-
action: ConsentAction,
|
|
733
|
-
nominatorContact?: string,
|
|
734
|
-
dataElementUuids?: string[],
|
|
735
|
-
productUuid?: string
|
|
736
|
-
) => {
|
|
737
|
-
if (!organizationId || !workspaceId || !contact) {
|
|
738
|
-
toast.error(t('missingInfoToManage'));
|
|
739
|
-
return;
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
setIsManageLoading(true);
|
|
743
|
-
|
|
744
|
-
const successMessages: Record<ConsentAction, string> = {
|
|
745
|
-
revoke: t('consentRevokedSuccess'),
|
|
746
|
-
regrant: t('consentRegrantedSuccess'),
|
|
747
|
-
renew: t('consentRenewedSuccess'),
|
|
748
|
-
};
|
|
749
|
-
|
|
750
|
-
const errorMessages: Record<ConsentAction, string> = {
|
|
751
|
-
revoke: t('unableToRevokeConsent'),
|
|
752
|
-
regrant: t('unableToRegrantConsent'),
|
|
753
|
-
renew: t('unableToRenewConsent'),
|
|
754
|
-
};
|
|
755
|
-
|
|
756
|
-
try {
|
|
757
|
-
// The ledger's submit-consent needs the notice the purpose was consented
|
|
758
|
-
// under, plus the purpose's data elements with their current selected
|
|
759
|
-
// state — both live on the loaded consent record (selectedRecord).
|
|
760
|
-
const noticeUuid = selectedRecord?.notice_uuid ?? undefined;
|
|
761
|
-
const dataElements = (selectedRecord?.data_elements ?? []).map((el) => ({
|
|
762
|
-
uuid: el.uuid,
|
|
763
|
-
selected: el.selected,
|
|
764
|
-
}));
|
|
765
|
-
|
|
766
|
-
const response = await manageConsent({
|
|
767
|
-
organizationId,
|
|
768
|
-
workspaceId,
|
|
769
|
-
purposeId,
|
|
770
|
-
contact,
|
|
771
|
-
action,
|
|
772
|
-
authContext,
|
|
773
|
-
consentClient,
|
|
774
|
-
nominatorContact,
|
|
775
|
-
dataElementUuids,
|
|
776
|
-
productUuid,
|
|
777
|
-
noticeUuid,
|
|
778
|
-
dataElements,
|
|
779
|
-
language: langParam,
|
|
780
|
-
});
|
|
781
|
-
|
|
782
|
-
if (response) {
|
|
783
|
-
toast.success(successMessages[action]);
|
|
784
|
-
await fetchData();
|
|
785
|
-
} else {
|
|
786
|
-
toast.error(errorMessages[action]);
|
|
787
|
-
}
|
|
788
|
-
} catch (error: any) {
|
|
789
|
-
console.error(`Error ${action} consent:`, error);
|
|
790
|
-
if (error?.code === 'NOMINATOR_NOT_FOUND') {
|
|
791
|
-
toast.error(t('nominatorNotFound'));
|
|
792
|
-
} else if (error?.code === 'NOMINEE_MUST_SPECIFY_NOMINATOR') {
|
|
793
|
-
toast.error(t('nomineeMustSpecifyNominator'));
|
|
794
|
-
} else if (error?.code === 'PURPOSE_NOT_REVOCABLE') {
|
|
795
|
-
toast.error(
|
|
796
|
-
t(
|
|
797
|
-
'purposeNotRevocableError',
|
|
798
|
-
'This purpose can\'t be withdrawn directly. Please raise a request to remove it.'
|
|
799
|
-
)
|
|
800
|
-
);
|
|
801
|
-
} else {
|
|
802
|
-
toast.error(errorMessages[action]);
|
|
803
|
-
}
|
|
804
|
-
} finally {
|
|
805
|
-
setIsManageLoading(false);
|
|
806
|
-
handleCloseModal();
|
|
807
|
-
}
|
|
808
|
-
},
|
|
809
|
-
[organizationId, workspaceId, contact, fetchData, handleCloseModal, t, authContext, consentClient, selectedRecord, langParam]
|
|
810
|
-
);
|
|
811
|
-
|
|
812
|
-
const getVar = (varName: string): string => `var(${varName})`;
|
|
813
|
-
|
|
814
|
-
const directBadge: number | '' =
|
|
815
|
-
consentDetail?.status_summary?.direct_purposes ?? '';
|
|
816
|
-
|
|
817
|
-
const nominatedBadge: number | '' =
|
|
818
|
-
consentDetail?.status_summary?.nominated_purposes ?? '';
|
|
819
|
-
|
|
820
|
-
const nominatorLabels = (consentDetail?.nominators || [])
|
|
821
|
-
.map((n) => n.email?.trim() || n.org_user_id?.trim() || n.uuid?.trim() || '')
|
|
822
|
-
.filter(Boolean);
|
|
823
|
-
const summaryText = t('productsAndConsentsSummary', {
|
|
824
|
-
products: visibleProductCount,
|
|
825
|
-
consents: visibleConsentCount,
|
|
826
|
-
});
|
|
827
|
-
|
|
828
|
-
return (
|
|
829
|
-
<div className="pc-consent-manager-surface" style={{ width: '100%' }}>
|
|
830
|
-
<div
|
|
831
|
-
className="pc-consent-shell-card"
|
|
832
|
-
style={{
|
|
833
|
-
backgroundColor: 'transparent',
|
|
834
|
-
}}
|
|
835
|
-
>
|
|
836
|
-
{/* Tabs: My Consents / Managing + Product/Purpose toggle */}
|
|
837
|
-
<div
|
|
838
|
-
className="pc-consent-tabs-row"
|
|
839
|
-
style={{
|
|
840
|
-
display: 'flex',
|
|
841
|
-
alignItems: 'center',
|
|
842
|
-
justifyContent: 'space-between',
|
|
843
|
-
gap: getVar('--pc-spacing-sm'),
|
|
844
|
-
borderBottom: `1px solid ${getVar('--pc-border-color')}`,
|
|
845
|
-
padding: '0.125rem 0 0.375rem',
|
|
846
|
-
}}
|
|
847
|
-
>
|
|
848
|
-
<div className="pc-consent-tabs-left" style={{ display: 'flex', minWidth: 0 }}>
|
|
849
|
-
<button
|
|
850
|
-
type="button"
|
|
851
|
-
onClick={() => handleTabChange('direct')}
|
|
852
|
-
style={{
|
|
853
|
-
display: 'flex',
|
|
854
|
-
alignItems: 'center',
|
|
855
|
-
gap: getVar('--pc-spacing-sm'),
|
|
856
|
-
padding: `0.5rem ${getVar('--pc-spacing-sm')}`,
|
|
857
|
-
fontSize: '0.75rem',
|
|
858
|
-
fontWeight: 600,
|
|
859
|
-
background: 'none',
|
|
860
|
-
border: 'none',
|
|
861
|
-
cursor: 'pointer',
|
|
862
|
-
borderBottom: activeTab === 'direct' ? `2px solid ${getVar('--pc-primary')}` : '2px solid transparent',
|
|
863
|
-
color: activeTab === 'direct' ? getVar('--pc-primary') : getVar('--pc-text-secondary'),
|
|
864
|
-
transition: 'color 0.2s, border-color 0.2s',
|
|
865
|
-
}}
|
|
866
|
-
>
|
|
867
|
-
{t('myConsents')}
|
|
868
|
-
<span style={{
|
|
869
|
-
borderRadius: '9999px',
|
|
870
|
-
backgroundColor: getVar('--pc-bg-tertiary'),
|
|
871
|
-
padding: '0.0625rem 0.375rem',
|
|
872
|
-
fontSize: '0.6875rem',
|
|
873
|
-
color: getVar('--pc-text-secondary'),
|
|
874
|
-
}}>
|
|
875
|
-
{directBadge}
|
|
876
|
-
</span>
|
|
877
|
-
</button>
|
|
878
|
-
<button
|
|
879
|
-
type="button"
|
|
880
|
-
onClick={() => handleTabChange('nominated')}
|
|
881
|
-
style={{
|
|
882
|
-
display: 'flex',
|
|
883
|
-
alignItems: 'center',
|
|
884
|
-
gap: getVar('--pc-spacing-sm'),
|
|
885
|
-
padding: `0.5rem ${getVar('--pc-spacing-sm')}`,
|
|
886
|
-
fontSize: '0.75rem',
|
|
887
|
-
fontWeight: 600,
|
|
888
|
-
background: 'none',
|
|
889
|
-
border: 'none',
|
|
890
|
-
cursor: 'pointer',
|
|
891
|
-
borderBottom: activeTab === 'nominated' ? `2px solid ${getVar('--pc-primary')}` : '2px solid transparent',
|
|
892
|
-
color: activeTab === 'nominated' ? getVar('--pc-primary') : getVar('--pc-text-secondary'),
|
|
893
|
-
transition: 'color 0.2s, border-color 0.2s',
|
|
894
|
-
}}
|
|
895
|
-
>
|
|
896
|
-
{t('managing')}
|
|
897
|
-
<span style={{
|
|
898
|
-
borderRadius: '9999px',
|
|
899
|
-
backgroundColor: getVar('--pc-bg-tertiary'),
|
|
900
|
-
padding: '0.0625rem 0.375rem',
|
|
901
|
-
fontSize: '0.6875rem',
|
|
902
|
-
color: getVar('--pc-text-secondary'),
|
|
903
|
-
}}>
|
|
904
|
-
{nominatedBadge}
|
|
905
|
-
</span>
|
|
906
|
-
</button>
|
|
907
|
-
</div>
|
|
908
|
-
|
|
909
|
-
<div
|
|
910
|
-
className="pc-consent-view-toggle"
|
|
911
|
-
style={{
|
|
912
|
-
marginLeft: 'auto',
|
|
913
|
-
display: 'flex',
|
|
914
|
-
alignItems: 'center',
|
|
915
|
-
gap: getVar('--pc-spacing-sm'),
|
|
916
|
-
paddingRight: getVar('--pc-spacing-sm'),
|
|
917
|
-
}}
|
|
918
|
-
>
|
|
919
|
-
<PCText
|
|
920
|
-
size="sm"
|
|
921
|
-
color="secondary"
|
|
922
|
-
className="pc-consent-view-toggle-label"
|
|
923
|
-
style={{ margin: 0, fontSize: '0.75rem', fontWeight: 500 }}
|
|
924
|
-
>
|
|
925
|
-
{t('consentVisibility')}
|
|
926
|
-
</PCText>
|
|
927
|
-
<div
|
|
928
|
-
className="pc-consent-view-toggle-group"
|
|
929
|
-
style={{
|
|
930
|
-
display: 'inline-flex',
|
|
931
|
-
borderRadius: '9999px',
|
|
932
|
-
backgroundColor: getVar('--pc-bg-secondary'),
|
|
933
|
-
padding: '0.125rem',
|
|
934
|
-
}}
|
|
935
|
-
>
|
|
936
|
-
<button
|
|
937
|
-
type="button"
|
|
938
|
-
className={`pc-consent-view-toggle-btn ${viewMode === 'product' ? 'is-active' : ''}`}
|
|
939
|
-
onClick={() => handleViewModeChange('product')}
|
|
940
|
-
style={{
|
|
941
|
-
minWidth: '5.25rem',
|
|
942
|
-
minHeight: '1.75rem',
|
|
943
|
-
padding: '0.3125rem 0.75rem',
|
|
944
|
-
border: 'none',
|
|
945
|
-
backgroundColor:
|
|
946
|
-
viewMode === 'product' ? getVar('--pc-primary') : 'transparent',
|
|
947
|
-
color:
|
|
948
|
-
viewMode === 'product'
|
|
949
|
-
? getVar('--pc-text-inverse')
|
|
950
|
-
: getVar('--pc-text-secondary'),
|
|
951
|
-
fontSize: '0.6875rem',
|
|
952
|
-
fontWeight: 600,
|
|
953
|
-
cursor: 'pointer',
|
|
954
|
-
borderRadius: '9999px',
|
|
955
|
-
transition: 'background-color 0.2s ease, color 0.2s ease',
|
|
956
|
-
}}
|
|
957
|
-
>
|
|
958
|
-
{t('product')}
|
|
959
|
-
</button>
|
|
960
|
-
<button
|
|
961
|
-
type="button"
|
|
962
|
-
className={`pc-consent-view-toggle-btn ${viewMode === 'purpose' ? 'is-active' : ''}`}
|
|
963
|
-
onClick={() => handleViewModeChange('purpose')}
|
|
964
|
-
style={{
|
|
965
|
-
minWidth: '5.25rem',
|
|
966
|
-
minHeight: '1.75rem',
|
|
967
|
-
padding: '0.3125rem 0.75rem',
|
|
968
|
-
border: 'none',
|
|
969
|
-
backgroundColor:
|
|
970
|
-
viewMode === 'purpose' ? getVar('--pc-primary') : 'transparent',
|
|
971
|
-
color:
|
|
972
|
-
viewMode === 'purpose'
|
|
973
|
-
? getVar('--pc-text-inverse')
|
|
974
|
-
: getVar('--pc-text-secondary'),
|
|
975
|
-
fontSize: '0.6875rem',
|
|
976
|
-
fontWeight: 600,
|
|
977
|
-
cursor: 'pointer',
|
|
978
|
-
borderRadius: '9999px',
|
|
979
|
-
transition: 'background-color 0.2s ease, color 0.2s ease',
|
|
980
|
-
}}
|
|
981
|
-
>
|
|
982
|
-
{t('purpose')}
|
|
983
|
-
</button>
|
|
984
|
-
</div>
|
|
985
|
-
</div>
|
|
986
|
-
</div>
|
|
987
|
-
|
|
988
|
-
{activeTab === 'nominated' && nominatorLabels.length > 0 && (
|
|
989
|
-
<PCText
|
|
990
|
-
size="sm"
|
|
991
|
-
color="secondary"
|
|
992
|
-
style={{
|
|
993
|
-
margin: 0,
|
|
994
|
-
marginBottom: getVar('--pc-spacing-sm'),
|
|
995
|
-
paddingLeft: getVar('--pc-spacing-lg'),
|
|
996
|
-
paddingRight: getVar('--pc-spacing-lg'),
|
|
997
|
-
}}
|
|
998
|
-
>
|
|
999
|
-
{t('managingConsentsFor')}{' '}
|
|
1000
|
-
<span style={{ fontWeight: 600, color: getVar('--pc-text-primary') }}>
|
|
1001
|
-
{nominatorLabels.join(', ')}
|
|
1002
|
-
</span>
|
|
1003
|
-
</PCText>
|
|
1004
|
-
)}
|
|
1005
|
-
|
|
1006
|
-
{/* Filters Section: Search on left, filters and export on the right */}
|
|
1007
|
-
<div style={{
|
|
1008
|
-
display: 'flex',
|
|
1009
|
-
flexDirection: 'column',
|
|
1010
|
-
gap: getVar('--pc-spacing-sm'),
|
|
1011
|
-
width: '100%',
|
|
1012
|
-
padding: '0.75rem 0 0.625rem',
|
|
1013
|
-
}} className="pc-filters-responsive">
|
|
1014
|
-
<div style={{ width: '100%' }} className="pc-search-responsive">
|
|
1015
|
-
<PCInput
|
|
1016
|
-
type="search"
|
|
1017
|
-
size="sm"
|
|
1018
|
-
clearable
|
|
1019
|
-
clearAriaLabel={t('clearInput')}
|
|
1020
|
-
placeholder={composedSearchPlaceholder}
|
|
1021
|
-
value={searchQuery}
|
|
1022
|
-
onClear={() => {
|
|
1023
|
-
setSearchQuery('');
|
|
1024
|
-
setCurrentPage(DEFAULT_PAGE);
|
|
1025
|
-
}}
|
|
1026
|
-
prefix={<Search size={14} strokeWidth={1.8} />}
|
|
1027
|
-
onChange={(e) => {
|
|
1028
|
-
setSearchQuery(e.target.value);
|
|
1029
|
-
setCurrentPage(DEFAULT_PAGE);
|
|
1030
|
-
}}
|
|
1031
|
-
style={{
|
|
1032
|
-
width: '100%',
|
|
1033
|
-
}}
|
|
1034
|
-
/>
|
|
1035
|
-
</div>
|
|
1036
|
-
|
|
1037
|
-
<div style={{
|
|
1038
|
-
display: 'flex',
|
|
1039
|
-
flexDirection: 'column',
|
|
1040
|
-
gap: getVar('--pc-spacing-sm'),
|
|
1041
|
-
width: '100%',
|
|
1042
|
-
}} className="pc-filters-row-responsive">
|
|
1043
|
-
<PCSelect
|
|
1044
|
-
className="pc-filter-select"
|
|
1045
|
-
size="sm"
|
|
1046
|
-
placeholder={t('status')}
|
|
1047
|
-
prefix={<Filter size={12} strokeWidth={1.8} />}
|
|
1048
|
-
options={statusFilterOptions}
|
|
1049
|
-
value={statusSelectValue}
|
|
1050
|
-
onChange={handleStatusFilterChange}
|
|
1051
|
-
showSelectedCheck
|
|
1052
|
-
style={{
|
|
1053
|
-
width: '100%',
|
|
1054
|
-
}}
|
|
1055
|
-
/>
|
|
1056
|
-
<PCSelect
|
|
1057
|
-
className="pc-filter-select"
|
|
1058
|
-
size="sm"
|
|
1059
|
-
placeholder={t('product')}
|
|
1060
|
-
prefix={<Circle size={10} strokeWidth={2} />}
|
|
1061
|
-
options={productFilterOptions}
|
|
1062
|
-
value={productSelectValue}
|
|
1063
|
-
onChange={handleProductFilterChange}
|
|
1064
|
-
showSelectedCheck
|
|
1065
|
-
style={{
|
|
1066
|
-
width: '100%',
|
|
1067
|
-
}}
|
|
1068
|
-
/>
|
|
1069
|
-
<PCText
|
|
1070
|
-
size="sm"
|
|
1071
|
-
color="secondary"
|
|
1072
|
-
className="pc-filters-summary"
|
|
1073
|
-
style={{
|
|
1074
|
-
margin: 0,
|
|
1075
|
-
whiteSpace: 'nowrap',
|
|
1076
|
-
alignSelf: 'center',
|
|
1077
|
-
}}
|
|
1078
|
-
>
|
|
1079
|
-
{summaryText}
|
|
1080
|
-
</PCText>
|
|
1081
|
-
<div className="pc-export-button-responsive">
|
|
1082
|
-
<PCButton
|
|
1083
|
-
size="sm"
|
|
1084
|
-
variant="outline"
|
|
1085
|
-
onClick={() => setExportModal(true)}
|
|
1086
|
-
style={{
|
|
1087
|
-
whiteSpace: 'nowrap',
|
|
1088
|
-
width: '100%',
|
|
1089
|
-
}}
|
|
1090
|
-
>
|
|
1091
|
-
<ArrowUpToLine size={13} />
|
|
1092
|
-
<span>{t('export')}</span>
|
|
1093
|
-
</PCButton>
|
|
1094
|
-
</div>
|
|
1095
|
-
</div>
|
|
1096
|
-
</div>
|
|
1097
|
-
{isLoading ? (
|
|
1098
|
-
<ConsentManagerTableSkeleton />
|
|
1099
|
-
) : (
|
|
1100
|
-
<>
|
|
1101
|
-
<div className="pc-consent-desktop-view">
|
|
1102
|
-
{viewMode === 'product' ? (
|
|
1103
|
-
<AdvancedTable
|
|
1104
|
-
table={productTable}
|
|
1105
|
-
variant={variant}
|
|
1106
|
-
classNames={groupedTableClassNames}
|
|
1107
|
-
isLoading={isLoading}
|
|
1108
|
-
expandedComponent={(row) => {
|
|
1109
|
-
const cardKey = getCardKey(row.original);
|
|
1110
|
-
return (
|
|
1111
|
-
<ConsentManagerExpandedRow
|
|
1112
|
-
group={row.original}
|
|
1113
|
-
onModify={handleOpenModal}
|
|
1114
|
-
extraPurposes={extraPurposesByKey[cardKey]}
|
|
1115
|
-
hasMore={hasMoreByKey[cardKey] ?? row.original.has_more_purposes}
|
|
1116
|
-
isLoadingMore={loadingMoreByKey[cardKey]}
|
|
1117
|
-
onLoadMore={handleLoadMorePurposes}
|
|
1118
|
-
/>
|
|
1119
|
-
);
|
|
1120
|
-
}}
|
|
1121
|
-
/>
|
|
1122
|
-
) : (
|
|
1123
|
-
<AdvancedTable
|
|
1124
|
-
table={purposeTable}
|
|
1125
|
-
variant={variant}
|
|
1126
|
-
classNames={purposeTableClassNames}
|
|
1127
|
-
isLoading={isLoading}
|
|
1128
|
-
/>
|
|
1129
|
-
)}
|
|
1130
|
-
</div>
|
|
1131
|
-
|
|
1132
|
-
<div className="pc-consent-mobile-view">
|
|
1133
|
-
{viewMode === 'product' ? (
|
|
1134
|
-
<ConsentManagerProductCards
|
|
1135
|
-
groups={consentGroups}
|
|
1136
|
-
onModify={handleOpenModal}
|
|
1137
|
-
extraPurposesByKey={extraPurposesByKey}
|
|
1138
|
-
hasMoreByKey={hasMoreByKey}
|
|
1139
|
-
loadingMoreByKey={loadingMoreByKey}
|
|
1140
|
-
onLoadMore={handleLoadMorePurposes}
|
|
1141
|
-
cardKeyFor={getCardKey}
|
|
1142
|
-
/>
|
|
1143
|
-
) : (
|
|
1144
|
-
<ConsentManagerPurposeCards
|
|
1145
|
-
rows={consentRows}
|
|
1146
|
-
onModify={handleOpenModal}
|
|
1147
|
-
/>
|
|
1148
|
-
)}
|
|
1149
|
-
</div>
|
|
1150
|
-
</>
|
|
1151
|
-
)}
|
|
1152
|
-
|
|
1153
|
-
{viewMode === 'product' && (
|
|
1154
|
-
<div className="pc-consent-pagination-wrap">
|
|
1155
|
-
<AdvancedTablePagination table={productTable} />
|
|
1156
|
-
</div>
|
|
1157
|
-
)}
|
|
1158
|
-
</div>
|
|
1159
|
-
|
|
1160
|
-
<PCModal
|
|
1161
|
-
isOpen={exportModal}
|
|
1162
|
-
onClose={() => setExportModal(false)}
|
|
1163
|
-
size="sm"
|
|
1164
|
-
closeAriaLabel={t('closeModal')}
|
|
1165
|
-
title={
|
|
1166
|
-
<div style={{ minWidth: 0, flex: 1, paddingRight: getVar('--pc-spacing-sm') }}>
|
|
1167
|
-
<PCText size="base" weight="semibold" style={{ margin: 0, color: getVar('--pc-text-primary') }}>
|
|
1168
|
-
{t('exportConsentData')}
|
|
1169
|
-
</PCText>
|
|
1170
|
-
<PCText
|
|
1171
|
-
size="xs"
|
|
1172
|
-
color="secondary"
|
|
1173
|
-
style={{ marginTop: pcStyles.mtXs.marginTop, marginBottom: 0, lineHeight: 1.5 }}
|
|
1174
|
-
>
|
|
1175
|
-
{t('exportConsentDataSubtitle')}
|
|
1176
|
-
</PCText>
|
|
1177
|
-
</div>
|
|
1178
|
-
}
|
|
1179
|
-
footer={
|
|
1180
|
-
<div className="pc-modal-footer-actions">
|
|
1181
|
-
<PCButton variant="secondary" onClick={() => setExportModal(false)}>
|
|
1182
|
-
{t('cancel')}
|
|
1183
|
-
</PCButton>
|
|
1184
|
-
<PCButton variant="primary" onClick={handleExport}>
|
|
1185
|
-
{t('export')}
|
|
1186
|
-
</PCButton>
|
|
1187
|
-
</div>
|
|
1188
|
-
}
|
|
1189
|
-
>
|
|
1190
|
-
<div style={{ ...pcStyles.flex, ...pcStyles.flexCol, gap: pcStyles.gapSm.gap }}>
|
|
1191
|
-
<PCText size="sm" color="secondary" style={{ margin: 0, lineHeight: 1.6 }}>
|
|
1192
|
-
{t('exportingIncludesFilters')}
|
|
1193
|
-
</PCText>
|
|
1194
|
-
</div>
|
|
1195
|
-
</PCModal>
|
|
1196
|
-
|
|
1197
|
-
<ModifyConsentModal
|
|
1198
|
-
isOpen={isModalOpen}
|
|
1199
|
-
onClose={handleCloseModal}
|
|
1200
|
-
selectedRecord={selectedRecord}
|
|
1201
|
-
isLoading={isManageLoading}
|
|
1202
|
-
onManageConsent={handleManageConsent}
|
|
1203
|
-
/>
|
|
1204
|
-
</div>
|
|
1205
|
-
);
|
|
1206
|
-
}
|