mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +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 { SharePaymentLinkFormContent } from './SharePaymentLinkFormContent';
|
||||
import { SharePaymentLinkProvider } from './SharePaymentLinkProvider';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// @ts-nocheck
|
||||
import { useFormikContext } from 'formik';
|
||||
import {
|
||||
Button,
|
||||
Classes,
|
||||
@@ -20,15 +21,23 @@ import {
|
||||
} from '@/components';
|
||||
import { useSharePaymentLink } from './SharePaymentLinkProvider';
|
||||
import { useClipboard } from '@/hooks/utils/useClipboard';
|
||||
import { useDialogActions } from '@/hooks/state';
|
||||
import { useDialogContext } from '@/components/Dialog/DialogProvider';
|
||||
|
||||
export function SharePaymentLinkFormContent() {
|
||||
const { url } = useSharePaymentLink();
|
||||
const { closeDialog } = useDialogActions();
|
||||
const { name } = useDialogContext();
|
||||
const { isSubmitting } = useFormikContext();
|
||||
|
||||
const clipboard = useClipboard();
|
||||
|
||||
const handleCopyBtnClick = () => {
|
||||
clipboard.copy(url);
|
||||
};
|
||||
const handleCancelBtnClick = () => {
|
||||
closeDialog(name);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -115,10 +124,11 @@ export function SharePaymentLinkFormContent() {
|
||||
</Button>
|
||||
) : (
|
||||
<>
|
||||
<Button>Cancel</Button>
|
||||
<Button onClick={handleCancelBtnClick}>Cancel</Button>
|
||||
<Button
|
||||
type={'submit'}
|
||||
intent={Intent.PRIMARY}
|
||||
loading={isSubmitting}
|
||||
style={{ minWidth: 100 }}
|
||||
>
|
||||
Generate
|
||||
|
||||
Reference in New Issue
Block a user