fix(striker-ui): add loading setter to confirm dialog hook

main
Tsu-ba-me 11 months ago
parent 3dcc2ba0c5
commit 4d65472694
  1. 11
      striker-ui/hooks/useConfirmDialog.tsx

@ -20,6 +20,7 @@ const useConfirmDialog = (
): { ): {
confirmDialog: ReactElement; confirmDialog: ReactElement;
confirmDialogRef: MutableRefObject<ConfirmDialogForwardedRefContent | null>; confirmDialogRef: MutableRefObject<ConfirmDialogForwardedRefContent | null>;
setConfirmDialogLoading: (value: boolean) => void;
setConfirmDialogOpen: (value: boolean) => void; setConfirmDialogOpen: (value: boolean) => void;
setConfirmDialogProps: Dispatch<SetStateAction<ConfirmDialogProps>>; setConfirmDialogProps: Dispatch<SetStateAction<ConfirmDialogProps>>;
finishConfirm: (title: ReactNode, message: Message) => void; finishConfirm: (title: ReactNode, message: Message) => void;
@ -44,6 +45,15 @@ const useConfirmDialog = (
titleText, titleText,
}); });
const setConfirmDialogLoading = useCallback(
(value: boolean) =>
setConfirmDialogProps(({ loading, ...rest }) => ({
...rest,
loading: value,
})),
[],
);
const setConfirmDialogOpen = useCallback( const setConfirmDialogOpen = useCallback(
(value: boolean) => confirmDialogRef?.current?.setOpen?.call(null, value), (value: boolean) => confirmDialogRef?.current?.setOpen?.call(null, value),
[], [],
@ -75,6 +85,7 @@ const useConfirmDialog = (
return { return {
confirmDialog, confirmDialog,
confirmDialogRef, confirmDialogRef,
setConfirmDialogLoading,
setConfirmDialogOpen, setConfirmDialogOpen,
setConfirmDialogProps, setConfirmDialogProps,
finishConfirm, finishConfirm,

Loading…
Cancel
Save