mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
feat: wip send invoice mail receipt
This commit is contained in:
@@ -19,7 +19,12 @@ function CreditNoteCustomizeDrawerRoot({
|
|||||||
payload,
|
payload,
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Drawer isOpen={isOpen} name={name} payload={payload} size={'100%'}>
|
<Drawer
|
||||||
|
isOpen={isOpen}
|
||||||
|
name={name}
|
||||||
|
payload={payload}
|
||||||
|
size={'calc(100% - 10px)'}
|
||||||
|
>
|
||||||
<DrawerSuspense>
|
<DrawerSuspense>
|
||||||
<CreditNoteCustomizeDrawerBody />
|
<CreditNoteCustomizeDrawerBody />
|
||||||
</DrawerSuspense>
|
</DrawerSuspense>
|
||||||
|
|||||||
@@ -20,7 +20,12 @@ function EstimateCustomizeDrawerRoot({
|
|||||||
payload,
|
payload,
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Drawer isOpen={isOpen} name={name} payload={payload} size={'100%'}>
|
<Drawer
|
||||||
|
isOpen={isOpen}
|
||||||
|
name={name}
|
||||||
|
payload={payload}
|
||||||
|
size={'calc(100% - 10px)'}
|
||||||
|
>
|
||||||
<DrawerSuspense>
|
<DrawerSuspense>
|
||||||
<EstimateCustomizeDrawerBody />
|
<EstimateCustomizeDrawerBody />
|
||||||
</DrawerSuspense>
|
</DrawerSuspense>
|
||||||
|
|||||||
@@ -17,7 +17,12 @@ function InvoiceCustomizeDrawerRoot({
|
|||||||
payload,
|
payload,
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Drawer isOpen={isOpen} name={name} size={'100%'} payload={payload}>
|
<Drawer
|
||||||
|
isOpen={isOpen}
|
||||||
|
name={name}
|
||||||
|
payload={payload}
|
||||||
|
size={'calc(100% - 10px)'}
|
||||||
|
>
|
||||||
<DrawerSuspense>
|
<DrawerSuspense>
|
||||||
<InvoiceCustomize />
|
<InvoiceCustomize />
|
||||||
</DrawerSuspense>
|
</DrawerSuspense>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import * as R from 'ramda';
|
import * as R from 'ramda';
|
||||||
|
import { useFormikContext } from 'formik';
|
||||||
import { InvoicePaymentPagePreviewProps } from '@/containers/PaymentPortal/InvoicePaymentPagePreview';
|
import { InvoicePaymentPagePreviewProps } from '@/containers/PaymentPortal/InvoicePaymentPagePreview';
|
||||||
import { InvoiceCustomizeFormValues } from './types';
|
import { InvoiceCustomizeFormValues } from './types';
|
||||||
import { useElementCustomizeContext } from '@/containers/ElementCustomize/ElementCustomizeProvider';
|
import { useElementCustomizeContext } from '@/containers/ElementCustomize/ElementCustomizeProvider';
|
||||||
import { useFormikContext } from 'formik';
|
|
||||||
import { InvoiceMailReceiptPreview } from './InvoiceMailReceiptPreview';
|
import { InvoiceMailReceiptPreview } from './InvoiceMailReceiptPreview';
|
||||||
import { Box } from '@/components';
|
import { Box } from '@/components';
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,12 @@ function InvoiceSendMailDrawerRoot({
|
|||||||
payload,
|
payload,
|
||||||
}: InvoiceSendMailDrawerProps) {
|
}: InvoiceSendMailDrawerProps) {
|
||||||
return (
|
return (
|
||||||
<Drawer isOpen={isOpen} name={name} size={'100%'} payload={payload}>
|
<Drawer
|
||||||
|
isOpen={isOpen}
|
||||||
|
name={name}
|
||||||
|
payload={payload}
|
||||||
|
size={'calc(100% - 10px)'}
|
||||||
|
>
|
||||||
<DrawerSuspense>
|
<DrawerSuspense>
|
||||||
<InvoiceSendMailContent />
|
<InvoiceSendMailContent />
|
||||||
</DrawerSuspense>
|
</DrawerSuspense>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import { useRef, useState } from 'react';
|
|
||||||
import { Button, Intent, MenuItem, Position } from '@blueprintjs/core';
|
import { Button, Intent, MenuItem, Position } from '@blueprintjs/core';
|
||||||
|
import { useRef, useState, useMemo, useCallback } from 'react';
|
||||||
import { useFormikContext } from 'formik';
|
import { useFormikContext } from 'formik';
|
||||||
|
import { SelectOptionProps } from '@blueprintjs-formik/select';
|
||||||
import { css } from '@emotion/css';
|
import { css } from '@emotion/css';
|
||||||
import { x } from '@xstyled/emotion';
|
|
||||||
import { unique, chain } from 'lodash';
|
|
||||||
import {
|
import {
|
||||||
|
FCheckbox,
|
||||||
FFormGroup,
|
FFormGroup,
|
||||||
FInputGroup,
|
FInputGroup,
|
||||||
FMultiSelect,
|
FMultiSelect,
|
||||||
@@ -17,7 +17,6 @@ import {
|
|||||||
} from '@/components';
|
} from '@/components';
|
||||||
import { useDrawerContext } from '@/components/Drawer/DrawerProvider';
|
import { useDrawerContext } from '@/components/Drawer/DrawerProvider';
|
||||||
import { useDrawerActions } from '@/hooks/state';
|
import { useDrawerActions } from '@/hooks/state';
|
||||||
import { SelectOptionProps } from '@blueprintjs-formik/select';
|
|
||||||
import { useInvoiceMailItems } from './_hooks';
|
import { useInvoiceMailItems } from './_hooks';
|
||||||
|
|
||||||
// Create new account renderer.
|
// Create new account renderer.
|
||||||
@@ -62,7 +61,7 @@ const fieldsWrapStyle = css`
|
|||||||
export function InvoiceSendMailFields() {
|
export function InvoiceSendMailFields() {
|
||||||
const [showCCField, setShowCCField] = useState<boolean>(false);
|
const [showCCField, setShowCCField] = useState<boolean>(false);
|
||||||
const [showBccField, setShowBccField] = useState<boolean>(false);
|
const [showBccField, setShowBccField] = useState<boolean>(false);
|
||||||
const textareaRef = useRef(null);
|
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||||
|
|
||||||
const { values, setFieldValue } = useFormikContext();
|
const { values, setFieldValue } = useFormikContext();
|
||||||
const items = useInvoiceMailItems();
|
const items = useInvoiceMailItems();
|
||||||
@@ -92,7 +91,7 @@ export function InvoiceSendMailFields() {
|
|||||||
setFieldValue('bcc', [...values?.bcc, value?.name]);
|
setFieldValue('bcc', [...values?.bcc, value?.name]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const rightElementsToField = (
|
const rightElementsToField = useMemo(() => (
|
||||||
<Group
|
<Group
|
||||||
spacing={0}
|
spacing={0}
|
||||||
paddingRight={'7px'}
|
paddingRight={'7px'}
|
||||||
@@ -118,16 +117,14 @@ export function InvoiceSendMailFields() {
|
|||||||
BCC
|
BCC
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
);
|
), []);
|
||||||
|
|
||||||
const handleTextareaChange = () => {
|
const handleTextareaChange = useCallback((item: SelectOptionProps) => {
|
||||||
const textarea = textareaRef.current;
|
const textarea = textareaRef.current;
|
||||||
if (!textarea) return;
|
if (!textarea) return;
|
||||||
|
|
||||||
const { selectionStart, selectionEnd } = textarea;
|
const { selectionStart, selectionEnd, value: text } = textarea;
|
||||||
const insertText = '{Variable}';
|
const insertText = item.value;
|
||||||
|
|
||||||
// Insert the text at the cursor position
|
|
||||||
const message =
|
const message =
|
||||||
text.substring(0, selectionStart) +
|
text.substring(0, selectionStart) +
|
||||||
insertText +
|
insertText +
|
||||||
@@ -139,10 +136,9 @@ export function InvoiceSendMailFields() {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
textarea.selectionStart = textarea.selectionEnd =
|
textarea.selectionStart = textarea.selectionEnd =
|
||||||
selectionStart + insertText.length;
|
selectionStart + insertText.length;
|
||||||
|
|
||||||
textarea.focus();
|
textarea.focus();
|
||||||
}, 0);
|
}, 0);
|
||||||
};
|
}, [setFieldValue]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
@@ -228,7 +224,7 @@ export function InvoiceSendMailFields() {
|
|||||||
<FSelect
|
<FSelect
|
||||||
selectedItem={'customerName'}
|
selectedItem={'customerName'}
|
||||||
name={'item'}
|
name={'item'}
|
||||||
items={[{ value: 'customerName', text: 'Customer Name' }]}
|
items={[{ value: 'CustomerName', text: 'Customer Name' }]}
|
||||||
onItemChange={handleTextareaChange}
|
onItemChange={handleTextareaChange}
|
||||||
popoverProps={{
|
popoverProps={{
|
||||||
fill: false,
|
fill: false,
|
||||||
@@ -251,20 +247,24 @@ export function InvoiceSendMailFields() {
|
|||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<FTextArea
|
<FTextArea
|
||||||
ref={textareaRef}
|
inputRef={textareaRef}
|
||||||
name={'message'}
|
name={'message'}
|
||||||
large
|
large
|
||||||
fill
|
fill
|
||||||
fastField
|
fastField
|
||||||
className={css`
|
className={css`
|
||||||
resize: vertical;
|
resize: vertical;
|
||||||
min-height: 200px;
|
min-height: 300px;
|
||||||
border-top-right-radius: 0px;
|
border-top-right-radius: 0px;
|
||||||
border-top-left-radius: 0px;
|
border-top-left-radius: 0px;
|
||||||
`}
|
`}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
|
|
||||||
|
<Group>
|
||||||
|
<FCheckbox name={'attachPdf'} label={'Attach PDF'} />
|
||||||
|
</Group>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<InvoiceSendMailFooter />
|
<InvoiceSendMailFooter />
|
||||||
|
|||||||
@@ -10,12 +10,13 @@ import { useDrawerActions } from '@/hooks/state';
|
|||||||
import { useDrawerContext } from '@/components/Drawer/DrawerProvider';
|
import { useDrawerContext } from '@/components/Drawer/DrawerProvider';
|
||||||
import { transformToForm } from '@/utils';
|
import { transformToForm } from '@/utils';
|
||||||
|
|
||||||
const initialValues = {
|
const initialValues: InvoiceSendMailFormValues = {
|
||||||
subject: '',
|
subject: '',
|
||||||
message: '',
|
message: '',
|
||||||
to: [],
|
to: [],
|
||||||
cc: [],
|
cc: [],
|
||||||
bcc: [],
|
bcc: [],
|
||||||
|
attachPdf: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
interface InvoiceSendMailFormProps {
|
interface InvoiceSendMailFormProps {
|
||||||
@@ -28,7 +29,7 @@ export function InvoiceSendMailForm({ children }: InvoiceSendMailFormProps) {
|
|||||||
const { name } = useDrawerContext();
|
const { name } = useDrawerContext();
|
||||||
const { closeDrawer } = useDrawerActions();
|
const { closeDrawer } = useDrawerActions();
|
||||||
|
|
||||||
const _initialValues = {
|
const _initialValues: InvoiceSendMailFormValues = {
|
||||||
...initialValues,
|
...initialValues,
|
||||||
...transformToForm(invoiceMailOptions, initialValues),
|
...transformToForm(invoiceMailOptions, initialValues),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { css } from '@emotion/css';
|
|
||||||
import { x } from '@xstyled/emotion';
|
import { x } from '@xstyled/emotion';
|
||||||
import { Box, Group, Stack } from '@/components';
|
import { Box, Group, Stack } from '@/components';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
@@ -27,17 +26,15 @@ export function InvoiceSendMailHeaderPreview() {
|
|||||||
<Group display="flex" alignItems="center" gap={15}>
|
<Group display="flex" alignItems="center" gap={15}>
|
||||||
<x.abbr
|
<x.abbr
|
||||||
role="presentation"
|
role="presentation"
|
||||||
className={css`
|
w={'40px'}
|
||||||
background-color: #daa3e4;
|
h={'40px'}
|
||||||
color: #3f1946;
|
bg={'#daa3e4'}
|
||||||
fill: #daa3e4;
|
fill={'#daa3e4'}
|
||||||
height: 40px;
|
color={'#3f1946'}
|
||||||
width: 40px;
|
lineHeight={'40px'}
|
||||||
line-height: 40px;
|
textAlign={'center'}
|
||||||
text-align: center;
|
borderRadius={'40px'}
|
||||||
border-radius: 40px;
|
fontSize={'14px'}
|
||||||
font-size: 14px;
|
|
||||||
`}
|
|
||||||
>
|
>
|
||||||
A
|
A
|
||||||
</x.abbr>
|
</x.abbr>
|
||||||
|
|||||||
@@ -4,4 +4,5 @@ export interface InvoiceSendMailFormValues {
|
|||||||
to: string[];
|
to: string[];
|
||||||
cc: string[];
|
cc: string[];
|
||||||
bcc: string[];
|
bcc: string[];
|
||||||
|
attachPdf: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,12 @@ function ReceiptCustomizeDrawerRoot({
|
|||||||
payload,
|
payload,
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Drawer isOpen={isOpen} name={name} size={'100%'} payload={payload}>
|
<Drawer
|
||||||
|
isOpen={isOpen}
|
||||||
|
name={name}
|
||||||
|
payload={payload}
|
||||||
|
size={'calc(100% - 10px)'}
|
||||||
|
>
|
||||||
<DrawerSuspense>
|
<DrawerSuspense>
|
||||||
<ReceiptCustomizeDrawerBody />
|
<ReceiptCustomizeDrawerBody />
|
||||||
</DrawerSuspense>
|
</DrawerSuspense>
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ export function useInvoicePaymentTransactions(invoiceId, props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SendSaleInvoiceMailValues {
|
export interface SendSaleInvoiceMailValues {
|
||||||
id: number;
|
id: number;
|
||||||
values: {
|
values: {
|
||||||
subject: string;
|
subject: string;
|
||||||
@@ -331,7 +331,7 @@ interface SendSaleInvoiceMailValues {
|
|||||||
attachInvoice?: boolean;
|
attachInvoice?: boolean;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
interface SendSaleInvoiceMailResponse {}
|
export interface SendSaleInvoiceMailResponse { }
|
||||||
/**
|
/**
|
||||||
* Sends the sale invoice mail.
|
* Sends the sale invoice mail.
|
||||||
* @param {UseMutationOptions<SendSaleInvoiceMailValues, Error, SendSaleInvoiceMailResponse>}
|
* @param {UseMutationOptions<SendSaleInvoiceMailValues, Error, SendSaleInvoiceMailResponse>}
|
||||||
|
|||||||
Reference in New Issue
Block a user