Skip to content

Commit

Permalink
Fix: Campaign status change - archive (#7749)
Browse files Browse the repository at this point in the history
  • Loading branch information
alaca authored Feb 20, 2025
1 parent 706f15c commit 2876666
Showing 1 changed file with 25 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,37 +157,36 @@ export default function CampaignsDetailsPage({campaignId}) {
}
};

const updateStatus = (status: 'archived' | 'draft') => {
const updateStatus = async (status: 'archived' | 'draft') => {
setValue('status', status);
handleSubmit(async (data) => {
edit(data);

try {
const response: Campaign = await save();
edit({...campaign, status})

setShow({
contextMenu: false,
confirmationModal: false,
});
reset(response);
try {
const response: Campaign = await save();

dispatch.addSnackbarNotice({
id: `update-${status}`,
content: getMessageByStatus(status),
});
} catch (err) {
setShow({
contextMenu: false,
confirmationModal: false,
});
setShow({
contextMenu: false,
confirmationModal: false,
});
reset(response);

dispatch.addSnackbarNotice({
id: 'update-error',
type: 'error',
content: __('Something went wrong', 'give'),
});
}
})();
dispatch.addSnackbarNotice({
id: `update-${status}`,
content: getMessageByStatus(status),
});
} catch (err) {
setShow({
contextMenu: false,
confirmationModal: false,
});

dispatch.addSnackbarNotice({
id: 'update-error',
type: 'error',
content: __('Something went wrong', 'give'),
});
}
};

if (!hasResolved) {
Expand Down

0 comments on commit 2876666

Please sign in to comment.