Skip to content

Commit

Permalink
feat: display draft badge with warning if errorDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
ansmonjol committed Aug 26, 2024
1 parent be33aa6 commit 5df2138
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 89 deletions.
24 changes: 23 additions & 1 deletion src/components/customers/CustomerInvoicesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ gql`
name
applicableTimezone
}
errorDetails {
errorCode
errorDetails
}
...InvoiceForFinalizeInvoice
...InvoiceForUpdateInvoicePaymentStatus
}
Expand Down Expand Up @@ -198,7 +203,24 @@ export const CustomerInvoicesList: FC<CustomerInvoicesListProps> = ({
key: 'status',
minWidth: 80,
title: translate('text_63ac86d797f728a87b2f9fa7'),
content: ({ status }) => <Status {...invoiceStatusMapping({ status })} />,
content: ({ status, errorDetails }) => {
const hasTaxErrors =
!!errorDetails?.length &&
[InvoiceStatusTypeEnum.Draft, InvoiceStatusTypeEnum.Voided].includes(status)

return (
<Tooltip
placement="top-start"
disableHoverListener={!hasTaxErrors}
title={translate('text_1724674592260h33v56rycaw')}
>
<Status
{...invoiceStatusMapping({ status })}
endIcon={hasTaxErrors ? 'warning-unfilled' : undefined}
/>
</Tooltip>
)
},
},
{
key: 'number',
Expand Down
18 changes: 17 additions & 1 deletion src/components/invoices/InvoiceCustomerInfos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ gql`
status
paymentStatus
paymentDisputeLostAt
errorDetails {
errorCode
errorDetails
}
customer {
id
name
Expand Down Expand Up @@ -201,7 +205,19 @@ export const InvoiceCustomerInfos = memo(({ invoice }: InvoiceCustomerInfosProps
{translate('text_65269b6afe1fda4ad9bf672b')}
</Typography>
<Typography variant="body" color="grey700">
{invoice?.status && <Status {...invoiceStatusMapping({ status: invoice.status })} />}
{invoice?.status && (
<Status
{...invoiceStatusMapping({ status: invoice.status })}
endIcon={
!!invoice.errorDetails?.length &&
[InvoiceStatusTypeEnum.Draft, InvoiceStatusTypeEnum.Voided].includes(
invoice.status,
)
? 'warning-unfilled'
: undefined
}
/>
)}
</Typography>
</InfoLine>
<InfoLine>
Expand Down
19 changes: 17 additions & 2 deletions src/components/invoices/InvoicesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,23 @@ const InvoicesList = ({
key: 'status',
title: translate('text_63ac86d797f728a87b2f9fa7'),
minWidth: 80,
content: ({ status }) => {
return <Status {...invoiceStatusMapping({ status })} />
content: ({ status, errorDetails }) => {
const hasTaxErrors =
!!errorDetails?.length &&
[InvoiceStatusTypeEnum.Draft, InvoiceStatusTypeEnum.Voided].includes(status)

return (
<Tooltip
placement="top-start"
disableHoverListener={!hasTaxErrors}
title={translate('text_1724674592260h33v56rycaw')}
>
<Status
{...invoiceStatusMapping({ status })}
endIcon={hasTaxErrors ? 'warning-unfilled' : undefined}
/>
</Tooltip>
)
},
},
{
Expand Down
Loading

0 comments on commit 5df2138

Please sign in to comment.