Skip to content

Commit

Permalink
refactor: update confirmation modal button
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaHungDinh committed Dec 16, 2024
1 parent d9bf5e5 commit cba9501
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export function DonationFormsRowActions({data, item, removeRow, addRow, setUpdat

await mutate(parameters);
return response;
}
},
__('Yes proceed','give')
);
};

Expand Down
11 changes: 7 additions & 4 deletions src/Views/Components/ListTable/ListTablePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export type BulkActionsConfig =
| BulkActionsConfigWithoutType
| BulkActionsConfigWithoutAction;

export const ShowConfirmModalContext = createContext((label, confirm, action, type = null) => {});
export const ShowConfirmModalContext = createContext((label, confirm, action, type = null, confirmButtonText = __('Confirm', 'give')) => {});
export const CheckboxContext = createContext(null);

export default function ListTablePage({
Expand All @@ -113,11 +113,13 @@ export default function ListTablePage({
confirm;
action?;
label;
confirmButtonText?: string;
type?: 'normal' | 'warning' | 'danger' | 'custom';
}>({
confirm: (selected) => {},
action: (selected) => {},
label: '',
confirmButtonText: '',
});
const [selectedAction, setSelectedAction] = useState<string>('');
const [selectedIds, setSelectedIds] = useState([]);
Expand Down Expand Up @@ -160,9 +162,10 @@ export default function ListTablePage({
label,
confirm,
action,
type: 'normal' | 'warning' | 'danger' | 'custom' | null
type?: 'normal' | 'warning' | 'danger' | 'custom' | null,
confirmButtonText?: string,
) => {
setModalContent({confirm, action, label, type});
setModalContent({label, confirm, action, type, confirmButtonText});
dialog.current.show();
};

Expand Down Expand Up @@ -354,7 +357,7 @@ export default function ListTablePage({
await mutate();
}}
>
{__('Confirm', 'give')}
{modalContent?.confirmButtonText ?? __('Confirm', 'give')}
</button>
</div>
</A11yDialog>
Expand Down

0 comments on commit cba9501

Please sign in to comment.