-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable setting invoice skipping at 0 for both organizations and custo…
…mers
- Loading branch information
1 parent
599cffe
commit b6bfb55
Showing
6 changed files
with
632 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/components/customers/DeleteCustomerFinalizeZeroAmountInvoiceDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { gql } from '@apollo/client' | ||
import { forwardRef } from 'react' | ||
|
||
import { DialogRef, Typography } from '~/components/designSystem' | ||
import { WarningDialog, WarningDialogRef } from '~/components/WarningDialog' | ||
import { addToast } from '~/core/apolloClient' | ||
import { | ||
DeleteCustomerFinalizeZeroAmountInvoiceFragment, | ||
FinalizeZeroAmountInvoiceEnum, | ||
useDeleteCustomerFinalizeZeroAmountInvoiceMutation, | ||
} from '~/generated/graphql' | ||
import { useInternationalization } from '~/hooks/core/useInternationalization' | ||
|
||
gql` | ||
fragment DeleteCustomerFinalizeZeroAmountInvoice on Customer { | ||
id | ||
externalId | ||
name | ||
finalizeZeroAmountInvoice | ||
} | ||
mutation deleteCustomerFinalizeZeroAmountInvoice($input: UpdateCustomerInput!) { | ||
updateCustomer(input: $input) { | ||
id | ||
...DeleteCustomerFinalizeZeroAmountInvoice | ||
} | ||
} | ||
` | ||
|
||
export interface DeleteCustomerFinalizeZeroAmountInvoiceDialogRef extends WarningDialogRef {} | ||
|
||
interface DeleteCustomerFinalizeZeroAmountInvoiceDialogProps { | ||
customer: DeleteCustomerFinalizeZeroAmountInvoiceFragment | ||
} | ||
|
||
export const DeleteCustomerFinalizeZeroAmountInvoiceDialog = forwardRef< | ||
DialogRef, | ||
DeleteCustomerFinalizeZeroAmountInvoiceDialogProps | ||
>(({ customer }: DeleteCustomerFinalizeZeroAmountInvoiceDialogProps, ref) => { | ||
const { translate } = useInternationalization() | ||
|
||
const [deleteCustomerFinalizeZeroAmountInvoice] = | ||
useDeleteCustomerFinalizeZeroAmountInvoiceMutation({ | ||
onCompleted(data) { | ||
if (data && data.updateCustomer) { | ||
addToast({ | ||
message: translate('text_17255496712882bspi9zp0ii'), | ||
severity: 'success', | ||
}) | ||
} | ||
}, | ||
}) | ||
|
||
return ( | ||
<WarningDialog | ||
ref={ref} | ||
title={translate('text_1725549671288txz7z4m4qrf')} | ||
description={ | ||
<Typography | ||
html={translate('text_17255496712882gafqyniqpc', { | ||
customerName: customer?.name, | ||
})} | ||
/> | ||
} | ||
onContinue={async () => | ||
await deleteCustomerFinalizeZeroAmountInvoice({ | ||
variables: { | ||
input: { | ||
id: customer?.id, | ||
externalId: customer?.externalId, | ||
name: customer?.name || '', | ||
finalizeZeroAmountInvoice: FinalizeZeroAmountInvoiceEnum.Inherit, | ||
}, | ||
}, | ||
}) | ||
} | ||
continueText={translate('text_63aa085d28b8510cd46441a5')} | ||
/> | ||
) | ||
}) | ||
|
||
DeleteCustomerFinalizeZeroAmountInvoiceDialog.displayName = | ||
'DeleteCustomerFinalizeZeroAmountInvoice' |
Oops, something went wrong.