-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update net payment term and display payment due date
- Loading branch information
Showing
14 changed files
with
790 additions
and
38 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
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
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
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
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
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
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
81 changes: 81 additions & 0 deletions
81
src/components/customers/DeleteCustomerNetPaymentTermDialog.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,81 @@ | ||
import { gql } from '@apollo/client' | ||
import { forwardRef } from 'react' | ||
|
||
import { Typography, DialogRef } from '~/components/designSystem' | ||
import { | ||
useDeleteCustomerNetPaymentTermMutation, | ||
DeleteCustomerNetPaymentTermFragment, | ||
} from '~/generated/graphql' | ||
import { WarningDialog, WarningDialogRef } from '~/components/WarningDialog' | ||
import { useInternationalization } from '~/hooks/core/useInternationalization' | ||
import { addToast } from '~/core/apolloClient' | ||
|
||
gql` | ||
fragment DeleteCustomerNetPaymentTerm on Customer { | ||
id | ||
externalId | ||
name | ||
netPaymentTerm | ||
} | ||
mutation deleteCustomerNetPaymentTerm($input: UpdateCustomerInput!) { | ||
updateCustomer(input: $input) { | ||
id | ||
...DeleteCustomerNetPaymentTerm | ||
} | ||
} | ||
` | ||
|
||
export interface DeleteOrganizationNetPaymentTermDialogRef extends WarningDialogRef {} | ||
|
||
interface DeleteOrganizationNetPaymentTermDialogProps { | ||
customer: DeleteCustomerNetPaymentTermFragment | ||
} | ||
|
||
export const DeleteOrganizationNetPaymentTermDialog = forwardRef< | ||
DialogRef, | ||
DeleteOrganizationNetPaymentTermDialogProps | ||
>(({ customer }: DeleteOrganizationNetPaymentTermDialogProps, ref) => { | ||
const [deleteCustomerNetPaymentTerm] = useDeleteCustomerNetPaymentTermMutation({ | ||
onCompleted(data) { | ||
if (data && data.updateCustomer) { | ||
addToast({ | ||
message: translate('text_64c7a89b6c67eb6c98898357'), | ||
severity: 'success', | ||
}) | ||
} | ||
}, | ||
}) | ||
const { translate } = useInternationalization() | ||
|
||
return ( | ||
<WarningDialog | ||
ref={ref} | ||
title={translate('text_64c7a89b6c67eb6c988980db')} | ||
description={ | ||
<Typography | ||
html={translate('text_64c7a89b6c67eb6c988980f9', { | ||
customerName: `<span class="line-break-anywhere">${customer.name}</span>`, | ||
})} | ||
/> | ||
} | ||
onContinue={async () => | ||
await deleteCustomerNetPaymentTerm({ | ||
variables: { | ||
input: { | ||
id: customer.id, | ||
netPaymentTerm: null, | ||
// TODO: API should not require those fields on customer update | ||
// To be tackled as improvement | ||
externalId: customer.externalId, | ||
name: customer.name || '', | ||
}, | ||
}, | ||
}) | ||
} | ||
continueText={translate('text_64c7a89b6c67eb6c98898133')} | ||
/> | ||
) | ||
}) | ||
|
||
DeleteOrganizationNetPaymentTermDialog.displayName = 'DeleteOrganizationNetPaymentTermDialog' |
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
Oops, something went wrong.