From a81d80332450e0feb5e73e5bacd361d66cac61b1 Mon Sep 17 00:00:00 2001 From: Ronald Langeveld Date: Thu, 2 Nov 2023 15:36:16 +0700 Subject: [PATCH] Added offers modal toggle functions (#18839) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs https://github.com/TryGhost/Product/issues/4047 - Wired up Offers Modal hide / show toggling --- ### 🤖 Generated by Copilot at 42f000b This pull request enhances the offers feature in the admin settings by adding cancel buttons and navigation options to the modal components. It also refactors the `OffersModal` component to use the `AddOfferModal` component for creating new offers. --- .../membership/offers/AddOfferModal.tsx | 7 +++++- .../membership/offers/EditOfferModal.tsx | 5 +++- .../membership/offers/OffersModal.tsx | 23 +++++++++++++------ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/apps/admin-x-settings/src/components/settings/membership/offers/AddOfferModal.tsx b/apps/admin-x-settings/src/components/settings/membership/offers/AddOfferModal.tsx index d03baa9e54..bf517bb852 100644 --- a/apps/admin-x-settings/src/components/settings/membership/offers/AddOfferModal.tsx +++ b/apps/admin-x-settings/src/components/settings/membership/offers/AddOfferModal.tsx @@ -133,9 +133,14 @@ const AddOfferModal = () => { } }, [hasOffers, modal, updateRoute]); + const cancelAddOffer = () => { + modal.remove(); + updateRoute('offers/edit'); + }; + const sidebar = ; - return ; + return ; }; export default NiceModal.create(AddOfferModal); diff --git a/apps/admin-x-settings/src/components/settings/membership/offers/EditOfferModal.tsx b/apps/admin-x-settings/src/components/settings/membership/offers/EditOfferModal.tsx index 86880829ef..d216b19932 100644 --- a/apps/admin-x-settings/src/components/settings/membership/offers/EditOfferModal.tsx +++ b/apps/admin-x-settings/src/components/settings/membership/offers/EditOfferModal.tsx @@ -66,7 +66,10 @@ const EditOfferModal = () => { const sidebar = ; - return ; + return { + modal.remove(); + updateRoute('offers/edit'); + }} />; }; export default NiceModal.create(EditOfferModal); diff --git a/apps/admin-x-settings/src/components/settings/membership/offers/OffersModal.tsx b/apps/admin-x-settings/src/components/settings/membership/offers/OffersModal.tsx index 19ea516298..de2a1b618b 100644 --- a/apps/admin-x-settings/src/components/settings/membership/offers/OffersModal.tsx +++ b/apps/admin-x-settings/src/components/settings/membership/offers/OffersModal.tsx @@ -8,7 +8,7 @@ import {useEffect} from 'react'; export type OfferType = 'percent' | 'fixed' | 'trial'; -const OfferCard: React.FC<{name: string, type: OfferType}> = ({name, type}) => { +const OfferCard: React.FC<{name: string, type: OfferType, onClick: ()=>void}> = ({name, type, onClick}) => { let discountColor = ''; switch (type) { @@ -26,7 +26,7 @@ const OfferCard: React.FC<{name: string, type: OfferType}> = ({name, type}) => { } return
-

{name}

+

{name}

10% off @@ -58,7 +58,16 @@ const OffersModal = () => { {id: 'archived', title: 'Archived'} ]; - return + const handleOfferEdit = (id:string) => { + // TODO: implement + modal.remove(); + updateRoute(`offers/${id}`); + }; + + return { + modal.remove(); + updateRoute('offers'); + }}>
@@ -69,14 +78,14 @@ const OffersModal = () => { width='wide' onTabChange={() => {}} /> -

Active offers

- - - + handleOfferEdit('123')} /> + handleOfferEdit('123')} /> + handleOfferEdit('123')} />
→ Learn about offers in Ghost