From d5e808934a732c878239be1939f814c0a508e359 Mon Sep 17 00:00:00 2001 From: Nada Date: Mon, 5 Aug 2024 12:37:11 +0400 Subject: [PATCH 1/6] fix: redirect to first step on create ad error --- .../AdConditionsSection.tsx | 51 +++++++++++++++---- .../my-ads/components/AdStatus/AdStatus.scss | 8 +-- .../my-ads/components/AdStatus/AdStatus.tsx | 2 +- .../my-ads/components/AdWizard/AdWizard.tsx | 15 ++++-- .../AlertComponent/AlertComponent.scss | 2 +- .../screens/CreateEditAd/CreateEditAd.tsx | 41 +++++++++------ .../screens/MyAds/MyAdsTable/MyAdsTable.scss | 2 +- .../MyAds/MyAdsTableRow/MyAdsTableRow.scss | 2 +- types.ts | 7 +++ 9 files changed, 94 insertions(+), 36 deletions(-) diff --git a/src/pages/my-ads/components/AdConditionsSection/AdConditionsSection.tsx b/src/pages/my-ads/components/AdConditionsSection/AdConditionsSection.tsx index 49bb0107..1d395ba1 100644 --- a/src/pages/my-ads/components/AdConditionsSection/AdConditionsSection.tsx +++ b/src/pages/my-ads/components/AdConditionsSection/AdConditionsSection.tsx @@ -1,6 +1,6 @@ -import { MouseEventHandler } from 'react'; +import { MouseEventHandler, useEffect } from 'react'; import { useFormContext } from 'react-hook-form'; -import { TCountryListItem, TCurrency } from 'types'; +import { TCountryListItem, TCurrency, TInitialData } from 'types'; import { AD_CONDITION_TYPES } from '@/constants'; import { isEmptyObject } from '@/utils'; import { Localize } from '@deriv-com/translations'; @@ -16,19 +16,24 @@ type TAdConditionsSection = { currency: TCurrency; getCurrentStep: () => number; getTotalSteps: () => number; + goToFirstStep: () => void; goToNextStep: MouseEventHandler; goToPreviousStep: () => void; - initialPaymentMethods: number[] | string[]; + initialData: TInitialData; localCurrency?: TCurrency; rateType: string; + setShouldReset: (shouldReset: boolean) => void; + shouldReset: boolean; }; const AdConditionsSection = ({ countryList, currency, - initialPaymentMethods, + initialData, localCurrency, rateType, + setShouldReset, + shouldReset, ...props }: TAdConditionsSection) => { const { @@ -41,14 +46,22 @@ const AdConditionsSection = ({ const selectedMethods = getValues('payment-method') ?? []; const labelSize = isDesktop ? 'sm' : 'md'; + useEffect(() => { + if (shouldReset) { + props.goToFirstStep(); + setShouldReset(false); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [shouldReset]); + const onClickBlockSelector = (value: number, type: string) => { if (type === AD_CONDITION_TYPES.JOINING_DATE) { - if (getValues('min-join-days') === value) { - setValue('min-join-days', 0); + if (getValues('min-join-days') == value) { + setValue('min-join-days', null); } else { setValue('min-join-days', value); } - } else if (getValues('min-completion-rate') === value) { + } else if (getValues('min-completion-rate') == value) { setValue('min-completion-rate', null); } else { setValue('min-completion-rate', value); @@ -59,8 +72,19 @@ const AdConditionsSection = ({ const minCompletionRate = watch('min-completion-rate'); const isPaymentMethodsSame = () => - initialPaymentMethods.length === selectedMethods.length && - initialPaymentMethods.sort().every((value, index) => value === selectedMethods.sort()[index]); + initialData?.paymentMethod.length === selectedMethods.length && + initialData?.paymentMethod.sort().every((value, index) => value === selectedMethods.sort()[index]); + + const isMinCompletionRateSame = () => (minCompletionRate?.toString() ?? null) === initialData.minCompletionRate; + + const isMinJoinDaysSame = () => (minJoinDays?.toString() ?? null) === initialData.minJoinDays; + + const isPreferredCountriesSame = () => + initialData?.selectedCountries.length === watch('preferred-countries').length && + initialData?.selectedCountries + .sort() + .every((value, index) => value === watch('preferred-countries').sort()[index]); + return (
); diff --git a/src/pages/my-ads/components/AdStatus/AdStatus.scss b/src/pages/my-ads/components/AdStatus/AdStatus.scss index af5f0832..9f63398d 100644 --- a/src/pages/my-ads/components/AdStatus/AdStatus.scss +++ b/src/pages/my-ads/components/AdStatus/AdStatus.scss @@ -19,11 +19,14 @@ } .ad-status { + margin-left: -2rem; + width: fit-content; + @include desktop { + max-width: 12rem; + } &--active { @include ad-status-base(#4bb4b3); - width: fit-content; - @include mobile-or-tablet-screen { margin-bottom: 0.8rem; padding: 0.2rem 1rem; @@ -37,6 +40,5 @@ margin-bottom: 0.8rem; padding: 0.2rem 1rem; } - width: fit-content; } } diff --git a/src/pages/my-ads/components/AdStatus/AdStatus.tsx b/src/pages/my-ads/components/AdStatus/AdStatus.tsx index 635e0be6..74491206 100644 --- a/src/pages/my-ads/components/AdStatus/AdStatus.tsx +++ b/src/pages/my-ads/components/AdStatus/AdStatus.tsx @@ -12,7 +12,7 @@ const AdStatus = ({ isActive = false }: TAdStatusProps) => { return ( void; orderExpiryOptions: TOrderExpiryOptions; rateType: string; + setShouldReset: (shouldReset: boolean) => void; + shouldReset: boolean; steps: TStep[]; }; const AdWizard = ({ countryList, - initialPaymentMethods, + initialData, onCancel, orderExpiryOptions, + setShouldReset, + shouldReset, steps, ...rest }: TAdWizardNav) => { @@ -34,6 +38,7 @@ const AdWizard = ({ const wizardProps = { getCurrentStep: () => currentStep + 1, getTotalSteps: () => steps.length, + goToFirstStep: () => setCurrentStep(0), goToNextStep: () => setCurrentStep(currentStep + 1), goToPreviousStep: () => setCurrentStep(currentStep - 1), }; @@ -82,8 +87,10 @@ const AdWizard = ({ ); diff --git a/src/pages/my-ads/components/AlertComponent/AlertComponent.scss b/src/pages/my-ads/components/AlertComponent/AlertComponent.scss index 11dd18b4..f5eb5c0a 100644 --- a/src/pages/my-ads/components/AlertComponent/AlertComponent.scss +++ b/src/pages/my-ads/components/AlertComponent/AlertComponent.scss @@ -3,7 +3,7 @@ justify-content: center; position: absolute; align-items: center; - right: 4.2rem; + right: 3.6rem; height: 100%; span { diff --git a/src/pages/my-ads/screens/CreateEditAd/CreateEditAd.tsx b/src/pages/my-ads/screens/CreateEditAd/CreateEditAd.tsx index 14359d23..a11081aa 100644 --- a/src/pages/my-ads/screens/CreateEditAd/CreateEditAd.tsx +++ b/src/pages/my-ads/screens/CreateEditAd/CreateEditAd.tsx @@ -1,7 +1,7 @@ import { useCallback, useEffect, useState } from 'react'; import { FormProvider, useForm } from 'react-hook-form'; import { useHistory } from 'react-router-dom'; -import { NonUndefinedValues, TCountryListItem, TCurrency, TErrorCodes, THooks, TLocalize } from 'types'; +import { NonUndefinedValues, TCountryListItem, TCurrency, TErrorCodes, THooks, TInitialData, TLocalize } from 'types'; import { AdCancelCreateEditModal, AdCreateEditErrorModal, AdCreateEditSuccessModal } from '@/components/Modals'; import { MY_ADS_URL, RATE_TYPE } from '@/constants'; import { api } from '@/hooks'; @@ -45,9 +45,10 @@ type TMutatePayload = Parameters[0]; type TFormValuesInfo = NonUndefinedValues; const CreateEditAd = () => { - const [initialPaymentMethods, setInitialPaymentMethods] = useState([]); + const [initialData, setInitialData] = useState({} as TInitialData); const { queryString } = useQueryString(); const { localize } = useTranslations(); + const [shouldReset, setShouldReset] = useState(false); const { advertId = '' } = queryString; const { data: advertInfo, isLoading } = api.advert.useGet({ id: advertId ?? undefined }, !!advertId, false); const isEdit = !!advertId; @@ -113,8 +114,8 @@ const CreateEditAd = () => { description?: string; eligible_countries: string[]; max_order_amount: number; - min_completion_rate?: number; - min_join_days?: number; + min_completion_rate?: number | null; + min_join_days?: number | null; min_order_amount: number; order_expiry_period: number; payment_method_ids?: TMutatePayload['payment_method_ids']; @@ -143,12 +144,12 @@ const CreateEditAd = () => { if (getValues('instructions')) { payload.description = getValues('instructions'); } - if (getValues('min-completion-rate')) { - payload.min_completion_rate = Number(getValues('min-completion-rate')); - } - if (getValues('min-join-days')) { - payload.min_join_days = Number(getValues('min-join-days')); - } + + payload.min_completion_rate = getValues('min-completion-rate') + ? Number(getValues('min-completion-rate')) + : null; + + payload.min_join_days = getValues('min-join-days') ? Number(getValues('min-join-days')) : null; if (isEdit) { delete payload.amount; @@ -194,8 +195,8 @@ const CreateEditAd = () => { 'form-type': 'edit' as const, instructions: formValues.description, 'max-order': formValues.max_order_amount.toString(), - 'min-completion-rate': formValues.min_completion_rate?.toString() ?? '', - 'min-join-days': formValues.min_join_days?.toString() ?? '', + 'min-completion-rate': formValues.min_completion_rate?.toString() ?? null, + 'min-join-days': formValues.min_join_days?.toString() ?? null, 'min-order': formValues.min_order_amount.toString(), 'order-completion-time': `${formValues.order_expiry_period}`, 'payment-method': @@ -210,7 +211,12 @@ const CreateEditAd = () => { // Use reset to set default values and mark the form as not dirty reset(defaultValues); - setInitialPaymentMethods(defaultValues['payment-method']); + setInitialData({ + minCompletionRate: defaultValues['min-completion-rate'], + minJoinDays: defaultValues['min-join-days'], + paymentMethod: defaultValues['payment-method'], + selectedCountries: defaultValues['preferred-countries'], + }); }, // eslint-disable-next-line react-hooks/exhaustive-deps [paymentMethodList, countryList] @@ -239,11 +245,13 @@ const CreateEditAd = () => { @@ -252,7 +260,10 @@ const CreateEditAd = () => { errorCode={(error?.code || updateError?.code) as TErrorCodes} errorMessage={(error?.message || updateError?.message) ?? 'Something’s not right'} isModalOpen={!!isModalOpenFor('AdCreateEditErrorModal')} - onRequestClose={hideModal} + onRequestClose={() => { + setShouldReset(true); + hideModal(); + }} /> Date: Mon, 5 Aug 2024 12:41:53 +0400 Subject: [PATCH 2/6] fix: daily buy limit, sell limit --- .../Modals/AdErrorTooltipModal/AdErrorTooltipModal.tsx | 8 ++++---- .../my-ads/screens/MyAds/MyAdsTable/MyAdsTable.tsx | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/Modals/AdErrorTooltipModal/AdErrorTooltipModal.tsx b/src/components/Modals/AdErrorTooltipModal/AdErrorTooltipModal.tsx index 8d7da0b0..f49ef62b 100644 --- a/src/components/Modals/AdErrorTooltipModal/AdErrorTooltipModal.tsx +++ b/src/components/Modals/AdErrorTooltipModal/AdErrorTooltipModal.tsx @@ -10,8 +10,8 @@ type TAdErrorTooltipModal = { accountCurrency: string; advertType: string; balanceAvailable: number; - dailyBuyLimit: string; - dailySellLimit: string; + dailyBuyLimit: number; + dailySellLimit: number; isModalOpen: boolean; onRequestClose: () => void; remainingAmount: number; @@ -24,8 +24,8 @@ const getAdErrorMessage = ( remainingAmount: number, balanceAvailable: number, advertType: string, - dailyBuyLimit: string, - dailySellLimit: string, + dailyBuyLimit: number, + dailySellLimit: number, onLiveChatClick: () => void ): string => { const errorMessages: { [key: string]: ReactNode | string } = { diff --git a/src/pages/my-ads/screens/MyAds/MyAdsTable/MyAdsTable.tsx b/src/pages/my-ads/screens/MyAds/MyAdsTable/MyAdsTable.tsx index c87f678d..dc023746 100644 --- a/src/pages/my-ads/screens/MyAds/MyAdsTable/MyAdsTable.tsx +++ b/src/pages/my-ads/screens/MyAds/MyAdsTable/MyAdsTable.tsx @@ -15,8 +15,8 @@ type TAdvertiserPaymentMethods = THooks.AdvertiserPaymentMethods.Get; export type TMyAdsTableRowRendererProps = NonUndefined[0] & { advertiserPaymentMethods: TAdvertiserPaymentMethods; balanceAvailable: number; - dailyBuyLimit: string; - dailySellLimit: string; + dailyBuyLimit: number; + dailySellLimit: number; isBarred: boolean; isListed: boolean; }; @@ -54,7 +54,9 @@ const MyAdsTable = () => { const { balance_available: balanceAvailable, blocked_until: blockedUntil, + daily_buy: dailyBuy, daily_buy_limit: dailyBuyLimit, + daily_sell: dailySell, daily_sell_limit: dailySellLimit, isListedBoolean: isListed, } = advertiserInfo || {}; @@ -88,8 +90,8 @@ const MyAdsTable = () => { {...(rowData as TMyAdsTableRowRendererProps)} advertiserPaymentMethods={advertiserPaymentMethods as TAdvertiserPaymentMethods} balanceAvailable={balanceAvailable ?? 0} - dailyBuyLimit={dailyBuyLimit ?? ''} - dailySellLimit={dailySellLimit ?? ''} + dailyBuyLimit={Number(dailyBuyLimit) - Number(dailyBuy) ?? 0} + dailySellLimit={Number(dailySellLimit) - Number(dailySell) ?? 0} isBarred={!!blockedUntil} isListed={!!isListed} /> From 285624d7fc2073cb16ec33b8ab3f518e6b732abd Mon Sep 17 00:00:00 2001 From: Nada Date: Mon, 5 Aug 2024 12:52:50 +0400 Subject: [PATCH 3/6] fix: fix build --- .../__tests__/AdErrorTooltipModal.spec.tsx | 4 ++-- .../__tests__/AdConditionsSection.spec.tsx | 10 +++++++++- .../components/AdWizard/__tests__/AdWizard.spec.tsx | 9 ++++++++- .../my-ads/screens/MyAds/MyAdsTable/MyAdsTable.tsx | 12 ++++++------ .../__tests__/MyAdsTableRowView.spec.tsx | 4 ++-- types.ts | 4 ++-- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/components/Modals/AdErrorTooltipModal/__tests__/AdErrorTooltipModal.spec.tsx b/src/components/Modals/AdErrorTooltipModal/__tests__/AdErrorTooltipModal.spec.tsx index 810a1497..6a54d2f3 100644 --- a/src/components/Modals/AdErrorTooltipModal/__tests__/AdErrorTooltipModal.spec.tsx +++ b/src/components/Modals/AdErrorTooltipModal/__tests__/AdErrorTooltipModal.spec.tsx @@ -5,8 +5,8 @@ const mockProps = { accountCurrency: 'USD', advertType: 'buy', balanceAvailable: 100, - dailyBuyLimit: '150', - dailySellLimit: '230', + dailyBuyLimit: 150, + dailySellLimit: 230, isModalOpen: true, onRequestClose: jest.fn(), remainingAmount: 100, diff --git a/src/pages/my-ads/components/AdConditionsSection/__tests__/AdConditionsSection.spec.tsx b/src/pages/my-ads/components/AdConditionsSection/__tests__/AdConditionsSection.spec.tsx index 685321b6..5dc2dba7 100644 --- a/src/pages/my-ads/components/AdConditionsSection/__tests__/AdConditionsSection.spec.tsx +++ b/src/pages/my-ads/components/AdConditionsSection/__tests__/AdConditionsSection.spec.tsx @@ -8,11 +8,19 @@ const mockProps = { currency: 'USD' as TCurrency, getCurrentStep: jest.fn(), getTotalSteps: jest.fn(), + goToFirstStep: jest.fn(), goToNextStep: jest.fn(), goToPreviousStep: jest.fn(), - initialPaymentMethods: [], + initialData: { + minCompletionRate: null, + minJoinDays: null, + paymentMethod: [], + selectedCountries: [], + }, localCurrency: 'USD' as TCurrency, rateType: 'fixed', + setShouldReset: jest.fn(), + shouldReset: false, }; jest.mock('@deriv-com/ui', () => ({ diff --git a/src/pages/my-ads/components/AdWizard/__tests__/AdWizard.spec.tsx b/src/pages/my-ads/components/AdWizard/__tests__/AdWizard.spec.tsx index 797572ea..e2e5d6df 100644 --- a/src/pages/my-ads/components/AdWizard/__tests__/AdWizard.spec.tsx +++ b/src/pages/my-ads/components/AdWizard/__tests__/AdWizard.spec.tsx @@ -28,11 +28,18 @@ jest.mock('../../AdProgressBar', () => ({ const mockProps = { countryList: {}, currency: 'usd' as TCurrency, - initialPaymentMethods: [], + initialData: { + minCompletionRate: null, + minJoinDays: null, + paymentMethod: [], + selectedCountries: [], + }, localCurrency: 'usd' as TCurrency, onCancel: jest.fn(), orderExpiryOptions: [900, 1800], rateType: 'float', + setShouldReset: jest.fn(), + shouldReset: false, steps: [{ header: { title: 'step 1' } }, { header: { title: 'step 2' } }, { header: { title: 'step 3' } }], }; diff --git a/src/pages/my-ads/screens/MyAds/MyAdsTable/MyAdsTable.tsx b/src/pages/my-ads/screens/MyAds/MyAdsTable/MyAdsTable.tsx index dc023746..e758a233 100644 --- a/src/pages/my-ads/screens/MyAds/MyAdsTable/MyAdsTable.tsx +++ b/src/pages/my-ads/screens/MyAds/MyAdsTable/MyAdsTable.tsx @@ -54,10 +54,10 @@ const MyAdsTable = () => { const { balance_available: balanceAvailable, blocked_until: blockedUntil, - daily_buy: dailyBuy, - daily_buy_limit: dailyBuyLimit, - daily_sell: dailySell, - daily_sell_limit: dailySellLimit, + daily_buy: dailyBuy = 0, + daily_buy_limit: dailyBuyLimit = 0, + daily_sell: dailySell = 0, + daily_sell_limit: dailySellLimit = 0, isListedBoolean: isListed, } = advertiserInfo || {}; const { mutate: updateAds } = api.advertiser.useUpdate(); @@ -90,8 +90,8 @@ const MyAdsTable = () => { {...(rowData as TMyAdsTableRowRendererProps)} advertiserPaymentMethods={advertiserPaymentMethods as TAdvertiserPaymentMethods} balanceAvailable={balanceAvailable ?? 0} - dailyBuyLimit={Number(dailyBuyLimit) - Number(dailyBuy) ?? 0} - dailySellLimit={Number(dailySellLimit) - Number(dailySell) ?? 0} + dailyBuyLimit={Number(dailyBuyLimit) - Number(dailyBuy)} + dailySellLimit={Number(dailySellLimit) - Number(dailySell)} isBarred={!!blockedUntil} isListed={!!isListed} /> diff --git a/src/pages/my-ads/screens/MyAds/MyAdsTableRow/__tests__/MyAdsTableRowView.spec.tsx b/src/pages/my-ads/screens/MyAds/MyAdsTableRow/__tests__/MyAdsTableRowView.spec.tsx index ec1578f5..7cffd66f 100644 --- a/src/pages/my-ads/screens/MyAds/MyAdsTableRow/__tests__/MyAdsTableRowView.spec.tsx +++ b/src/pages/my-ads/screens/MyAds/MyAdsTableRow/__tests__/MyAdsTableRowView.spec.tsx @@ -35,8 +35,8 @@ const mockProps = { country: 'id', created_time: new Date(1688460999), currentRateType: 'fixed' as const, - dailyBuyLimit: '', - dailySellLimit: '', + dailyBuyLimit: 0, + dailySellLimit: 0, days_until_archive: 1, description: '', effective_rate: 22, diff --git a/types.ts b/types.ts index 4856bd85..ac9562db 100644 --- a/types.ts +++ b/types.ts @@ -227,8 +227,8 @@ export type TOrderIdsMap = { }; export type TInitialData = { - minCompletionRate: string; - minJoinDays: string; + minCompletionRate: string | null; + minJoinDays: string | null; paymentMethod: number[] | string[]; selectedCountries: string[]; }; From f02bed60f41766cb7eeb097617d1abae34e0c324 Mon Sep 17 00:00:00 2001 From: Nada Date: Mon, 5 Aug 2024 13:01:24 +0400 Subject: [PATCH 4/6] fix: failing test --- .../components/AdConditionsSection/AdConditionsSection.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pages/my-ads/components/AdConditionsSection/AdConditionsSection.tsx b/src/pages/my-ads/components/AdConditionsSection/AdConditionsSection.tsx index 1d395ba1..fe117214 100644 --- a/src/pages/my-ads/components/AdConditionsSection/AdConditionsSection.tsx +++ b/src/pages/my-ads/components/AdConditionsSection/AdConditionsSection.tsx @@ -44,6 +44,7 @@ const AdConditionsSection = ({ } = useFormContext(); const { isDesktop } = useDevice(); const selectedMethods = getValues('payment-method') ?? []; + const preferedCountries = getValues('preferred-countries') ?? []; const labelSize = isDesktop ? 'sm' : 'md'; useEffect(() => { @@ -80,10 +81,8 @@ const AdConditionsSection = ({ const isMinJoinDaysSame = () => (minJoinDays?.toString() ?? null) === initialData.minJoinDays; const isPreferredCountriesSame = () => - initialData?.selectedCountries.length === watch('preferred-countries').length && - initialData?.selectedCountries - .sort() - .every((value, index) => value === watch('preferred-countries').sort()[index]); + initialData?.selectedCountries.length === preferedCountries.length && + initialData?.selectedCountries.sort().every((value, index) => value === preferedCountries.sort()[index]); return (
From dd16b4fc33a50b11425dd0e2ce8eb891bf7a8a9c Mon Sep 17 00:00:00 2001 From: Nada Date: Mon, 5 Aug 2024 13:10:10 +0400 Subject: [PATCH 5/6] fix: create ad issue --- .../AdConditionsSection/AdConditionsSection.tsx | 10 +++++----- src/pages/my-ads/screens/CreateEditAd/CreateEditAd.tsx | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/pages/my-ads/components/AdConditionsSection/AdConditionsSection.tsx b/src/pages/my-ads/components/AdConditionsSection/AdConditionsSection.tsx index fe117214..dc345e0c 100644 --- a/src/pages/my-ads/components/AdConditionsSection/AdConditionsSection.tsx +++ b/src/pages/my-ads/components/AdConditionsSection/AdConditionsSection.tsx @@ -44,7 +44,7 @@ const AdConditionsSection = ({ } = useFormContext(); const { isDesktop } = useDevice(); const selectedMethods = getValues('payment-method') ?? []; - const preferedCountries = getValues('preferred-countries') ?? []; + const preferedCountries = watch('preferred-countries') ?? []; const labelSize = isDesktop ? 'sm' : 'md'; useEffect(() => { @@ -73,16 +73,16 @@ const AdConditionsSection = ({ const minCompletionRate = watch('min-completion-rate'); const isPaymentMethodsSame = () => - initialData?.paymentMethod.length === selectedMethods.length && - initialData?.paymentMethod.sort().every((value, index) => value === selectedMethods.sort()[index]); + initialData.paymentMethod?.length === selectedMethods.length && + initialData.paymentMethod?.sort().every((value, index) => value === selectedMethods.sort()[index]); const isMinCompletionRateSame = () => (minCompletionRate?.toString() ?? null) === initialData.minCompletionRate; const isMinJoinDaysSame = () => (minJoinDays?.toString() ?? null) === initialData.minJoinDays; const isPreferredCountriesSame = () => - initialData?.selectedCountries.length === preferedCountries.length && - initialData?.selectedCountries.sort().every((value, index) => value === preferedCountries.sort()[index]); + initialData?.selectedCountries?.length === preferedCountries.length && + initialData?.selectedCountries?.sort().every((value, index) => value === preferedCountries.sort()[index]); return (
diff --git a/src/pages/my-ads/screens/CreateEditAd/CreateEditAd.tsx b/src/pages/my-ads/screens/CreateEditAd/CreateEditAd.tsx index a11081aa..c494b5ce 100644 --- a/src/pages/my-ads/screens/CreateEditAd/CreateEditAd.tsx +++ b/src/pages/my-ads/screens/CreateEditAd/CreateEditAd.tsx @@ -151,6 +151,11 @@ const CreateEditAd = () => { payload.min_join_days = getValues('min-join-days') ? Number(getValues('min-join-days')) : null; + if (!isEdit) { + if (!payload.min_completion_rate) delete payload.min_completion_rate; + if (!payload.min_join_days) delete payload.min_join_days; + } + if (isEdit) { delete payload.amount; delete payload.type; From 99a5ef4b662646267474b5bc15d7c42cdad82a0b Mon Sep 17 00:00:00 2001 From: Nada Date: Mon, 5 Aug 2024 16:14:50 +0400 Subject: [PATCH 6/6] fix: instructions trim issue, contact info not shown --- src/components/CopyAdForm/CopyAdForm.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/CopyAdForm/CopyAdForm.tsx b/src/components/CopyAdForm/CopyAdForm.tsx index 3bf3ae45..ebca9301 100644 --- a/src/components/CopyAdForm/CopyAdForm.tsx +++ b/src/components/CopyAdForm/CopyAdForm.tsx @@ -39,6 +39,7 @@ const CopyAdForm = ({ formValues, isModalOpen, onClickCancel, onFormSubmit, ...r const { account_currency: currency, amount, + contact_info: contactInfo, description, eligible_countries: eligibleCountries = [], local_currency: localCurrency, @@ -209,11 +210,23 @@ const CopyAdForm = ({ formValues, isModalOpen, onClickCancel, onFormSubmit, ...r triggerValidationFunction={() => triggerValidation(['amount', 'min-order'])} />
+ {type === 'sell' && ( +
+ + + + + {contactInfo || '-'} + +
+ )}
- {description || '-'} + + {description || '-'} +