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. 13
      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 = (
confirmDialogProps?: Partial<Omit<ConfirmDialogProps, 'content'>>; args: {
formSummaryProps?: Omit<FormSummaryProps<Checklist>, 'entries'>; confirmDialogProps?: Partial<Omit<ConfirmDialogProps, 'content'>>;
getConfirmDialogTitle: (length: number) => ReactNode; formSummaryProps?: Omit<FormSummaryProps<Checklist>, 'entries'>;
}) => ConfirmDialogProps; getConfirmDialogTitle: (length: number) => ReactNode;
} & Pick<ConfirmDialogProps, 'onProceedAppend'> &
Pick<FormSummaryProps<Checklist>, 'renderEntry'>,
) => ConfirmDialogProps;
type GetCheckFunction = (key: string) => boolean; type GetCheckFunction = (key: string) => boolean;

Loading…
Cancel
Save