-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DEV-12592): add entity email to invoice uploading menu
- Loading branch information
1 parent
0243446
commit 2a24375
Showing
6 changed files
with
67 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import React, { DragEvent, useState } from 'react'; | ||
import { toast } from 'react-hot-toast'; | ||
|
||
import { useMoniteContext } from '@/core/context/MoniteContext'; | ||
import { useFileInput, useMenuButton } from '@/core/hooks'; | ||
import { t } from '@lingui/macro'; | ||
import { useLingui } from '@lingui/react'; | ||
|
@@ -10,7 +11,6 @@ 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, | ||
|
@@ -21,6 +21,8 @@ import { | |
Typography, | ||
} from '@mui/material'; | ||
|
||
const MENU_WIDTH = 550; | ||
|
||
interface CreatePayableMenuProps { | ||
isCreateAllowed: boolean; | ||
onCreateInvoice: () => void; | ||
|
@@ -36,6 +38,10 @@ export const CreatePayableMenu = ({ | |
const { buttonProps, menuProps, open, closeMenu } = useMenuButton(); | ||
const { FileInput, openFileInput } = useFileInput(); | ||
const [dragIsOver, setDragIsOver] = useState(false); | ||
const { api } = useMoniteContext(); | ||
|
||
const { data: mailboxes } = api.mailboxes.getMailboxes.useQuery(); | ||
const mailboxAddress = mailboxes?.data?.[0]?.mailbox_full_address; | ||
|
||
const handleDragOver = (event: DragEvent<HTMLDivElement>) => { | ||
event.preventDefault(); | ||
|
@@ -68,11 +74,11 @@ export const CreatePayableMenu = ({ | |
> | ||
{t(i18n)`New bill`} | ||
</Button> | ||
<Menu {...menuProps} sx={{ '& > .MuiPaper-root': { width: 550 } }}> | ||
<Menu {...menuProps} sx={{ '& > .MuiPaper-root': { width: MENU_WIDTH } }}> | ||
<Stack | ||
spacing={3} | ||
flexDirection="column" | ||
sx={{ p: 2, width: 550 }} | ||
sx={{ p: 2, width: MENU_WIDTH }} | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
|
@@ -85,29 +91,20 @@ export const CreatePayableMenu = ({ | |
alignItems="center" | ||
mb={2} | ||
> | ||
<Typography variant="subtitle1">{t( | ||
i18n | ||
)`Forward to email`}</Typography> | ||
<Button | ||
variant="text" | ||
endIcon={<SettingsIcon />} | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
}} | ||
>{t(i18n)`Customise`}</Button> | ||
<Typography variant="subtitle1"> | ||
{t(i18n)`Forward to email`} | ||
</Typography> | ||
</Stack> | ||
<Alert | ||
severity="info" | ||
icon={<MailOutlineIcon color="primary" />} | ||
action={ | ||
<Button | ||
disabled={!mailboxAddress} | ||
variant="outlined" | ||
startIcon={<ContentCopyIcon />} | ||
onClick={() => { | ||
navigator.clipboard.writeText( | ||
'[email protected]' | ||
); | ||
navigator.clipboard.writeText(mailboxAddress || ''); | ||
toast.success(t(i18n)`Copied to clipboard`); | ||
}} | ||
> | ||
|
@@ -121,9 +118,7 @@ export const CreatePayableMenu = ({ | |
> | ||
<Box> | ||
<Typography variant="body1" color="primary"> | ||
{/* TODO: add support for email */} | ||
{/* eslint-disable-next-line lingui/no-unlocalized-strings */} | ||
{'[email protected]'} | ||
{mailboxAddress || t(i18n)`No email address`} | ||
</Typography> | ||
</Box> | ||
</Alert> | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './mailboxesHandlers'; | ||
export * from './mailboxesFixture'; |
31 changes: 31 additions & 0 deletions
31
packages/sdk-react/src/mocks/mailboxes/mailboxesFixture.ts
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,31 @@ | ||
import { components } from '@/api'; | ||
import { faker } from '@faker-js/faker'; | ||
|
||
export const mailboxesFixture: components['schemas']['MailboxDataResponse'] = { | ||
data: [ | ||
{ | ||
id: faker.string.uuid(), | ||
mailbox_domain_id: faker.string.uuid(), | ||
mailbox_full_address: faker.internet.email(), | ||
mailbox_name: faker.company.name(), | ||
related_object_type: 'payable', | ||
status: 'active', | ||
}, | ||
{ | ||
id: faker.string.uuid(), | ||
mailbox_domain_id: faker.string.uuid(), | ||
mailbox_full_address: faker.internet.email(), | ||
mailbox_name: faker.company.name(), | ||
related_object_type: 'payable', | ||
status: 'active', | ||
}, | ||
{ | ||
id: faker.string.uuid(), | ||
mailbox_domain_id: faker.string.uuid(), | ||
mailbox_full_address: faker.internet.email(), | ||
mailbox_name: faker.company.name(), | ||
related_object_type: 'payable', | ||
status: 'active', | ||
}, | ||
], | ||
}; |
16 changes: 16 additions & 0 deletions
16
packages/sdk-react/src/mocks/mailboxes/mailboxesHandlers.ts
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,16 @@ | ||
import { components } from '@/api'; | ||
|
||
import { http, HttpResponse, delay } from 'msw'; | ||
|
||
import { mailboxesFixture } from './mailboxesFixture'; | ||
|
||
export const mailboxesHandlers = [ | ||
http.get<{}, {}, components['schemas']['MailboxDataResponse']>( | ||
'*/mailboxes', | ||
async () => { | ||
await delay(); | ||
|
||
return HttpResponse.json(mailboxesFixture); | ||
} | ||
), | ||
]; |