From 696f364557db375fcca2f8ded08228c82b7aa630 Mon Sep 17 00:00:00 2001 From: Katelyn Grimes Date: Fri, 22 May 2026 11:07:20 -0400 Subject: [PATCH 1/2] Hide save button when no changes are made --- .../PartnerRemindersReport.test.tsx | 12 +--- .../PartnerRemindersReport.tsx | 71 +++++++++---------- 2 files changed, 38 insertions(+), 45 deletions(-) diff --git a/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.test.tsx b/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.test.tsx index f476f63cf4..7a8ec7c1ac 100644 --- a/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.test.tsx +++ b/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.test.tsx @@ -125,17 +125,11 @@ describe('PartnerRemindersReport', () => { await waitFor(() => expect(onNavListToggle).toHaveBeenCalled()); }); - it('should show saved snackbar when save is clicked with no changes', async () => { + it('should hide save button when no changes are made', async () => { mockEnqueue.mockClear(); - const { getByRole } = render(); - - userEvent.click(getByRole('button', { name: 'Save' })); + 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..8f4f1eae6d 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 }) => ( = ({ - + {getUpdates(values).length > 0 && ( + + )} From f2626b9a9abdb58f5c0880ee0d1ae76484faf18a Mon Sep 17 00:00:00 2001 From: Katelyn Grimes Date: Fri, 22 May 2026 11:40:35 -0400 Subject: [PATCH 2/2] Claude review suggestions --- .../PartnerRemindersReport.test.tsx | 1 - .../MinistryPartnerReminders/PartnerRemindersReport.tsx | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.test.tsx b/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.test.tsx index 7a8ec7c1ac..904b8e134d 100644 --- a/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.test.tsx +++ b/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.test.tsx @@ -126,7 +126,6 @@ describe('PartnerRemindersReport', () => { }); it('should hide save button when no changes are made', async () => { - mockEnqueue.mockClear(); const { queryByRole } = render(); expect(queryByRole('button', { name: 'Save' })).not.toBeInTheDocument(); diff --git a/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.tsx b/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.tsx index 8f4f1eae6d..de19faf56f 100644 --- a/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.tsx +++ b/src/components/HrTools/MinistryPartnerReminders/PartnerRemindersReport.tsx @@ -213,10 +213,10 @@ export const PartnerRemindersReport: React.FC = ({ - 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{' '}