mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
feat: add loading state to generate payment link dialog
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import { DialogBody } from '@blueprintjs/core';
|
|
||||||
import { SharePaymentLinkForm } from './SharePaymentLinkForm';
|
import { SharePaymentLinkForm } from './SharePaymentLinkForm';
|
||||||
import { SharePaymentLinkFormContent } from './SharePaymentLinkFormContent';
|
import { SharePaymentLinkFormContent } from './SharePaymentLinkFormContent';
|
||||||
import { SharePaymentLinkProvider } from './SharePaymentLinkProvider';
|
import { SharePaymentLinkProvider } from './SharePaymentLinkProvider';
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
|
import { useFormikContext } from 'formik';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Classes,
|
Classes,
|
||||||
@@ -20,15 +21,23 @@ import {
|
|||||||
} from '@/components';
|
} from '@/components';
|
||||||
import { useSharePaymentLink } from './SharePaymentLinkProvider';
|
import { useSharePaymentLink } from './SharePaymentLinkProvider';
|
||||||
import { useClipboard } from '@/hooks/utils/useClipboard';
|
import { useClipboard } from '@/hooks/utils/useClipboard';
|
||||||
|
import { useDialogActions } from '@/hooks/state';
|
||||||
|
import { useDialogContext } from '@/components/Dialog/DialogProvider';
|
||||||
|
|
||||||
export function SharePaymentLinkFormContent() {
|
export function SharePaymentLinkFormContent() {
|
||||||
const { url } = useSharePaymentLink();
|
const { url } = useSharePaymentLink();
|
||||||
|
const { closeDialog } = useDialogActions();
|
||||||
|
const { name } = useDialogContext();
|
||||||
|
const { isSubmitting } = useFormikContext();
|
||||||
|
|
||||||
const clipboard = useClipboard();
|
const clipboard = useClipboard();
|
||||||
|
|
||||||
const handleCopyBtnClick = () => {
|
const handleCopyBtnClick = () => {
|
||||||
clipboard.copy(url);
|
clipboard.copy(url);
|
||||||
};
|
};
|
||||||
|
const handleCancelBtnClick = () => {
|
||||||
|
closeDialog(name);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -115,10 +124,11 @@ export function SharePaymentLinkFormContent() {
|
|||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Button>Cancel</Button>
|
<Button onClick={handleCancelBtnClick}>Cancel</Button>
|
||||||
<Button
|
<Button
|
||||||
type={'submit'}
|
type={'submit'}
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
|
loading={isSubmitting}
|
||||||
style={{ minWidth: 100 }}
|
style={{ minWidth: 100 }}
|
||||||
>
|
>
|
||||||
Generate
|
Generate
|
||||||
|
|||||||
Reference in New Issue
Block a user