fix(striker-ui): simplify frequently used props of build delete dialog in checklist

main
Tsu-ba-me 2 years ago
parent 38f577e8f1
commit f7f363b7c1
  1. 10
      striker-ui/hooks/useChecklist.tsx
  2. 7
      striker-ui/types/Checklist.d.ts

@ -36,11 +36,19 @@ const useChecklist = ({
confirmDialogProps = {}, confirmDialogProps = {},
formSummaryProps = {}, formSummaryProps = {},
getConfirmDialogTitle, getConfirmDialogTitle,
onProceedAppend,
renderEntry,
}) => ({ }) => ({
actionProceedText: 'Delete', actionProceedText: 'Delete',
content: ( content: (
<FormSummary entries={checklist} maxDepth={0} {...formSummaryProps} /> <FormSummary
entries={checklist}
maxDepth={0}
renderEntry={renderEntry}
{...formSummaryProps}
/>
), ),
onProceedAppend,
proceedColour: 'red', proceedColour: 'red',
titleText: getConfirmDialogTitle(checks.length), titleText: getConfirmDialogTitle(checks.length),
...confirmDialogProps, ...confirmDialogProps,

@ -2,11 +2,14 @@ type Checklist = Record<string, boolean>;
type ArrayChecklist = (keyof Checklist)[]; type ArrayChecklist = (keyof Checklist)[];
type BuildDeleteDialogPropsFunction = (args: { type BuildDeleteDialogPropsFunction = (
args: {
confirmDialogProps?: Partial<Omit<ConfirmDialogProps, 'content'>>; confirmDialogProps?: Partial<Omit<ConfirmDialogProps, 'content'>>;
formSummaryProps?: Omit<FormSummaryProps<Checklist>, 'entries'>; formSummaryProps?: Omit<FormSummaryProps<Checklist>, 'entries'>;
getConfirmDialogTitle: (length: number) => ReactNode; getConfirmDialogTitle: (length: number) => ReactNode;
}) => ConfirmDialogProps; } & Pick<ConfirmDialogProps, 'onProceedAppend'> &
Pick<FormSummaryProps<Checklist>, 'renderEntry'>,
) => ConfirmDialogProps;
type GetCheckFunction = (key: string) => boolean; type GetCheckFunction = (key: string) => boolean;

Loading…
Cancel
Save