@redacto.io/consent-sdk-react 4.0.0 → 5.1.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/CHANGELOG.md +19 -1
- package/LICENSE +176 -0
- package/README.md +98 -1
- package/dist/index.js +231 -96
- package/dist/index.mjs +231 -96
- package/dist/privacy-center.d.mts +649 -0
- package/dist/privacy-center.d.ts +649 -0
- package/dist/privacy-center.js +20824 -0
- package/dist/privacy-center.mjs +20789 -0
- package/package.json +47 -3
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +6 -4
- package/src/RedactoNoticeConsent/api/index.ts +2 -0
- package/src/RedactoNoticeConsent/api/types.ts +2 -0
- package/src/RedactoNoticeConsent/components/DigiLockerCallback.tsx +128 -62
- package/src/RedactoNoticeConsent/language-codes.ts +97 -0
- package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx +0 -3
- package/src/RedactoNoticeConsentInline/api/index.ts +0 -1
- package/src/RedactoPrivacyCenter/PrivacyCenterActivityPage.tsx +19 -0
- package/src/RedactoPrivacyCenter/PrivacyCenterCaseDetailsPage.tsx +154 -0
- package/src/RedactoPrivacyCenter/PrivacyCenterConsentManagerPage.tsx +17 -0
- package/src/RedactoPrivacyCenter/PrivacyCenterFormPage.tsx +79 -0
- package/src/RedactoPrivacyCenter/PrivacyCenterHomePage.tsx +30 -0
- package/src/RedactoPrivacyCenter/PrivacyCenterLayout.tsx +173 -0
- package/src/RedactoPrivacyCenter/RedactoPrivacyCenter.tsx +55 -0
- package/src/RedactoPrivacyCenter/api/actions.ts +476 -0
- package/src/RedactoPrivacyCenter/api/client.ts +524 -0
- package/src/RedactoPrivacyCenter/api/config.ts +33 -0
- package/src/RedactoPrivacyCenter/api/fetcher.ts +181 -0
- package/src/RedactoPrivacyCenter/api/upload.ts +93 -0
- package/src/RedactoPrivacyCenter/assets/character.svg +31 -0
- package/src/RedactoPrivacyCenter/assets/fileAttach.svg +9 -0
- package/src/RedactoPrivacyCenter/assets/greenTick.svg +4 -0
- package/src/RedactoPrivacyCenter/assets/mail.svg +3 -0
- package/src/RedactoPrivacyCenter/assets/poweredByRedacto.svg +9 -0
- package/src/RedactoPrivacyCenter/assets/sentImg.svg +9 -0
- package/src/RedactoPrivacyCenter/assets/uploadFileIcon.svg +9 -0
- package/src/RedactoPrivacyCenter/components/ActivitiesList.tsx +272 -0
- package/src/RedactoPrivacyCenter/components/CaseDetails/AttachmentCard.tsx +38 -0
- package/src/RedactoPrivacyCenter/components/CaseDetails/ChatBubble.tsx +31 -0
- package/src/RedactoPrivacyCenter/components/CaseDetails/DocumentRequestCard.tsx +73 -0
- package/src/RedactoPrivacyCenter/components/CaseDetails/MessageComposer.tsx +87 -0
- package/src/RedactoPrivacyCenter/components/CaseDetails/MessageItem.tsx +95 -0
- package/src/RedactoPrivacyCenter/components/CaseDetails/MessagesTab.tsx +147 -0
- package/src/RedactoPrivacyCenter/components/CaseDetails/RequestDetailsTab.tsx +171 -0
- package/src/RedactoPrivacyCenter/components/CaseDetails/StatusEvent.tsx +23 -0
- package/src/RedactoPrivacyCenter/components/CaseDetails/useFileUpload.ts +116 -0
- package/src/RedactoPrivacyCenter/components/CaseDetails/useMessagePolling.ts +36 -0
- package/src/RedactoPrivacyCenter/components/CaseDetails/utils.ts +56 -0
- package/src/RedactoPrivacyCenter/components/CaseDetailsModal.tsx +469 -0
- package/src/RedactoPrivacyCenter/components/CaseHistory.tsx +426 -0
- package/src/RedactoPrivacyCenter/components/ConsentManager.tsx +732 -0
- package/src/RedactoPrivacyCenter/components/ConsentManagerColumns.tsx +238 -0
- package/src/RedactoPrivacyCenter/components/ConsentManagerConstants.ts +7 -0
- package/src/RedactoPrivacyCenter/components/ConsentManagerTableSkeleton.tsx +155 -0
- package/src/RedactoPrivacyCenter/components/DataRequest/CorrectionDataSection.tsx +189 -0
- package/src/RedactoPrivacyCenter/components/DataRequest/GrievanceDataSection.tsx +118 -0
- package/src/RedactoPrivacyCenter/components/DataRequest/NominationDataSection.tsx +66 -0
- package/src/RedactoPrivacyCenter/components/DataRequest/PurposeSelectionSection.tsx +304 -0
- package/src/RedactoPrivacyCenter/components/Form.tsx +1596 -0
- package/src/RedactoPrivacyCenter/components/GrievanceTable.tsx +174 -0
- package/src/RedactoPrivacyCenter/components/GrievanceTablePagination.tsx +337 -0
- package/src/RedactoPrivacyCenter/components/ModifyConsentModal.tsx +330 -0
- package/src/RedactoPrivacyCenter/components/Pagination.tsx +140 -0
- package/src/RedactoPrivacyCenter/components/PrivacyCenterLayout.tsx +304 -0
- package/src/RedactoPrivacyCenter/components/RequestSubmit.tsx +232 -0
- package/src/RedactoPrivacyCenter/components/SideMenuBarPC/SideBarPC.tsx +475 -0
- package/src/RedactoPrivacyCenter/components/SideMenuBarPC/SideMenuPC.tsx +408 -0
- package/src/RedactoPrivacyCenter/components/SideMenuBarPC/constants.tsx +42 -0
- package/src/RedactoPrivacyCenter/components/SideMenuBarPC/menuItemsPC.tsx +1 -0
- package/src/RedactoPrivacyCenter/components/SideMenuBarPC/types.ts +40 -0
- package/src/RedactoPrivacyCenter/components/SideMenuBarPC/utils.ts +38 -0
- package/src/RedactoPrivacyCenter/components/ThemeTransitionOverlay.tsx +85 -0
- package/src/RedactoPrivacyCenter/components/activitiesColumns.tsx +141 -0
- package/src/RedactoPrivacyCenter/components/caseHistoryColumns.tsx +159 -0
- package/src/RedactoPrivacyCenter/components/constant.ts +16 -0
- package/src/RedactoPrivacyCenter/components/types.ts +76 -0
- package/src/RedactoPrivacyCenter/components/utils.tsx +10 -0
- package/src/RedactoPrivacyCenter/config/routes.ts +9 -0
- package/src/RedactoPrivacyCenter/config/table.ts +25 -0
- package/src/RedactoPrivacyCenter/context/AuthContext.tsx +137 -0
- package/src/RedactoPrivacyCenter/context/BaseUrlContext.tsx +41 -0
- package/src/RedactoPrivacyCenter/context/LocaleContext.tsx +11 -0
- package/src/RedactoPrivacyCenter/context/NavigationContext.tsx +96 -0
- package/src/RedactoPrivacyCenter/context/OrganizationContext.tsx +30 -0
- package/src/RedactoPrivacyCenter/context/PageChromeContext.tsx +60 -0
- package/src/RedactoPrivacyCenter/context/theme.tsx +127 -0
- package/src/RedactoPrivacyCenter/context/types.ts +14 -0
- package/src/RedactoPrivacyCenter/lib/api.ts +566 -0
- package/src/RedactoPrivacyCenter/lib/consent-manager/utils.tsx +63 -0
- package/src/RedactoPrivacyCenter/lib/constants.ts +161 -0
- package/src/RedactoPrivacyCenter/lib/i18n.ts +81 -0
- package/src/RedactoPrivacyCenter/lib/locales.ts +105 -0
- package/src/RedactoPrivacyCenter/lib/queries.ts +134 -0
- package/src/RedactoPrivacyCenter/lib/types.ts +531 -0
- package/src/RedactoPrivacyCenter/lib/useCurrentLanguage.ts +37 -0
- package/src/RedactoPrivacyCenter/lib/utils.ts +626 -0
- package/src/RedactoPrivacyCenter/locales/as/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/bho/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/bn/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/brx/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/doi/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/en/translation.json +255 -0
- package/src/RedactoPrivacyCenter/locales/gom/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/gu/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/hi/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/kn/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/ks/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/mai/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/ml/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/mni-Mtei/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/mr/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/ne/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/or/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/pa/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/sa/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/sat/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/sd/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/ta/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/te/translation.json +280 -0
- package/src/RedactoPrivacyCenter/locales/ur/translation.json +280 -0
- package/src/RedactoPrivacyCenter/styles/base.css +117 -0
- package/src/RedactoPrivacyCenter/styles/injectStyles.ts +1725 -0
- package/src/RedactoPrivacyCenter/styles/pcStyles.ts +813 -0
- package/src/RedactoPrivacyCenter/styles/responsive.ts +138 -0
- package/src/RedactoPrivacyCenter/styles/variables.css +133 -0
- package/src/RedactoPrivacyCenter/table/AdvancedTable.tsx +367 -0
- package/src/RedactoPrivacyCenter/table/AdvancedTablePagination.tsx +476 -0
- package/src/RedactoPrivacyCenter/table/index.ts +2 -0
- package/src/RedactoPrivacyCenter/types/images.d.ts +29 -0
- package/src/RedactoPrivacyCenter/ui/Footer.tsx +75 -0
- package/src/RedactoPrivacyCenter/ui/FormBlockWrapper.tsx +54 -0
- package/src/RedactoPrivacyCenter/ui/PCAccordion.tsx +93 -0
- package/src/RedactoPrivacyCenter/ui/PCActionIcon.tsx +47 -0
- package/src/RedactoPrivacyCenter/ui/PCAvatar.tsx +69 -0
- package/src/RedactoPrivacyCenter/ui/PCBadge.tsx +48 -0
- package/src/RedactoPrivacyCenter/ui/PCButton.tsx +77 -0
- package/src/RedactoPrivacyCenter/ui/PCCheckbox.tsx +55 -0
- package/src/RedactoPrivacyCenter/ui/PCCollapse.tsx +107 -0
- package/src/RedactoPrivacyCenter/ui/PCEmpty.tsx +35 -0
- package/src/RedactoPrivacyCenter/ui/PCInput.tsx +132 -0
- package/src/RedactoPrivacyCenter/ui/PCLoader.tsx +31 -0
- package/src/RedactoPrivacyCenter/ui/PCModal.tsx +106 -0
- package/src/RedactoPrivacyCenter/ui/PCPopover.tsx +173 -0
- package/src/RedactoPrivacyCenter/ui/PCSelect.tsx +387 -0
- package/src/RedactoPrivacyCenter/ui/PCTable.tsx +149 -0
- package/src/RedactoPrivacyCenter/ui/PCText.tsx +41 -0
- package/src/RedactoPrivacyCenter/ui/PCTextarea.tsx +43 -0
- package/src/RedactoPrivacyCenter/ui/PCTitle.tsx +37 -0
- package/src/RedactoPrivacyCenter/ui/PCTooltip.tsx +119 -0
- package/src/RedactoPrivacyCenter/ui/SimpleBar.tsx +25 -0
- package/src/RedactoPrivacyCenter/ui/StatusBadge.tsx +53 -0
- package/src/RedactoPrivacyCenter/ui/ThemeToggle.tsx +72 -0
- package/src/RedactoPrivacyCenter/ui/index.ts +18 -0
- package/src/RedactoPrivacyCenter/utils/cn.ts +28 -0
- package/src/RedactoPrivacyCenter/utils/date.ts +48 -0
- package/src/RedactoPrivacyCenter/utils/status.ts +111 -0
- package/src/RedactoPrivacyCenter/utils/toast.ts +130 -0
- package/src/privacy-center.ts +108 -0
- package/tsconfig.json +2 -0
- package/tsup.config.ts +16 -1
- package/.turbo/turbo-build.log +0 -21
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { PCText, PCTooltip, PCBadge } from '../ui';
|
|
4
|
+
import { pcStyles } from '../styles/pcStyles';
|
|
5
|
+
import { Smartphone, LaptopMinimal } from 'lucide-react';
|
|
6
|
+
import { createColumnHelper } from '@tanstack/react-table';
|
|
7
|
+
import dayjs from 'dayjs';
|
|
8
|
+
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
9
|
+
import { ConsentStatusEnum } from '../lib/types';
|
|
10
|
+
import type { UserConsent } from '../lib/types';
|
|
11
|
+
import { formatDateTime } from '../lib/consent-manager/utils';
|
|
12
|
+
import type { UseConsentManagerColumnsProps } from './types';
|
|
13
|
+
|
|
14
|
+
dayjs.extend(relativeTime);
|
|
15
|
+
|
|
16
|
+
const columnHelper = createColumnHelper<UserConsent>();
|
|
17
|
+
|
|
18
|
+
export const useConsentManagerColumns = ({
|
|
19
|
+
onOpenModal,
|
|
20
|
+
}: UseConsentManagerColumnsProps) => {
|
|
21
|
+
const { t } = useTranslation();
|
|
22
|
+
return useMemo(
|
|
23
|
+
() => [
|
|
24
|
+
columnHelper.accessor('purpose', {
|
|
25
|
+
id: 'purpose',
|
|
26
|
+
size: 300,
|
|
27
|
+
minSize: 200,
|
|
28
|
+
header: t('purpose'),
|
|
29
|
+
cell: (info) => (
|
|
30
|
+
<div style={{ width: '100%', minWidth: '150px' }}>
|
|
31
|
+
<PCText size="sm" weight="medium">{info.getValue()}</PCText>
|
|
32
|
+
<PCText
|
|
33
|
+
size="sm"
|
|
34
|
+
color="secondary"
|
|
35
|
+
style={{
|
|
36
|
+
display: '-webkit-box',
|
|
37
|
+
WebkitLineClamp: 2,
|
|
38
|
+
WebkitBoxOrient: 'vertical',
|
|
39
|
+
overflow: 'hidden',
|
|
40
|
+
wordBreak: 'break-word',
|
|
41
|
+
fontSize: '0.75rem',
|
|
42
|
+
maxWidth: '400px',
|
|
43
|
+
}}
|
|
44
|
+
title={info.row.original.purpose_description}
|
|
45
|
+
>
|
|
46
|
+
{info.row.original.purpose_description}
|
|
47
|
+
</PCText>
|
|
48
|
+
</div>
|
|
49
|
+
),
|
|
50
|
+
enableSorting: false,
|
|
51
|
+
enableColumnFilter: false,
|
|
52
|
+
}),
|
|
53
|
+
columnHelper.accessor('product_name', {
|
|
54
|
+
id: 'product',
|
|
55
|
+
size: 150,
|
|
56
|
+
minSize: 100,
|
|
57
|
+
header: t('product'),
|
|
58
|
+
cell: (info) => (
|
|
59
|
+
<div style={{ width: '100%', minWidth: '80px' }}>
|
|
60
|
+
<PCText size="sm" weight="medium">{info.getValue() || '-'}</PCText>
|
|
61
|
+
{info.row.original.product_description && (
|
|
62
|
+
<PCText
|
|
63
|
+
size="sm"
|
|
64
|
+
color="secondary"
|
|
65
|
+
style={{
|
|
66
|
+
display: '-webkit-box',
|
|
67
|
+
WebkitLineClamp: 2,
|
|
68
|
+
WebkitBoxOrient: 'vertical',
|
|
69
|
+
overflow: 'hidden',
|
|
70
|
+
wordBreak: 'break-word',
|
|
71
|
+
fontSize: '0.75rem',
|
|
72
|
+
}}
|
|
73
|
+
title={info.row.original.product_description}
|
|
74
|
+
>
|
|
75
|
+
{info.row.original.product_description}
|
|
76
|
+
</PCText>
|
|
77
|
+
)}
|
|
78
|
+
</div>
|
|
79
|
+
),
|
|
80
|
+
enableSorting: false,
|
|
81
|
+
enableColumnFilter: false,
|
|
82
|
+
}),
|
|
83
|
+
columnHelper.accessor('status', {
|
|
84
|
+
id: 'status',
|
|
85
|
+
size: 120,
|
|
86
|
+
minSize: 90,
|
|
87
|
+
header: t('status'),
|
|
88
|
+
cell: (info) => {
|
|
89
|
+
const status = info.getValue();
|
|
90
|
+
const getStatusName = (status: string) => {
|
|
91
|
+
if (status === ConsentStatusEnum.ACTIVE) {
|
|
92
|
+
return t('statusActive');
|
|
93
|
+
} else if (status === ConsentStatusEnum.WITHDRAWN) {
|
|
94
|
+
return t('statusWithdrawn');
|
|
95
|
+
} else if (status === ConsentStatusEnum.EXPIRED) {
|
|
96
|
+
return t('statusExpired');
|
|
97
|
+
} else if (status === ConsentStatusEnum.DECLINED) {
|
|
98
|
+
return t('statusDeclined');
|
|
99
|
+
} else {
|
|
100
|
+
return status;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const getStatusVariant = (status: string): 'success' | 'error' | 'warning' | 'info' | 'secondary' => {
|
|
105
|
+
if (status === ConsentStatusEnum.ACTIVE) return 'success';
|
|
106
|
+
if (status === ConsentStatusEnum.WITHDRAWN) return 'error';
|
|
107
|
+
if (status === ConsentStatusEnum.EXPIRED) return 'warning';
|
|
108
|
+
if (status === ConsentStatusEnum.DECLINED) return 'warning';
|
|
109
|
+
return 'secondary';
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<div style={{ ...pcStyles.flex, ...pcStyles.itemsCenter, ...pcStyles.justifyStart, width: '100%' }}>
|
|
114
|
+
<PCBadge variant={getStatusVariant(status)} size="sm" className="pc-status-badge">
|
|
115
|
+
{getStatusName(status)}
|
|
116
|
+
</PCBadge>
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
},
|
|
120
|
+
enableSorting: false,
|
|
121
|
+
enableColumnFilter: false,
|
|
122
|
+
}),
|
|
123
|
+
columnHelper.accessor('given_date', {
|
|
124
|
+
id: 'given_date',
|
|
125
|
+
size: 180,
|
|
126
|
+
minSize: 140,
|
|
127
|
+
header: t('givenDate'),
|
|
128
|
+
cell: (info) => {
|
|
129
|
+
const timestamp = info.getValue();
|
|
130
|
+
const date = dayjs(timestamp);
|
|
131
|
+
const formattedDateTime = date.format('MMM D, YYYY [at] h:mm A');
|
|
132
|
+
const relativeTimeText = date.fromNow();
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<PCTooltip
|
|
136
|
+
content={date.format('MMMM D, YYYY [at] h:mm:ss A')}
|
|
137
|
+
placement="top"
|
|
138
|
+
>
|
|
139
|
+
<div style={{
|
|
140
|
+
...pcStyles.flex,
|
|
141
|
+
...pcStyles.flexCol,
|
|
142
|
+
minWidth: '120px',
|
|
143
|
+
gap: '0.125rem',
|
|
144
|
+
}}>
|
|
145
|
+
<PCText size="sm" weight="medium" color="primary">
|
|
146
|
+
{formattedDateTime}
|
|
147
|
+
</PCText>
|
|
148
|
+
<PCText size="sm" color="secondary" style={{ fontSize: '0.75rem' }}>
|
|
149
|
+
{relativeTimeText}
|
|
150
|
+
</PCText>
|
|
151
|
+
</div>
|
|
152
|
+
</PCTooltip>
|
|
153
|
+
);
|
|
154
|
+
},
|
|
155
|
+
enableSorting: false,
|
|
156
|
+
enableColumnFilter: false,
|
|
157
|
+
}),
|
|
158
|
+
columnHelper.accessor('valid_till', {
|
|
159
|
+
id: 'valid_till',
|
|
160
|
+
minSize: 100,
|
|
161
|
+
header: t('validTill'),
|
|
162
|
+
cell: (info) => {
|
|
163
|
+
const status = info.row.original.status;
|
|
164
|
+
if (
|
|
165
|
+
status === ConsentStatusEnum.DECLINED ||
|
|
166
|
+
status === ConsentStatusEnum.WITHDRAWN
|
|
167
|
+
) {
|
|
168
|
+
return '-';
|
|
169
|
+
}
|
|
170
|
+
const validTillValue = info.getValue();
|
|
171
|
+
if (status === ConsentStatusEnum.ACTIVE && (validTillValue === null || validTillValue === undefined)) {
|
|
172
|
+
return <PCText size="sm">{t('untilWithdrawalNoExpiry')}</PCText>;
|
|
173
|
+
}
|
|
174
|
+
return <PCText size="sm">{formatDateTime(info.getValue())}</PCText>;
|
|
175
|
+
},
|
|
176
|
+
enableSorting: false,
|
|
177
|
+
enableColumnFilter: false,
|
|
178
|
+
}),
|
|
179
|
+
columnHelper.accessor('method', {
|
|
180
|
+
id: 'method',
|
|
181
|
+
size: 120,
|
|
182
|
+
minSize: 80,
|
|
183
|
+
header: t('method'),
|
|
184
|
+
cell: (info) => {
|
|
185
|
+
const method = info.getValue();
|
|
186
|
+
const iconMap: Record<string, JSX.Element> = {
|
|
187
|
+
MOBILE: <Smartphone size={12} style={{ marginRight: '0.25rem', color: '#6b7280' }} />,
|
|
188
|
+
WEB: <LaptopMinimal size={12} style={{ marginRight: '0.25rem', color: '#6b7280' }} />,
|
|
189
|
+
};
|
|
190
|
+
return (
|
|
191
|
+
<div style={{
|
|
192
|
+
...pcStyles.flex,
|
|
193
|
+
...pcStyles.itemsCenter,
|
|
194
|
+
minWidth: '60px',
|
|
195
|
+
}}>
|
|
196
|
+
{iconMap[method] || null}
|
|
197
|
+
<PCText size="sm">{method}</PCText>
|
|
198
|
+
</div>
|
|
199
|
+
);
|
|
200
|
+
},
|
|
201
|
+
enableSorting: false,
|
|
202
|
+
enableColumnFilter: false,
|
|
203
|
+
}),
|
|
204
|
+
|
|
205
|
+
columnHelper.display({
|
|
206
|
+
id: 'action',
|
|
207
|
+
size: 100,
|
|
208
|
+
minSize: 70,
|
|
209
|
+
header: t('action'),
|
|
210
|
+
enableSorting: false,
|
|
211
|
+
enableColumnFilter: false,
|
|
212
|
+
cell: ({ row }) => {
|
|
213
|
+
const isDisabled =
|
|
214
|
+
row.original.status === ConsentStatusEnum.DECLINED;
|
|
215
|
+
|
|
216
|
+
return (
|
|
217
|
+
<button
|
|
218
|
+
style={{
|
|
219
|
+
fontSize: pcStyles.textSm.fontSize,
|
|
220
|
+
fontWeight: pcStyles.fontWeightMedium.fontWeight,
|
|
221
|
+
cursor: isDisabled ? 'not-allowed' : 'pointer',
|
|
222
|
+
color: isDisabled ? '#9ca3af' : '#4F87FF',
|
|
223
|
+
background: 'none',
|
|
224
|
+
border: 'none',
|
|
225
|
+
padding: 0,
|
|
226
|
+
}}
|
|
227
|
+
onClick={() => onOpenModal(row.original)}
|
|
228
|
+
disabled={isDisabled}
|
|
229
|
+
>
|
|
230
|
+
{t('modifyButton')}
|
|
231
|
+
</button>
|
|
232
|
+
);
|
|
233
|
+
},
|
|
234
|
+
}),
|
|
235
|
+
],
|
|
236
|
+
[onOpenModal, t]
|
|
237
|
+
);
|
|
238
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { SKELETON_ROW_COUNT } from './ConsentManagerConstants';
|
|
2
|
+
import { pcStyles } from '../styles/pcStyles';
|
|
3
|
+
|
|
4
|
+
const getVar = (varName: string): string => `var(${varName})`;
|
|
5
|
+
|
|
6
|
+
export const ConsentManagerTableSkeleton = () => {
|
|
7
|
+
return (
|
|
8
|
+
<div style={{
|
|
9
|
+
borderRadius: getVar('--pc-border-radius-md'),
|
|
10
|
+
border: `1px solid ${getVar('--pc-border-color')}`,
|
|
11
|
+
backgroundColor: getVar('--pc-bg-primary'),
|
|
12
|
+
}}>
|
|
13
|
+
{/* Table Header */}
|
|
14
|
+
<div style={{
|
|
15
|
+
borderBottom: `1px solid ${getVar('--pc-border-color')}`,
|
|
16
|
+
backgroundColor: getVar('--pc-bg-secondary'),
|
|
17
|
+
}}>
|
|
18
|
+
<div style={{
|
|
19
|
+
display: 'grid',
|
|
20
|
+
gridTemplateColumns: 'repeat(7, 1fr)',
|
|
21
|
+
gap: getVar('--pc-spacing-md'),
|
|
22
|
+
paddingLeft: getVar('--pc-spacing-lg'),
|
|
23
|
+
paddingRight: getVar('--pc-spacing-lg'),
|
|
24
|
+
paddingTop: getVar('--pc-spacing-md'),
|
|
25
|
+
paddingBottom: getVar('--pc-spacing-md'),
|
|
26
|
+
}} className="pc-grid-responsive">
|
|
27
|
+
{Array.from({ length: 7 }).map((_, i) => (
|
|
28
|
+
<div
|
|
29
|
+
key={i}
|
|
30
|
+
style={{
|
|
31
|
+
height: '1rem',
|
|
32
|
+
width: '6rem',
|
|
33
|
+
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
34
|
+
borderRadius: getVar('--pc-border-radius-md'),
|
|
35
|
+
backgroundColor: getVar('--pc-bg-tertiary'),
|
|
36
|
+
}}
|
|
37
|
+
/>
|
|
38
|
+
))}
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
{/* Table Rows */}
|
|
43
|
+
{Array.from({ length: SKELETON_ROW_COUNT }).map((_, index) => (
|
|
44
|
+
<div
|
|
45
|
+
key={index}
|
|
46
|
+
style={{
|
|
47
|
+
borderBottom: `1px solid ${getVar('--pc-border-color')}`,
|
|
48
|
+
backgroundColor: getVar('--pc-bg-primary'),
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
<div style={{
|
|
52
|
+
display: 'grid',
|
|
53
|
+
gridTemplateColumns: 'repeat(7, 1fr)',
|
|
54
|
+
gap: getVar('--pc-spacing-md'),
|
|
55
|
+
paddingLeft: getVar('--pc-spacing-lg'),
|
|
56
|
+
paddingRight: getVar('--pc-spacing-lg'),
|
|
57
|
+
paddingTop: getVar('--pc-spacing-md'),
|
|
58
|
+
paddingBottom: getVar('--pc-spacing-md'),
|
|
59
|
+
}} className="pc-grid-responsive">
|
|
60
|
+
{/* Purpose */}
|
|
61
|
+
<div style={{ ...pcStyles.flex, ...pcStyles.flexCol, ...pcStyles.gapXs }}>
|
|
62
|
+
<div style={{
|
|
63
|
+
height: '1rem',
|
|
64
|
+
width: '8rem',
|
|
65
|
+
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
66
|
+
borderRadius: getVar('--pc-border-radius-md'),
|
|
67
|
+
backgroundColor: getVar('--pc-bg-tertiary'),
|
|
68
|
+
}} />
|
|
69
|
+
<div style={{
|
|
70
|
+
height: '0.75rem',
|
|
71
|
+
width: '12rem',
|
|
72
|
+
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
73
|
+
borderRadius: getVar('--pc-border-radius-md'),
|
|
74
|
+
backgroundColor: getVar('--pc-bg-tertiary'),
|
|
75
|
+
}} />
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
{/* Product */}
|
|
79
|
+
<div style={{ ...pcStyles.flex, ...pcStyles.flexCol, ...pcStyles.gapXs }}>
|
|
80
|
+
<div style={{
|
|
81
|
+
height: '1rem',
|
|
82
|
+
width: '6rem',
|
|
83
|
+
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
84
|
+
borderRadius: getVar('--pc-border-radius-md'),
|
|
85
|
+
backgroundColor: getVar('--pc-bg-tertiary'),
|
|
86
|
+
}} />
|
|
87
|
+
<div style={{
|
|
88
|
+
height: '0.75rem',
|
|
89
|
+
width: '8rem',
|
|
90
|
+
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
91
|
+
borderRadius: getVar('--pc-border-radius-md'),
|
|
92
|
+
backgroundColor: getVar('--pc-bg-tertiary'),
|
|
93
|
+
}} />
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
{/* Status */}
|
|
97
|
+
<div style={{ ...pcStyles.flex, ...pcStyles.itemsCenter }}>
|
|
98
|
+
<div style={{
|
|
99
|
+
height: '1.5rem',
|
|
100
|
+
width: '5rem',
|
|
101
|
+
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
102
|
+
borderRadius: '9999px',
|
|
103
|
+
backgroundColor: getVar('--pc-bg-tertiary'),
|
|
104
|
+
}} />
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
{/* Given Date */}
|
|
108
|
+
<div style={{ ...pcStyles.flex, ...pcStyles.itemsCenter }}>
|
|
109
|
+
<div style={{
|
|
110
|
+
height: '1rem',
|
|
111
|
+
width: '6rem',
|
|
112
|
+
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
113
|
+
borderRadius: getVar('--pc-border-radius-md'),
|
|
114
|
+
backgroundColor: getVar('--pc-bg-tertiary'),
|
|
115
|
+
}} />
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
{/* Valid till */}
|
|
119
|
+
<div style={{ ...pcStyles.flex, ...pcStyles.itemsCenter }}>
|
|
120
|
+
<div style={{
|
|
121
|
+
height: '1rem',
|
|
122
|
+
width: '6rem',
|
|
123
|
+
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
124
|
+
borderRadius: getVar('--pc-border-radius-md'),
|
|
125
|
+
backgroundColor: getVar('--pc-bg-tertiary'),
|
|
126
|
+
}} />
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
{/* Method */}
|
|
130
|
+
<div style={{ ...pcStyles.flex, ...pcStyles.itemsCenter }}>
|
|
131
|
+
<div style={{
|
|
132
|
+
height: '1rem',
|
|
133
|
+
width: '4rem',
|
|
134
|
+
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
135
|
+
borderRadius: getVar('--pc-border-radius-md'),
|
|
136
|
+
backgroundColor: getVar('--pc-bg-tertiary'),
|
|
137
|
+
}} />
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
{/* Action */}
|
|
141
|
+
<div style={{ ...pcStyles.flex, ...pcStyles.itemsCenter }}>
|
|
142
|
+
<div style={{
|
|
143
|
+
height: '1.5rem',
|
|
144
|
+
width: '4rem',
|
|
145
|
+
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
146
|
+
borderRadius: getVar('--pc-border-radius-md'),
|
|
147
|
+
backgroundColor: getVar('--pc-bg-tertiary'),
|
|
148
|
+
}} />
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
))}
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
};
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { PCCheckbox, PCInput } from '../../ui';
|
|
2
|
+
import { pcStyles } from '../../styles/pcStyles';
|
|
3
|
+
import type { DataElement } from '../../lib/types';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
|
|
6
|
+
const getVar = (varName: string): string => `var(${varName})`;
|
|
7
|
+
|
|
8
|
+
export default function CorrectionDataSection({
|
|
9
|
+
dataElements,
|
|
10
|
+
selected,
|
|
11
|
+
setSelected,
|
|
12
|
+
correctionValues,
|
|
13
|
+
setCorrectionValues,
|
|
14
|
+
isTranslating = false,
|
|
15
|
+
}: {
|
|
16
|
+
dataElements: DataElement[];
|
|
17
|
+
selected: string[];
|
|
18
|
+
setSelected: (values: string[]) => void;
|
|
19
|
+
correctionValues: Record<string, { current: string; updated: string }>;
|
|
20
|
+
setCorrectionValues: (
|
|
21
|
+
values: Record<string, { current: string; updated: string }>
|
|
22
|
+
) => void;
|
|
23
|
+
isTranslating?: boolean;
|
|
24
|
+
}) {
|
|
25
|
+
const { t } = useTranslation();
|
|
26
|
+
|
|
27
|
+
const handleSelectAll = (checked: boolean) => {
|
|
28
|
+
setSelected(checked ? dataElements.map((el) => el.name) : []);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const handleToggle = (name: string, checked: boolean) => {
|
|
32
|
+
setSelected(
|
|
33
|
+
checked ? [...selected, name] : selected.filter((n) => n !== name)
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const getElementByName = (name: string) =>
|
|
38
|
+
dataElements.find((el) => el.name === name);
|
|
39
|
+
|
|
40
|
+
if (isTranslating) {
|
|
41
|
+
return (
|
|
42
|
+
<div>
|
|
43
|
+
<div style={{ marginBottom: '0.375rem', paddingLeft: pcStyles.pxMd.paddingLeft, paddingRight: pcStyles.pxMd.paddingRight }}>
|
|
44
|
+
<div style={{ height: '1rem', width: '10rem', animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite', borderRadius: pcStyles.borderRadiusMd, backgroundColor: getVar('--pc-bg-tertiary'), marginBottom: '0.375rem' }}></div>
|
|
45
|
+
<div style={{ height: '1rem', width: '6rem', animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite', borderRadius: pcStyles.borderRadiusMd, backgroundColor: getVar('--pc-bg-tertiary'), marginBottom: '0.5rem' }}></div>
|
|
46
|
+
</div>
|
|
47
|
+
<div style={{
|
|
48
|
+
backgroundColor: getVar('--pc-bg-secondary'),
|
|
49
|
+
borderRadius: pcStyles.borderRadiusMd,
|
|
50
|
+
padding: getVar('--pc-spacing-sm'),
|
|
51
|
+
border: `1px solid ${getVar('--pc-border-color')}`,
|
|
52
|
+
}}>
|
|
53
|
+
{[1, 2, 3, 4].map((skeletonIndex) => (
|
|
54
|
+
<div key={skeletonIndex} style={{ marginBottom: skeletonIndex < 4 ? getVar('--pc-spacing-xs') : 0, ...pcStyles.flex, ...pcStyles.itemsCenter, ...pcStyles.gapSm }}>
|
|
55
|
+
<div style={{ height: '1rem', width: '1rem', animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite', borderRadius: pcStyles.borderRadiusMd, backgroundColor: getVar('--pc-bg-tertiary') }}></div>
|
|
56
|
+
<div style={{ height: '1rem', width: '8rem', animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite', borderRadius: pcStyles.borderRadiusMd, backgroundColor: getVar('--pc-bg-tertiary') }}></div>
|
|
57
|
+
</div>
|
|
58
|
+
))}
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
66
|
+
<div style={{ ...pcStyles.flex, ...pcStyles.flexCol, gap: getVar('--pc-spacing-xs') }}>
|
|
67
|
+
<p style={{
|
|
68
|
+
margin: 0,
|
|
69
|
+
fontSize: pcStyles.textXs.fontSize,
|
|
70
|
+
color: getVar('--pc-text-secondary'),
|
|
71
|
+
}}>
|
|
72
|
+
{t('selectFieldsToUpdate')}
|
|
73
|
+
</p>
|
|
74
|
+
<div style={{
|
|
75
|
+
backgroundColor: getVar('--pc-bg-secondary'),
|
|
76
|
+
borderRadius: pcStyles.borderRadiusMd,
|
|
77
|
+
padding: getVar('--pc-spacing-sm'),
|
|
78
|
+
border: `1px solid ${getVar('--pc-border-color')}`,
|
|
79
|
+
}}>
|
|
80
|
+
<PCCheckbox
|
|
81
|
+
label={t('selectAll')}
|
|
82
|
+
size="sm"
|
|
83
|
+
checked={
|
|
84
|
+
dataElements.length > 0 && selected.length === dataElements.length
|
|
85
|
+
}
|
|
86
|
+
onChange={(e) => handleSelectAll(e.target.checked)}
|
|
87
|
+
labelClassName="text-sm font-medium"
|
|
88
|
+
style={{ marginBottom: getVar('--pc-spacing-xl') }}
|
|
89
|
+
/>
|
|
90
|
+
<div style={{
|
|
91
|
+
display: 'grid',
|
|
92
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(200px, 1fr))',
|
|
93
|
+
gap: getVar('--pc-spacing-md'),
|
|
94
|
+
}}>
|
|
95
|
+
{dataElements.map((element) => (
|
|
96
|
+
<PCCheckbox
|
|
97
|
+
key={element.uuid}
|
|
98
|
+
label={element.name}
|
|
99
|
+
size="sm"
|
|
100
|
+
checked={selected.includes(element.name)}
|
|
101
|
+
onChange={(e) => handleToggle(element.name, e.target.checked)}
|
|
102
|
+
labelClassName="text-sm capitalize"
|
|
103
|
+
/>
|
|
104
|
+
))}
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
{selected.length > 0 && (
|
|
109
|
+
<div style={{
|
|
110
|
+
marginTop: getVar('--pc-spacing-md'),
|
|
111
|
+
paddingTop: getVar('--pc-spacing-md'),
|
|
112
|
+
borderTop: `1px solid ${getVar('--pc-border-color')}`,
|
|
113
|
+
}}>
|
|
114
|
+
<p style={{
|
|
115
|
+
marginBottom: getVar('--pc-spacing-sm'),
|
|
116
|
+
fontSize: pcStyles.textSm.fontSize,
|
|
117
|
+
fontWeight: pcStyles.fontWeightMedium.fontWeight,
|
|
118
|
+
color: getVar('--pc-text-primary'),
|
|
119
|
+
}}>
|
|
120
|
+
<span style={{ color: getVar('--pc-error') }}>*</span>{' '}
|
|
121
|
+
{t('enterCorrectValue')}
|
|
122
|
+
</p>
|
|
123
|
+
<div style={{
|
|
124
|
+
display: 'grid',
|
|
125
|
+
gridTemplateColumns: 'repeat(1, 1fr)',
|
|
126
|
+
gap: getVar('--pc-spacing-sm'),
|
|
127
|
+
}}>
|
|
128
|
+
{selected.map((name) => {
|
|
129
|
+
const field = getElementByName(name);
|
|
130
|
+
return (
|
|
131
|
+
<div key={name} style={{
|
|
132
|
+
padding: getVar('--pc-spacing-sm'),
|
|
133
|
+
backgroundColor: getVar('--pc-bg-secondary'),
|
|
134
|
+
borderRadius: pcStyles.borderRadiusSm,
|
|
135
|
+
}}>
|
|
136
|
+
<label style={{
|
|
137
|
+
marginBottom: getVar('--pc-spacing-xs'),
|
|
138
|
+
display: 'block',
|
|
139
|
+
fontSize: pcStyles.textSm.fontSize,
|
|
140
|
+
fontWeight: pcStyles.fontWeightMedium.fontWeight,
|
|
141
|
+
color: getVar('--pc-text-primary'),
|
|
142
|
+
}}>
|
|
143
|
+
{field?.name}
|
|
144
|
+
</label>
|
|
145
|
+
<div style={{
|
|
146
|
+
display: 'grid',
|
|
147
|
+
gridTemplateColumns: 'repeat(1, 1fr)',
|
|
148
|
+
gap: getVar('--pc-spacing-xs'),
|
|
149
|
+
}}>
|
|
150
|
+
<PCInput
|
|
151
|
+
placeholder={t('currentValuePlaceholder')}
|
|
152
|
+
size="sm"
|
|
153
|
+
required
|
|
154
|
+
value={correctionValues[name]?.current || ''}
|
|
155
|
+
onChange={(e) =>
|
|
156
|
+
setCorrectionValues({
|
|
157
|
+
...correctionValues,
|
|
158
|
+
[name]: {
|
|
159
|
+
...correctionValues[name],
|
|
160
|
+
current: e.target.value,
|
|
161
|
+
},
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
/>
|
|
165
|
+
<PCInput
|
|
166
|
+
placeholder={t('updatedValuePlaceholder')}
|
|
167
|
+
size="sm"
|
|
168
|
+
required
|
|
169
|
+
value={correctionValues[name]?.updated || ''}
|
|
170
|
+
onChange={(e) =>
|
|
171
|
+
setCorrectionValues({
|
|
172
|
+
...correctionValues,
|
|
173
|
+
[name]: {
|
|
174
|
+
...correctionValues[name],
|
|
175
|
+
updated: e.target.value,
|
|
176
|
+
},
|
|
177
|
+
})
|
|
178
|
+
}
|
|
179
|
+
/>
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
);
|
|
183
|
+
})}
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
)}
|
|
187
|
+
</>
|
|
188
|
+
);
|
|
189
|
+
}
|