@granto-umbrella/umbrella-components 3.0.29 → 3.0.31
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granto-umbrella/umbrella-components",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.31",
|
|
4
4
|
"description": "Umbrella Components for React",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -36,8 +36,10 @@
|
|
|
36
36
|
"@radix-ui/react-label": "^2.1.3",
|
|
37
37
|
"@radix-ui/react-popover": "^1.1.11",
|
|
38
38
|
"@radix-ui/react-radio-group": "^1.2.4",
|
|
39
|
+
"cpf-cnpj-validator": "^1.0.3",
|
|
39
40
|
"date-fns": "^4.1.0",
|
|
40
41
|
"lucide-react": "^0.488.0",
|
|
42
|
+
"make-mask": "^1.0.3",
|
|
41
43
|
"phosphor-react": "^1.4.1",
|
|
42
44
|
"radix": "^0.0.0",
|
|
43
45
|
"react": "^18.3.1",
|
|
@@ -76,7 +78,6 @@
|
|
|
76
78
|
"jest": "^29.7.0",
|
|
77
79
|
"jest-environment-jsdom": "^29.7.0",
|
|
78
80
|
"react-icons": "^5.4.0",
|
|
79
|
-
"storybook": "8.4.7",
|
|
80
81
|
"styled-components": "^6.1.19",
|
|
81
82
|
"ts-jest": "^29.2.5",
|
|
82
83
|
"typescript": "~5.6.2",
|
|
@@ -1,40 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { cnpj } from 'cpf-cnpj-validator';
|
|
3
|
+
import { format, parseISO } from 'date-fns';
|
|
3
4
|
import {
|
|
4
|
-
FileText,
|
|
5
|
-
CreditCard,
|
|
6
|
-
Download,
|
|
7
|
-
PlusCircle,
|
|
8
5
|
ChevronDown,
|
|
9
6
|
ChevronUp,
|
|
7
|
+
CreditCard,
|
|
8
|
+
Download,
|
|
9
|
+
FileText,
|
|
10
10
|
Loader2,
|
|
11
|
+
PlusCircle,
|
|
11
12
|
} from 'lucide-react';
|
|
13
|
+
import mask from 'make-mask';
|
|
14
|
+
import { ArrowCircleUpRight, Cube, FlowArrow, XCircle } from 'phosphor-react';
|
|
15
|
+
import React, { useState } from 'react';
|
|
16
|
+
|
|
17
|
+
import Pill from '../../atoms/Pill/Pill';
|
|
18
|
+
import { mapRemoteToTimeline } from '../../molecules/TimeLine/TimeLine.mapper';
|
|
19
|
+
import { TimelineModal } from '../../organisms/TimelineModal/TimelineModal';
|
|
20
|
+
import { ExcludeModal } from '../ExcludeModal';
|
|
21
|
+
import { RefuseModal } from '../RefuseModal';
|
|
12
22
|
import {
|
|
23
|
+
ActionButton,
|
|
24
|
+
Actions,
|
|
25
|
+
BodyRow,
|
|
13
26
|
CardContainer,
|
|
27
|
+
DropdownMenu,
|
|
28
|
+
DropdownWrapper,
|
|
14
29
|
HeaderRow,
|
|
15
|
-
InfoRow,
|
|
16
30
|
InfoLabel,
|
|
31
|
+
InfoRow,
|
|
32
|
+
InfoSubValue,
|
|
17
33
|
InfoValue,
|
|
18
|
-
Actions,
|
|
19
|
-
DropdownWrapper,
|
|
20
|
-
DropdownMenu,
|
|
21
34
|
MenuItemProps,
|
|
35
|
+
ProcessValue,
|
|
36
|
+
ProdValue,
|
|
22
37
|
StyledMenuItem,
|
|
23
38
|
Text,
|
|
24
|
-
BodyRow,
|
|
25
|
-
InfoSubValue,
|
|
26
39
|
TruncatedValue,
|
|
27
|
-
ProdValue,
|
|
28
|
-
ProcessValue,
|
|
29
|
-
ActionButton,
|
|
30
40
|
} from './InsuranceCard.styles';
|
|
31
|
-
import { ArrowCircleUpRight, Cube, XCircle, FlowArrow } from 'phosphor-react';
|
|
32
|
-
import { ExcludeModal } from '../ExcludeModal';
|
|
33
|
-
|
|
34
41
|
import { InsuranceCardProps, StatusVariant } from './InsuranceCard.types';
|
|
35
|
-
import { RefuseModal } from '../RefuseModal';
|
|
36
|
-
import Pill from '../../atoms/Pill/Pill';
|
|
37
|
-
import { TimelineModal } from '../../organisms/TimelineModal/TimelineModal';
|
|
38
42
|
|
|
39
43
|
export const InsuranceCard: React.FC<InsuranceCardProps> = ({
|
|
40
44
|
idGranto,
|
|
@@ -47,41 +51,118 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
|
|
|
47
51
|
statusVariant,
|
|
48
52
|
seguradoName,
|
|
49
53
|
seguradoCnpj,
|
|
54
|
+
product,
|
|
50
55
|
issuedDate,
|
|
51
56
|
totalValue,
|
|
52
57
|
processId,
|
|
53
58
|
activeIndex,
|
|
54
59
|
testId,
|
|
55
60
|
openCardId,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
showTimelineToggle,
|
|
67
|
-
toggleOpen,
|
|
68
|
-
handleClick,
|
|
69
|
-
isAllowedByRoles,
|
|
70
|
-
productTitle,
|
|
71
|
-
productDescription,
|
|
72
|
-
downloadFile,
|
|
73
|
-
searchCerts,
|
|
74
|
-
onEndorsementClick,
|
|
75
|
-
irParaContinuarEmissao,
|
|
76
|
-
abrirModalExcluirProposta,
|
|
77
|
-
fecharModalExclusao,
|
|
78
|
-
confirmarExclusao,
|
|
79
|
-
abrirModalRecusarProposta,
|
|
80
|
-
fecharModalRecusa,
|
|
81
|
-
confirmarRecusa,
|
|
61
|
+
setOpenCardId,
|
|
62
|
+
runQuery,
|
|
63
|
+
useDownloadAndSupport,
|
|
64
|
+
useDownloadFile,
|
|
65
|
+
useChangeOrderStageAsync,
|
|
66
|
+
useMyStore,
|
|
67
|
+
useQueryClient,
|
|
68
|
+
useGetTimeline,
|
|
69
|
+
useAuthStoreV2,
|
|
70
|
+
navigate,
|
|
82
71
|
}) => {
|
|
72
|
+
const [loadingItem, setLoadingItem] = useState<string | null>(null);
|
|
73
|
+
const [showRefuseModal, setShowRefuseModal] = useState(false);
|
|
74
|
+
const [showExcludeModal, setShowExcludeModal] = useState(false);
|
|
75
|
+
const [showTimeline, setShowTimeline] = useState(false);
|
|
76
|
+
const [timelineItems, setTimelineItems] = useState<
|
|
77
|
+
ReturnType<typeof mapRemoteToTimeline>
|
|
78
|
+
>([]);
|
|
79
|
+
const { isLoading: isTimelineLoading, refetch: fetchTimeline } =
|
|
80
|
+
useGetTimeline({ orderId: idOrder, insuranceId: idInsurance });
|
|
81
|
+
|
|
82
|
+
const showTimelineToggle = async () => {
|
|
83
|
+
const willOpen = !showTimeline;
|
|
84
|
+
|
|
85
|
+
if (willOpen && (!timelineItems || timelineItems.length === 0)) {
|
|
86
|
+
setLoadingItem('linha_do_tempo');
|
|
87
|
+
setShowTimeline(true);
|
|
88
|
+
try {
|
|
89
|
+
const { data: remote } = await fetchTimeline();
|
|
90
|
+
setTimelineItems(mapRemoteToTimeline(remote ?? []));
|
|
91
|
+
} catch (err) {
|
|
92
|
+
console.error('Falha ao carregar timeline', err);
|
|
93
|
+
} finally {
|
|
94
|
+
setLoadingItem(null);
|
|
95
|
+
}
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
setShowTimeline(willOpen);
|
|
100
|
+
};
|
|
101
|
+
|
|
83
102
|
const isOpen = openCardId === idOrder;
|
|
84
103
|
|
|
104
|
+
const toggleOpen = () => {
|
|
105
|
+
setOpenCardId(isOpen ? null : idOrder);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const handleClick = async (
|
|
109
|
+
key: string,
|
|
110
|
+
callback: () => Promise<void> | void
|
|
111
|
+
) => {
|
|
112
|
+
setLoadingItem(key);
|
|
113
|
+
await Promise.resolve(callback());
|
|
114
|
+
setLoadingItem(null);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const { isAllowedByRoles } = useAuthStoreV2();
|
|
118
|
+
|
|
119
|
+
const [productTitle, productDescription] = product;
|
|
120
|
+
|
|
121
|
+
const { downloadFile, searchCerts } = useDownloadFile(idOrder);
|
|
122
|
+
const { onEndorsementClick } = useDownloadAndSupport();
|
|
123
|
+
const mutateStageOrder = useChangeOrderStageAsync();
|
|
124
|
+
const { setData } = useMyStore();
|
|
125
|
+
const queryClient = useQueryClient();
|
|
126
|
+
|
|
127
|
+
const irParaContinuarEmissao = () => {
|
|
128
|
+
const stateData = idInsurance
|
|
129
|
+
? { idInsurance, isSupply }
|
|
130
|
+
: { idOrder, isSupply };
|
|
131
|
+
if (
|
|
132
|
+
statusLabel === 'Proposta recusada' ||
|
|
133
|
+
statusLabel === 'Proposta excluída'
|
|
134
|
+
) {
|
|
135
|
+
mutateStageOrder.mutateAsync(
|
|
136
|
+
{
|
|
137
|
+
id: idGranto,
|
|
138
|
+
newStage: 'IDLE',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
onSuccess: () => {
|
|
142
|
+
queryClient.invalidateQueries({ queryKey: ['orders'] });
|
|
143
|
+
},
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
navigate('/issue', { state: stateData });
|
|
148
|
+
|
|
149
|
+
setData({});
|
|
150
|
+
};
|
|
151
|
+
const abrirModalExcluirProposta = () => setShowExcludeModal(true);
|
|
152
|
+
const fecharModalExclusao = () => setShowExcludeModal(false);
|
|
153
|
+
|
|
154
|
+
const confirmarExclusao = () => {
|
|
155
|
+
runQuery();
|
|
156
|
+
fecharModalExclusao();
|
|
157
|
+
};
|
|
158
|
+
const abrirModalRecusarProposta = () => setShowRefuseModal(true);
|
|
159
|
+
const fecharModalRecusa = () => setShowRefuseModal(false);
|
|
160
|
+
|
|
161
|
+
const confirmarRecusa = () => {
|
|
162
|
+
runQuery();
|
|
163
|
+
fecharModalRecusa();
|
|
164
|
+
};
|
|
165
|
+
|
|
85
166
|
return (
|
|
86
167
|
<CardContainer
|
|
87
168
|
data-testid={testId}
|
|
@@ -108,7 +189,7 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
|
|
|
108
189
|
onClose={() => setShowTimeline(false)}
|
|
109
190
|
data={timelineItems}
|
|
110
191
|
loading={isTimelineLoading}
|
|
111
|
-
onRetry={
|
|
192
|
+
onRetry={fetchTimeline}
|
|
112
193
|
/>
|
|
113
194
|
<HeaderRow>
|
|
114
195
|
{isSupply && (
|
|
@@ -127,7 +208,14 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
|
|
|
127
208
|
<InfoRow>
|
|
128
209
|
<InfoLabel>Segurado</InfoLabel>
|
|
129
210
|
<TruncatedValue>{seguradoName}</TruncatedValue>
|
|
130
|
-
<InfoSubValue>
|
|
211
|
+
<InfoSubValue>
|
|
212
|
+
{mask(
|
|
213
|
+
seguradoCnpj,
|
|
214
|
+
cnpj.isValid(seguradoCnpj)
|
|
215
|
+
? '00.000.000/0000-00'
|
|
216
|
+
: '000.000.000-00'
|
|
217
|
+
)}
|
|
218
|
+
</InfoSubValue>
|
|
131
219
|
</InfoRow>
|
|
132
220
|
<InfoRow>
|
|
133
221
|
<InfoLabel>Produto</InfoLabel>
|
|
@@ -138,7 +226,7 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
|
|
|
138
226
|
<InfoLabel>
|
|
139
227
|
{activeIndex === 0 ? 'Iniciado em' : 'Emitido em'}
|
|
140
228
|
</InfoLabel>
|
|
141
|
-
<InfoValue>{issuedDate}</InfoValue>
|
|
229
|
+
<InfoValue>{format(parseISO(issuedDate), 'dd/MM/yyyy')}</InfoValue>
|
|
142
230
|
</InfoRow>
|
|
143
231
|
<InfoRow>
|
|
144
232
|
<InfoLabel>
|
|
@@ -149,14 +237,18 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
|
|
|
149
237
|
</InfoRow>
|
|
150
238
|
<InfoRow>
|
|
151
239
|
<InfoLabel>Processo</InfoLabel>
|
|
152
|
-
<ProcessValue>
|
|
240
|
+
<ProcessValue>
|
|
241
|
+
{processId
|
|
242
|
+
? mask(processId || '', '0000000-00.0000.0.00.0000')
|
|
243
|
+
: '-'}
|
|
244
|
+
</ProcessValue>
|
|
153
245
|
</InfoRow>
|
|
154
246
|
<Actions>
|
|
155
247
|
<DropdownWrapper>
|
|
156
248
|
<ActionButton
|
|
157
249
|
data-testid={`btn_minhas_emissoes_mais_informacoes_${processId}`}
|
|
158
250
|
id={`btn_minhas_emissoes_mais_informacoes_${processId}`}
|
|
159
|
-
onClick={
|
|
251
|
+
onClick={toggleOpen}
|
|
160
252
|
>
|
|
161
253
|
Mais informações{' '}
|
|
162
254
|
{isOpen ? <ChevronUp size={16} /> : <ChevronDown size={16} />}
|
|
@@ -174,7 +266,7 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
|
|
|
174
266
|
)
|
|
175
267
|
}
|
|
176
268
|
onClick={() =>
|
|
177
|
-
handleClick
|
|
269
|
+
handleClick('linha_do_tempo', showTimelineToggle)
|
|
178
270
|
}
|
|
179
271
|
>
|
|
180
272
|
Linha do tempo
|
|
@@ -190,9 +282,7 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
|
|
|
190
282
|
)
|
|
191
283
|
}
|
|
192
284
|
onClick={() =>
|
|
193
|
-
handleClick
|
|
194
|
-
irParaContinuarEmissao(idOrder)
|
|
195
|
-
)
|
|
285
|
+
handleClick('continuar_emissao', irParaContinuarEmissao)
|
|
196
286
|
}
|
|
197
287
|
>
|
|
198
288
|
Continuar emissão
|
|
@@ -209,9 +299,7 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
|
|
|
209
299
|
)
|
|
210
300
|
}
|
|
211
301
|
onClick={() =>
|
|
212
|
-
handleClick
|
|
213
|
-
downloadFile('MINUTE', 'true')
|
|
214
|
-
)
|
|
302
|
+
handleClick('minuta', () => downloadFile('MINUTE', true))
|
|
215
303
|
}
|
|
216
304
|
>
|
|
217
305
|
Baixar minuta
|
|
@@ -230,9 +318,7 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
|
|
|
230
318
|
)
|
|
231
319
|
}
|
|
232
320
|
onClick={() =>
|
|
233
|
-
handleClick
|
|
234
|
-
abrirModalRecusarProposta(idOrder)
|
|
235
|
-
)
|
|
321
|
+
handleClick('recusar_proposta', abrirModalRecusarProposta)
|
|
236
322
|
}
|
|
237
323
|
>
|
|
238
324
|
Recusar proposta
|
|
@@ -251,9 +337,7 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
|
|
|
251
337
|
)
|
|
252
338
|
}
|
|
253
339
|
onClick={() =>
|
|
254
|
-
handleClick
|
|
255
|
-
abrirModalExcluirProposta(idOrder)
|
|
256
|
-
)
|
|
340
|
+
handleClick('excluir_proposta', abrirModalExcluirProposta)
|
|
257
341
|
}
|
|
258
342
|
>
|
|
259
343
|
Excluir proposta
|
|
@@ -274,7 +358,7 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
|
|
|
274
358
|
)
|
|
275
359
|
}
|
|
276
360
|
onClick={() =>
|
|
277
|
-
handleClick
|
|
361
|
+
handleClick('linha_do_tempo', showTimelineToggle)
|
|
278
362
|
}
|
|
279
363
|
>
|
|
280
364
|
Linha do tempo
|
|
@@ -290,9 +374,7 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
|
|
|
290
374
|
)
|
|
291
375
|
}
|
|
292
376
|
onClick={() =>
|
|
293
|
-
handleClick
|
|
294
|
-
downloadFile('POLICY', 'true')
|
|
295
|
-
)
|
|
377
|
+
handleClick('apolice', () => downloadFile('POLICY', true))
|
|
296
378
|
}
|
|
297
379
|
>
|
|
298
380
|
Baixar apólice
|
|
@@ -308,7 +390,7 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
|
|
|
308
390
|
)
|
|
309
391
|
}
|
|
310
392
|
onClick={() =>
|
|
311
|
-
handleClick
|
|
393
|
+
handleClick('boleto', () => downloadFile('SLIP', true))
|
|
312
394
|
}
|
|
313
395
|
>
|
|
314
396
|
Baixar boleto
|
|
@@ -324,7 +406,9 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
|
|
|
324
406
|
)
|
|
325
407
|
}
|
|
326
408
|
onClick={() =>
|
|
327
|
-
handleClick
|
|
409
|
+
handleClick('certidoes', () =>
|
|
410
|
+
searchCerts(idInsurance!, idOrder)
|
|
411
|
+
)
|
|
328
412
|
}
|
|
329
413
|
>
|
|
330
414
|
Baixar certidões
|
|
@@ -340,8 +424,8 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
|
|
|
340
424
|
)
|
|
341
425
|
}
|
|
342
426
|
onClick={() =>
|
|
343
|
-
handleClick
|
|
344
|
-
onEndorsementClick(idInsurance!)
|
|
427
|
+
handleClick('endosso', () =>
|
|
428
|
+
onEndorsementClick('Umbrela Corp', idInsurance!)
|
|
345
429
|
)
|
|
346
430
|
}
|
|
347
431
|
>
|
|
@@ -3,53 +3,39 @@ export type StatusVariant = 'primary' | 'success' | 'warning' | 'danger';
|
|
|
3
3
|
|
|
4
4
|
export interface InsuranceCardProps {
|
|
5
5
|
idGranto: string;
|
|
6
|
-
idInterno: string;
|
|
7
6
|
idOrder: string;
|
|
8
7
|
idInsurance?: string;
|
|
8
|
+
idInterno: string;
|
|
9
9
|
isSupply: boolean;
|
|
10
|
-
hasMinute
|
|
10
|
+
hasMinute: boolean;
|
|
11
11
|
statusLabel: string;
|
|
12
|
-
statusVariant:
|
|
12
|
+
statusVariant: StatusVariant;
|
|
13
13
|
seguradoName: string;
|
|
14
14
|
seguradoCnpj: string;
|
|
15
|
-
product:
|
|
15
|
+
product: any;
|
|
16
16
|
issuedDate: string;
|
|
17
17
|
totalValue: string;
|
|
18
|
-
processId
|
|
19
|
-
activeIndex
|
|
18
|
+
processId?: string;
|
|
19
|
+
activeIndex: number;
|
|
20
20
|
testId?: string;
|
|
21
21
|
openCardId: string | null;
|
|
22
22
|
setOpenCardId: (id: string | null) => void;
|
|
23
23
|
runQuery: () => void;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
searchCerts: (idOrder: string) => void;
|
|
42
|
-
onEndorsementClick: (idOrder: string) => void;
|
|
43
|
-
mutateStageOrder: (idOrder: string, stage: string) => Promise<void>;
|
|
44
|
-
setData: (data: any) => void;
|
|
45
|
-
queryClient: any;
|
|
46
|
-
irParaContinuarEmissao: (idOrder: string) => void;
|
|
47
|
-
abrirModalExcluirProposta: (idOrder: string) => void;
|
|
48
|
-
fecharModalExclusao: () => void;
|
|
49
|
-
confirmarExclusao: () => Promise<void>;
|
|
50
|
-
abrirModalRecusarProposta: (idOrder: string) => void;
|
|
51
|
-
fecharModalRecusa: () => void;
|
|
52
|
-
confirmarRecusa: () => Promise<void>;
|
|
53
|
-
handleClick?: (value: string, callback: () => void) => void;
|
|
54
|
-
isAllowedByRoles?: any;
|
|
24
|
+
useDownloadAndSupport: any;
|
|
25
|
+
useDownloadFile: any;
|
|
26
|
+
useChangeOrderStageAsync: any;
|
|
27
|
+
useMyStore: any;
|
|
28
|
+
useQueryClient: any;
|
|
29
|
+
useGetTimeline: any;
|
|
30
|
+
useAuthStoreV2: any;
|
|
31
|
+
navigate: any;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface MenuItemProps {
|
|
35
|
+
icon: React.ReactNode;
|
|
36
|
+
danger?: boolean;
|
|
37
|
+
children: React.ReactNode;
|
|
38
|
+
onClick?: () => void;
|
|
39
|
+
id?: string;
|
|
40
|
+
'data-testid'?: string;
|
|
55
41
|
}
|