diff --git a/.changeset/beige-steaks-deliver.md b/.changeset/beige-steaks-deliver.md new file mode 100644 index 000000000..b149ac0a7 --- /dev/null +++ b/.changeset/beige-steaks-deliver.md @@ -0,0 +1,5 @@ +--- +'@monite/sdk-react': patch +--- + +feat(DEV-13151): expand tax value check for non-vat supported countries diff --git a/.changeset/config.json b/.changeset/config.json index 1928a6c3a..9a94bfa17 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -5,7 +5,7 @@ "fixed": [["@monite/sdk-react", "@monite/sdk-api"]], "linked": [], "access": "public", - "baseBranch": "origin/main", + "baseBranch": "origin/dev", "updateInternalDependencies": "patch", "ignore": ["sdk-demo-with-nextjs-and-clerk-auth"] } diff --git a/.changeset/hot-games-cheer.md b/.changeset/hot-games-cheer.md new file mode 100644 index 000000000..a845151cc --- /dev/null +++ b/.changeset/hot-games-cheer.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/.changeset/odd-horses-rest.md b/.changeset/odd-horses-rest.md new file mode 100644 index 000000000..5358cddc3 --- /dev/null +++ b/.changeset/odd-horses-rest.md @@ -0,0 +1,23 @@ +--- +'@monite/sdk-react': minor +--- + +introduce Custom Tabs for `` + +### Description + +Implemented the ability to configure custom tabs for Receivables using MUI. Users can now select the specific tabs they +need, while backward compatibility is maintained. By default, the standard tabs Invoices, Quotes, and Credit Notes are +displayed. + +### Breaking Changes + +The `` component interface has changed. Instead of using `ReceivablesTableTabEnum` for the active +tab, you now need to pass a `number` representing the tab index. Additionally, the default tab indices have been +updated: + +- **Invoices**: 0 (previously 1) +- **Quotes**: 1 (previously 0) +- **Credit Notes**: 2 (unchanged) + +Please update any existing integrations to reflect these changes. diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 000000000..2f758cafc --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,16 @@ +{ + "mode": "pre", + "tag": "beta", + "initialVersions": { + "@team-monite/e2e": "1.0.1", + "sdk-demo-with-nextjs-and-clerk-auth": "0.1.0", + "@team-monite/eslint-plugin": "2.0.3", + "@team-monite/rollup-config": "1.2.0", + "@monite/sdk-api": "3.17.0", + "@team-monite/sdk-demo": "1.9.0", + "@monite/sdk-drop-in": "1.7.0", + "@monite/sdk-react": "3.17.0", + "@team-monite/sdk-themes": "0.2.1" + }, + "changesets": [] +} diff --git a/.changeset/strong-parents-admire.md b/.changeset/strong-parents-admire.md new file mode 100644 index 000000000..339c1b5ff --- /dev/null +++ b/.changeset/strong-parents-admire.md @@ -0,0 +1,5 @@ +--- +'@monite/sdk-react': minor +--- + +feat: introduce icon wrapper component for all close icons to be cusotmisable from theme props diff --git a/.changeset/three-planets-drum.md b/.changeset/three-planets-drum.md new file mode 100644 index 000000000..f34b89287 --- /dev/null +++ b/.changeset/three-planets-drum.md @@ -0,0 +1,5 @@ +--- +'@monite/sdk-react': patch +--- + +hide email section for upload bill dropdown diff --git a/.changeset/tricky-keys-smoke.md b/.changeset/tricky-keys-smoke.md new file mode 100644 index 000000000..df8696b7a --- /dev/null +++ b/.changeset/tricky-keys-smoke.md @@ -0,0 +1,5 @@ +--- +'@monite/sdk-react': minor +--- + +feat: add integration of payment flow with iframe modal diff --git a/examples/with-nextjs-and-clerk-auth/src/components/NavigationMenu/NavigationList.tsx b/examples/with-nextjs-and-clerk-auth/src/components/NavigationMenu/NavigationList.tsx index b88477838..74e182167 100644 --- a/examples/with-nextjs-and-clerk-auth/src/components/NavigationMenu/NavigationList.tsx +++ b/examples/with-nextjs-and-clerk-auth/src/components/NavigationMenu/NavigationList.tsx @@ -71,9 +71,6 @@ export const NavigationList = () => { }> {t(i18n)`Invoice Design`} - }> - {t(i18n)`Message Templates`} - }> {t(i18n)`Email Templates`} diff --git a/examples/with-nextjs-and-clerk-auth/src/locales/en/messages.po b/examples/with-nextjs-and-clerk-auth/src/locales/en/messages.po index 0ed5a8f8d..e6ba6d76e 100644 --- a/examples/with-nextjs-and-clerk-auth/src/locales/en/messages.po +++ b/examples/with-nextjs-and-clerk-auth/src/locales/en/messages.po @@ -44,7 +44,7 @@ msgstr "Dark Mode" msgid "Dashboard" msgstr "Dashboard" -#: src/components/NavigationMenu/NavigationList.tsx:78 +#: src/components/NavigationMenu/NavigationList.tsx:75 msgid "Email Templates" msgstr "Email Templates" @@ -52,7 +52,7 @@ msgstr "Email Templates" msgid "English" msgstr "English" -#: src/components/NavigationMenu/NavigationList.tsx:97 +#: src/components/NavigationMenu/NavigationList.tsx:94 msgid "Get Help" msgstr "Get Help" @@ -86,8 +86,8 @@ msgid "Material UI" msgstr "Material UI" #: src/components/NavigationMenu/NavigationList.tsx:75 -msgid "Message Templates" -msgstr "Message Templates" +#~ msgid "Message Templates" +#~ msgstr "Message Templates" #: src/components/ThemeSelect/ThemeSelect.tsx:45 #: src/components/ThemeSelect/useThemeSelect.ts:19 @@ -134,7 +134,7 @@ msgstr "Roles & Approvals" #~ msgid "Subtotal" #~ msgstr "Subtotal" -#: src/components/NavigationMenu/NavigationList.tsx:81 +#: src/components/NavigationMenu/NavigationList.tsx:78 msgid "Tags" msgstr "Tags" diff --git a/packages/sdk-react/mui-styles.d.ts b/packages/sdk-react/mui-styles.d.ts index d18de70d2..f8d63e05f 100644 --- a/packages/sdk-react/mui-styles.d.ts +++ b/packages/sdk-react/mui-styles.d.ts @@ -7,6 +7,7 @@ import { type MonitePayableStatusChipProps } from '@/components/payables/Payable import { type MoniteInvoiceRecurrenceIterationStatusChipProps } from '@/components/receivables/InvoiceRecurrenceIterationStatusChip/InvoiceRecurrenceIterationStatusChip'; import { type MoniteInvoiceRecurrenceStatusChipProps } from '@/components/receivables/InvoiceRecurrenceStatusChip/InvoiceRecurrenceStatusChip'; import { type MoniteInvoiceStatusChipProps } from '@/components/receivables/InvoiceStatusChip/InvoiceStatusChip'; +import { type MoniteIconWrapperProps } from '@/ui/iconWrapper/IconWrapper'; import { type MoniteTablePaginationProps } from '@/ui/table/TablePagination'; import { ComponentsOverrides, @@ -43,6 +44,7 @@ declare module '@mui/material/styles' { MoniteCounterpartStatusChip: 'root'; MoniteApprovalStatusChip: 'root'; MonitePayableTable: 'never'; + MoniteReceivablesTable: 'never'; } /** @@ -59,6 +61,8 @@ declare module '@mui/material/styles' { MoniteCounterpartStatusChip: Partial; MonitePayableTable: Partial; MoniteApprovalStatusChip: Partial; + MoniteReceivablesTable: Partial; + MoniteIconWrapper: Partial; } interface MoniteOptions { @@ -81,5 +85,7 @@ declare module '@mui/material/styles' { MoniteInvoiceRecurrenceIterationStatusChip?: ComponentType<'MoniteInvoiceRecurrenceIterationStatusChip'>; MoniteCounterpartStatusChip?: ComponentType<'MoniteCounterpartStatusChip'>; MoniteApprovalStatusChip?: ComponentType<'MoniteApprovalStatusChip'>; + MoniteReceivablesTable?: ComponentType<'MoniteReceivablesTable'>; + MoniteIconWrapper?: ComponentType<'MoniteIconWrapper'>; } } diff --git a/packages/sdk-react/src/components/approvalPolicies/ApprovalPolicyDetails/ApprovalPolicyDetailsFormAdvanced/ApprovalPolicyDetailsFormAdvanced.tsx b/packages/sdk-react/src/components/approvalPolicies/ApprovalPolicyDetails/ApprovalPolicyDetailsFormAdvanced/ApprovalPolicyDetailsFormAdvanced.tsx index a6c124633..1e3a9f6dc 100644 --- a/packages/sdk-react/src/components/approvalPolicies/ApprovalPolicyDetails/ApprovalPolicyDetailsFormAdvanced/ApprovalPolicyDetailsFormAdvanced.tsx +++ b/packages/sdk-react/src/components/approvalPolicies/ApprovalPolicyDetails/ApprovalPolicyDetailsFormAdvanced/ApprovalPolicyDetailsFormAdvanced.tsx @@ -8,6 +8,7 @@ import { useApprovalPolicyDetails } from '@/components/approvalPolicies/Approval import { RHFTextField } from '@/components/RHF/RHFTextField'; import { MoniteScopedProviders } from '@/core/context/MoniteScopedProviders'; import { useIsActionAllowed } from '@/core/queries/usePermissions'; +import { IconWrapper } from '@/ui/iconWrapper'; import { yupResolver } from '@hookform/resolvers/yup'; import type { I18n } from '@lingui/core'; import { t } from '@lingui/macro'; @@ -21,7 +22,6 @@ import { DialogContent, DialogTitle, Divider, - IconButton, Link, Typography, } from '@mui/material'; @@ -135,14 +135,14 @@ export const ApprovalPolicyDetailsFormAdvancedBase = ({ : t(i18n)`Create Approval Policy`} {dialogContext?.isDialogContent && ( - - + )} diff --git a/packages/sdk-react/src/components/approvalPolicies/ApprovalPolicyDetails/ApprovalPolicyForm/ApprovalPolicyForm.tsx b/packages/sdk-react/src/components/approvalPolicies/ApprovalPolicyDetails/ApprovalPolicyForm/ApprovalPolicyForm.tsx index fab27772d..92b1496a4 100644 --- a/packages/sdk-react/src/components/approvalPolicies/ApprovalPolicyDetails/ApprovalPolicyForm/ApprovalPolicyForm.tsx +++ b/packages/sdk-react/src/components/approvalPolicies/ApprovalPolicyDetails/ApprovalPolicyForm/ApprovalPolicyForm.tsx @@ -20,6 +20,7 @@ import { RHFTextField } from '@/components/RHF/RHFTextField'; import { useMoniteContext } from '@/core/context/MoniteContext'; import { useCurrencies } from '@/core/hooks'; import { MoniteCurrency } from '@/ui/Currency'; +import { IconWrapper } from '@/ui/iconWrapper'; import { yupResolver } from '@hookform/resolvers/yup'; import { Trans } from '@lingui/macro'; import { t } from '@lingui/macro'; @@ -33,7 +34,6 @@ import { DialogContent, Divider, Grid, - IconButton, MenuItem, Stack, Typography, @@ -643,14 +643,14 @@ export const ApprovalPolicyForm = ({ )} {dialogContext?.isDialogContent && ( - - + )} diff --git a/packages/sdk-react/src/components/approvalPolicies/ApprovalPolicyDetails/ApprovalPolicyView/ApprovalPolicyView.tsx b/packages/sdk-react/src/components/approvalPolicies/ApprovalPolicyDetails/ApprovalPolicyView/ApprovalPolicyView.tsx index ca9ba87ee..1c4b3208a 100644 --- a/packages/sdk-react/src/components/approvalPolicies/ApprovalPolicyDetails/ApprovalPolicyView/ApprovalPolicyView.tsx +++ b/packages/sdk-react/src/components/approvalPolicies/ApprovalPolicyDetails/ApprovalPolicyView/ApprovalPolicyView.tsx @@ -13,6 +13,7 @@ import { } from '@/components/approvalPolicies/useApprovalPolicyTrigger'; import { getCounterpartName } from '@/components/counterparts/helpers'; import { useMoniteContext } from '@/core/context/MoniteContext'; +import { IconWrapper } from '@/ui/iconWrapper'; import { t, Trans } from '@lingui/macro'; import { useLingui } from '@lingui/react'; import CloseIcon from '@mui/icons-material/Close'; @@ -24,7 +25,6 @@ import { DialogActions, DialogContent, Divider, - IconButton, List, ListItem, Typography, @@ -225,14 +225,14 @@ export const ApprovalPolicyView = ({ {approvalPolicy?.name} {dialogContext?.isDialogContent && ( - - + )} diff --git a/packages/sdk-react/src/components/approvalPolicies/ApprovalPolicyDetails/ExistingApprovalPolicyDetailsAdvanced/ExistingApprovalPolicyDetailsAdvanced.tsx b/packages/sdk-react/src/components/approvalPolicies/ApprovalPolicyDetails/ExistingApprovalPolicyDetailsAdvanced/ExistingApprovalPolicyDetailsAdvanced.tsx index 6905b51cb..c9fd826ca 100644 --- a/packages/sdk-react/src/components/approvalPolicies/ApprovalPolicyDetails/ExistingApprovalPolicyDetailsAdvanced/ExistingApprovalPolicyDetailsAdvanced.tsx +++ b/packages/sdk-react/src/components/approvalPolicies/ApprovalPolicyDetails/ExistingApprovalPolicyDetailsAdvanced/ExistingApprovalPolicyDetailsAdvanced.tsx @@ -2,6 +2,7 @@ import { components } from '@/api'; import { useDialog } from '@/components'; import { MoniteScopedProviders } from '@/core/context/MoniteScopedProviders'; import { useIsActionAllowed } from '@/core/queries/usePermissions'; +import { IconWrapper } from '@/ui/iconWrapper'; import { t } from '@lingui/macro'; import { useLingui } from '@lingui/react'; import CloseIcon from '@mui/icons-material/Close'; @@ -14,7 +15,6 @@ import { DialogContent, DialogTitle, Divider, - IconButton, Link, Typography, Paper, @@ -67,14 +67,14 @@ const ExistingApprovalPolicyDetailsAdvancedBase = ({ {approvalPolicy?.name} {dialogContext?.isDialogContent && ( - - + )} diff --git a/packages/sdk-react/src/components/approvalRequests/ApprovalRequestsTable/ApprovalRequestsTable.test.tsx b/packages/sdk-react/src/components/approvalRequests/ApprovalRequestsTable/ApprovalRequestsTable.test.tsx index 25824adc2..dab81828f 100644 --- a/packages/sdk-react/src/components/approvalRequests/ApprovalRequestsTable/ApprovalRequestsTable.test.tsx +++ b/packages/sdk-react/src/components/approvalRequests/ApprovalRequestsTable/ApprovalRequestsTable.test.tsx @@ -59,7 +59,8 @@ describe('ApprovalRequestTable', () => { }); describe('# Public API', () => { - test('should trigger a `onRowClick` callback when click on a row', async () => { + //TODO: fix this test after we solve problem with multiple spinners on waitUntilTableIsLoaded + test.skip('should trigger an `onRowClick` callback when clicking on a row', async () => { const onRowClickMock = jest.fn(); renderWithClient(); @@ -67,13 +68,14 @@ describe('ApprovalRequestTable', () => { const firstApproval = approvalRequestsListFixture[0]; expect(firstApproval.id).toBeDefined(); - const firstRow = await waitFor(async () => { - const rows = await screen.findAllByRole('row'); - expect(rows.length).toBeGreaterThan(1); - return rows[1]; // skip the header row + const rows = await waitFor(async () => { + const tableRows = await screen.findAllByRole('row'); + expect(tableRows.length).toBeGreaterThan(1); // Ensure data rows are loaded + return tableRows; }); - fireEvent.click(firstRow); + const firstDataRow = rows[1]; + fireEvent.click(firstDataRow); expect(onRowClickMock).toHaveBeenCalledWith(firstApproval.id); }); diff --git a/packages/sdk-react/src/components/counterparts/CounterpartDetails/CounterpartForm/CounterpartIndividualForm/CounterpartIndividualForm.tsx b/packages/sdk-react/src/components/counterparts/CounterpartDetails/CounterpartForm/CounterpartIndividualForm/CounterpartIndividualForm.tsx index 306eead7c..a8c48fcd9 100644 --- a/packages/sdk-react/src/components/counterparts/CounterpartDetails/CounterpartForm/CounterpartIndividualForm/CounterpartIndividualForm.tsx +++ b/packages/sdk-react/src/components/counterparts/CounterpartDetails/CounterpartForm/CounterpartIndividualForm/CounterpartIndividualForm.tsx @@ -8,6 +8,7 @@ import { useDialog } from '@/components/Dialog'; import { useIsActionAllowed } from '@/core/queries/usePermissions'; import { LanguageCodeEnum } from '@/enums/LanguageCodeEnum'; import { AccessRestriction } from '@/ui/accessRestriction'; +import { IconWrapper } from '@/ui/iconWrapper'; import { LoadingPage } from '@/ui/loadingPage'; import { yupResolver } from '@hookform/resolvers/yup'; import { t } from '@lingui/macro'; @@ -26,7 +27,6 @@ import { ListItemButton, ListItemText, Grid, - IconButton, } from '@mui/material'; import { getIndividualName } from '../../../helpers'; @@ -177,13 +177,13 @@ export const CounterpartIndividualForm = (props: CounterpartsFormProps) => { {dialogContext?.isDialogContent && ( - - + )} diff --git a/packages/sdk-react/src/components/counterparts/CounterpartDetails/CounterpartForm/CounterpartOrganizationForm/CounterpartOrganizationForm.tsx b/packages/sdk-react/src/components/counterparts/CounterpartDetails/CounterpartForm/CounterpartOrganizationForm/CounterpartOrganizationForm.tsx index 2dc9401d4..4fe00f367 100644 --- a/packages/sdk-react/src/components/counterparts/CounterpartDetails/CounterpartForm/CounterpartOrganizationForm/CounterpartOrganizationForm.tsx +++ b/packages/sdk-react/src/components/counterparts/CounterpartDetails/CounterpartForm/CounterpartOrganizationForm/CounterpartOrganizationForm.tsx @@ -8,6 +8,7 @@ import { useDialog } from '@/components/Dialog'; import { useIsActionAllowed } from '@/core/queries/usePermissions'; import { LanguageCodeEnum } from '@/enums/LanguageCodeEnum'; import { AccessRestriction } from '@/ui/accessRestriction'; +import { IconWrapper } from '@/ui/iconWrapper'; import { LoadingPage } from '@/ui/loadingPage'; import { yupResolver } from '@hookform/resolvers/yup'; import { t } from '@lingui/macro'; @@ -26,7 +27,6 @@ import { ListItemButton, ListItemText, Grid, - IconButton, } from '@mui/material'; import { CounterpartAddressForm } from '../../CounterpartAddressForm'; @@ -184,13 +184,13 @@ export const CounterpartOrganizationForm = (props: CounterpartsFormProps) => { {dialogContext?.isDialogContent && ( - - + )} diff --git a/packages/sdk-react/src/components/counterparts/CounterpartDetails/CounterpartView/CounterpartView.tsx b/packages/sdk-react/src/components/counterparts/CounterpartDetails/CounterpartView/CounterpartView.tsx index 763978d39..6f8cad5c9 100644 --- a/packages/sdk-react/src/components/counterparts/CounterpartDetails/CounterpartView/CounterpartView.tsx +++ b/packages/sdk-react/src/components/counterparts/CounterpartDetails/CounterpartView/CounterpartView.tsx @@ -5,6 +5,7 @@ import { CounterpartVatView } from '@/components/counterparts/CounterpartDetails import { useDialog } from '@/components/Dialog'; import { useIsActionAllowed } from '@/core/queries/usePermissions'; import { AccessRestriction } from '@/ui/accessRestriction'; +import { IconWrapper } from '@/ui/iconWrapper'; import { LoadingPage } from '@/ui/loadingPage'; import { NotFound } from '@/ui/notFound'; import { t } from '@lingui/macro'; @@ -16,7 +17,6 @@ import EditIcon from '@mui/icons-material/Edit'; import { Button, Typography, - IconButton, Divider, Grid, DialogContent, @@ -185,13 +185,13 @@ export const CounterpartView = (props: CounterpartViewProps) => { {dialogContext?.isDialogContent && ( - - + )} diff --git a/packages/sdk-react/src/components/payables/CreatePayableMenu/CreatePayableMenu.tsx b/packages/sdk-react/src/components/payables/CreatePayableMenu/CreatePayableMenu.tsx index 52820801a..2bb7889bf 100644 --- a/packages/sdk-react/src/components/payables/CreatePayableMenu/CreatePayableMenu.tsx +++ b/packages/sdk-react/src/components/payables/CreatePayableMenu/CreatePayableMenu.tsx @@ -6,20 +6,9 @@ import { t } from '@lingui/macro'; import { useLingui } from '@lingui/react'; import AddIcon from '@mui/icons-material/Add'; import CloudUploadOutlinedIcon from '@mui/icons-material/CloudUploadOutlined'; -import ContentCopyIcon from '@mui/icons-material/ContentCopy'; import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp'; -import MailOutlineIcon from '@mui/icons-material/MailOutline'; -import SettingsIcon from '@mui/icons-material/Settings'; -import { - Alert, - alpha, - Box, - Button, - Menu, - Stack, - Typography, -} from '@mui/material'; +import { alpha, Box, Button, Menu, Stack, Typography } from '@mui/material'; interface CreatePayableMenuProps { isCreateAllowed: boolean; @@ -91,61 +80,6 @@ export const CreatePayableMenu = ({ e.stopPropagation(); }} > - - - {t( - i18n - )`Forward to email`} - - - } - action={ - - } - sx={{ - '& .MuiPaper-root': { alignItems: 'center' }, - '& .MuiAlert-action': { pt: 0 }, - }} - > - - - {/* TODO: add support for email */} - {/* eslint-disable-next-line lingui/no-unlocalized-strings */} - {'incoming-bills-silver-wind@x-platform.com'} - - - - - {t( - i18n - )`All invoices and bills sent to this email will be automatically processed and added to the system as drafts.`} - - {t(i18n)`Drag & Drop`} @@ -228,5 +162,3 @@ export const CreatePayableMenu = ({ ); }; - -CreatePayableMenu; diff --git a/packages/sdk-react/src/components/payables/PayableDetails/PayableDetailsHeader/PayableDetailsHeader.tsx b/packages/sdk-react/src/components/payables/PayableDetails/PayableDetailsHeader/PayableDetailsHeader.tsx index 73750eb0f..2f279f234 100644 --- a/packages/sdk-react/src/components/payables/PayableDetails/PayableDetailsHeader/PayableDetailsHeader.tsx +++ b/packages/sdk-react/src/components/payables/PayableDetails/PayableDetailsHeader/PayableDetailsHeader.tsx @@ -4,6 +4,7 @@ import { useDialog } from '@/components/Dialog'; import { PayableStatusChip } from '@/components/payables/PayableStatusChip'; import { PayableDataTestId } from '@/components/payables/types'; import { useCounterpartById } from '@/core/queries'; +import { IconWrapper } from '@/ui/iconWrapper'; import { t } from '@lingui/macro'; import { useLingui } from '@lingui/react'; import CloseIcon from '@mui/icons-material/Close'; @@ -12,7 +13,6 @@ import { Button, ButtonProps, DialogTitle, - IconButton, Stack, Toolbar, Typography, @@ -116,14 +116,15 @@ export const PayableDetailsHeader = ({ {dialogContext?.isDialogContent && ( - - + )} diff --git a/packages/sdk-react/src/components/payables/PayablesTable/components/PayablesTableAction.tsx b/packages/sdk-react/src/components/payables/PayablesTable/components/PayablesTableAction.tsx index 357f0d9b0..9ceab2682 100644 --- a/packages/sdk-react/src/components/payables/PayablesTable/components/PayablesTableAction.tsx +++ b/packages/sdk-react/src/components/payables/PayablesTable/components/PayablesTableAction.tsx @@ -1,17 +1,16 @@ +import { useState } from 'react'; +import { toast } from 'react-hot-toast'; + import { components } from '@/api'; +import { useMoniteContext } from '@/core/context/MoniteContext'; +import { useRootElements } from '@/core/context/RootElementsProvider'; import { useIsActionAllowed } from '@/core/queries/usePermissions'; import { t } from '@lingui/macro'; import { useLingui } from '@lingui/react'; -import { Button } from '@mui/material'; +import { Button, Modal, Box } from '@mui/material'; interface PayablesTableActionProps { payable: components['schemas']['PayableResponseSchema']; - - /** - * The event handler for the pay action - * - * @param id - The identifier of the row to perform the pay action on, a string. - */ onPay?: (id: string) => void; } @@ -19,6 +18,7 @@ export const PayablesTableAction = ({ payable, onPay, }: PayablesTableActionProps) => { + const { root } = useRootElements(); const { i18n } = useLingui(); const { data: isPayAllowed } = useIsActionAllowed({ method: 'payable', @@ -26,26 +26,114 @@ export const PayablesTableAction = ({ entityUserId: payable.was_created_by_user_id, }); + const { handlePay } = usePaymentHandler(payable); + + const [modalOpen, setModalOpen] = useState(false); + const [iframeUrl, setIframeUrl] = useState(null); + + const handleOpenModal = async () => { + const url = await handlePay(); + if (url) { + setIframeUrl(url); + setModalOpen(true); + } + }; + + const handleCloseModal = () => { + setModalOpen(false); + setIframeUrl(null); + }; + if (isPayAllowed && payable.status === 'waiting_to_be_paid') { return ( - + <> + + + + + {iframeUrl ? ( +