Princi Vershwal 2023-12-13 11:18:48 +05:30 committed by GitHub
parent c90e033fcf
commit 7d530406f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import {getOfferPortalPreviewUrl, offerPortalPreviewUrlTypes} from '../../../../
import {getPaidActiveTiers, useBrowseTiers} from '@tryghost/admin-x-framework/api/tiers';
import {getTiersCadences} from '../../../../utils/getTiersCadences';
import {useAddOffer} from '@tryghost/admin-x-framework/api/offers';
import {useBrowseOffers} from '@tryghost/admin-x-framework/api/offers';
import {useEffect, useMemo, useState} from 'react';
import {useGlobalData} from '../../../providers/GlobalDataProvider';
import {useModal} from '@ebay/nice-modal-react';
@ -364,6 +365,8 @@ const AddOfferModal = () => {
}
});
const {data: {offers: allOffers = []} = {}} = useBrowseOffers();
const {formState, updateForm, handleSave, saveState, okProps, validate, errors, clearError} = useForm({
initialState: {
disableBackground: false,
@ -592,7 +595,11 @@ const AddOfferModal = () => {
}, [hasOffers, modal, updateRoute]);
const cancelAddOffer = () => {
updateRoute('offers/edit');
if (allOffers.length > 0) {
updateRoute('offers/edit');
} else {
updateRoute('offers');
}
};
const overrides : offerPortalPreviewUrlTypes = useMemo(() => {

View File

@ -18,7 +18,7 @@ const OffersRouteHandler: React.FC<OffersRouteHandlerProps> = ({route}) => {
} else if (route.startsWith('offers/success/') && route.length > 'offers/success/'.length) {
const offerId = route.split('/').pop();
return <OfferSuccess id={offerId ? offerId : ''} />;
} else {
} else if (route === 'offers/edit') {
return <OffersIndexModal />;
}
};