From 830967d2ed7f531c54429537143fac2813e44460 Mon Sep 17 00:00:00 2001 From: Princi Vershwal Date: Wed, 13 Dec 2023 12:46:26 +0530 Subject: [PATCH] Edit cancle button fix (#19350) Fixes: [PROD-213](https://linear.app/tryghost/issue/PROD-213/cancelling-should-act-two-ways-when-the-modal-is-opened-from-the-list) --- .../src/components/settings/growth/Offers.tsx | 1 + .../components/settings/growth/offers/EditOfferModal.tsx | 8 +++++++- .../src/components/settings/growth/offers/OffersIndex.tsx | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/admin-x-settings/src/components/settings/growth/Offers.tsx b/apps/admin-x-settings/src/components/settings/growth/Offers.tsx index 4ac3765293..30a1824e78 100644 --- a/apps/admin-x-settings/src/components/settings/growth/Offers.tsx +++ b/apps/admin-x-settings/src/components/settings/growth/Offers.tsx @@ -57,6 +57,7 @@ const Offers: React.FC<{ keywords: string[] }> = ({keywords}) => { }; const goToOfferEdit = (offerId: string) => { + sessionStorage.setItem('editOfferPageSource', 'offers'); updateRoute(`offers/edit/${offerId}`); }; diff --git a/apps/admin-x-settings/src/components/settings/growth/offers/EditOfferModal.tsx b/apps/admin-x-settings/src/components/settings/growth/offers/EditOfferModal.tsx index cbd8317b2c..7f5d9a3d2e 100644 --- a/apps/admin-x-settings/src/components/settings/growth/offers/EditOfferModal.tsx +++ b/apps/admin-x-settings/src/components/settings/growth/offers/EditOfferModal.tsx @@ -269,7 +269,13 @@ const EditOfferModal: React.FC<{id: string}> = ({id}) => { title='Offer' width={1140} onCancel={() => { - updateRoute('offers/edit'); + if (sessionStorage.getItem('editOfferPageSource') === 'offers') { + sessionStorage.removeItem('editOfferPageSource'); + updateRoute('offers'); + } else { + sessionStorage.removeItem('editOfferPageSource'); + updateRoute('offers/edit'); + } }} onOk={async () => { if (!(await handleSave({fakeWhenUnchanged: true}))) { diff --git a/apps/admin-x-settings/src/components/settings/growth/offers/OffersIndex.tsx b/apps/admin-x-settings/src/components/settings/growth/offers/OffersIndex.tsx index d90d1b990c..c167a94b35 100644 --- a/apps/admin-x-settings/src/components/settings/growth/offers/OffersIndex.tsx +++ b/apps/admin-x-settings/src/components/settings/growth/offers/OffersIndex.tsx @@ -126,6 +126,7 @@ export const OffersIndexModal = () => { const handleOfferEdit = (id:string) => { // TODO: implement + sessionStorage.setItem('editOfferPageSource', 'offersIndex'); updateRoute(`offers/edit/${id}`); };