diff --git a/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.test.tsx b/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.test.tsx
index f476f63cf4..904b8e134d 100644
--- a/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.test.tsx
+++ b/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.test.tsx
@@ -125,17 +125,10 @@ describe('PartnerRemindersReport', () => {
await waitFor(() => expect(onNavListToggle).toHaveBeenCalled());
});
- it('should show saved snackbar when save is clicked with no changes', async () => {
- mockEnqueue.mockClear();
- const { getByRole } = render();
-
- userEvent.click(getByRole('button', { name: 'Save' }));
+ it('should hide save button when no changes are made', async () => {
+ const { queryByRole } = render();
- await waitFor(() =>
- expect(mockEnqueue).toHaveBeenCalledWith('No changes have been made', {
- variant: 'info',
- }),
- );
+ expect(queryByRole('button', { name: 'Save' })).not.toBeInTheDocument();
});
it('should render reminder data in table', async () => {
diff --git a/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.tsx b/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.tsx
index 2b6d6aa732..de19faf56f 100644
--- a/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.tsx
+++ b/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.tsx
@@ -89,38 +89,6 @@ export const PartnerRemindersReport: React.FC = ({
window.print();
};
- const handleSave = async (values: RowValues) => {
- const updates = Object.entries(values.status)
- .filter(([id, statusCd]) => initialValues.status[id] !== statusCd)
- .map(([id, statusCd]) => {
- return {
- rowId: id,
- statusCd,
- };
- });
-
- if (updates.length === 0) {
- enqueueSnackbar(t('No changes have been made'), { variant: 'info' });
- return;
- }
-
- await updateMutation({
- variables: {
- input: {
- accountListId: accountListId ?? '',
- designationNumber,
- updates,
- },
- },
- onCompleted: () => {
- enqueueSnackbar(t('Changes saved'), { variant: 'success' });
- },
- onError: () => {
- enqueueSnackbar(t('Error saving changes'), { variant: 'error' });
- },
- });
- };
-
const transformedData: ReminderData[] = useMemo(
() =>
reminders
@@ -157,13 +125,42 @@ export const PartnerRemindersReport: React.FC = ({
[transformedData],
);
+ const getUpdates = (values: RowValues) => {
+ return Object.entries(values.status)
+ .filter(([id, statusCd]) => initialValues.status[id] !== statusCd)
+ .map(([id, statusCd]) => {
+ return {
+ rowId: id,
+ statusCd,
+ };
+ });
+ };
+
+ const handleSave = async (values: RowValues) => {
+ await updateMutation({
+ variables: {
+ input: {
+ accountListId: accountListId ?? '',
+ designationNumber,
+ updates: getUpdates(values),
+ },
+ },
+ onCompleted: () => {
+ enqueueSnackbar(t('Changes saved'), { variant: 'success' });
+ },
+ onError: () => {
+ enqueueSnackbar(t('Error saving changes'), { variant: 'error' });
+ },
+ });
+ };
+
return (
initialValues={initialValues}
onSubmit={handleSave}
enableReinitialize
>
- {({ submitForm }) => (
+ {({ submitForm, values }) => (
= ({
- When you're done, click the "Save" button
- at the bottom of the page. Wondering how the{' '}
- Reminder System works and how it differs from the
- Receipting System? Check out{' '}
+ When you're done, a "Save" button will
+ appear at the top of the page. Click it to save your
+ changes. Wondering how the Reminder System works
+ and how it differs from the Receipting System? Check out{' '}
= ({
-
+ {getUpdates(values).length > 0 && (
+
+ )}