Skip to content

Commit

Permalink
Merge pull request #231 from nada-deriv/nada/bug-fixes
Browse files Browse the repository at this point in the history
fix: bug fixes
  • Loading branch information
farrah-deriv authored Aug 2, 2024
2 parents db7a958 + 75cfbf0 commit c28bb34
Show file tree
Hide file tree
Showing 35 changed files with 211 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const PreferredCountriesFooter = ({ isDisabled, onClickApply, onClickClear }: TP
return (
<div className='flex gap-[0.8rem] w-full'>
<Button
className='border-2'
color='black'
disabled={isDisabled}
isFullWidth
Expand Down
9 changes: 6 additions & 3 deletions src/components/PaymentMethodCard/PaymentMethodCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HTMLAttributes } from 'react';
import { ComponentProps, HTMLAttributes } from 'react';
import clsx from 'clsx';
import { TAdvertiserPaymentMethod, TPaymentMethod } from 'types';
import { LabelPairedPlusLgBoldIcon } from '@deriv/quill-icons';
Expand All @@ -18,6 +18,7 @@ type TPaymentMethodCardProps = HTMLAttributes<HTMLDivElement> & {
paymentMethod: { isAvailable?: boolean } & (TAdvertiserPaymentMethod | TPaymentMethod);
selectedPaymentMethodIds?: number[];
shouldShowPaymentMethodDisplayName?: boolean;
textSize?: ComponentProps<typeof Text>['size'];
};

const PaymentMethodCard = ({
Expand All @@ -31,6 +32,7 @@ const PaymentMethodCard = ({
paymentMethod,
selectedPaymentMethodIds = [],
shouldShowPaymentMethodDisplayName,
textSize,
}: TPaymentMethodCardProps) => {
const { display_name: displayName, isAvailable, type } = paymentMethod;

Expand All @@ -57,7 +59,7 @@ const PaymentMethodCard = ({
<Text size='sm'>{displayName}</Text>
</div>
) : (
<>
<div onClick={() => onSelectPaymentMethodCard?.(Number(paymentMethod.id))}>
<PaymentMethodCardHeader
isDisabled={isDisabled}
isEditable={isEditable}
Expand All @@ -72,8 +74,9 @@ const PaymentMethodCard = ({
<PaymentMethodCardBody
paymentMethod={paymentMethod}
shouldShowPaymentMethodDisplayName={shouldShowPaymentMethodDisplayName}
size={textSize}
/>
</>
</div>
)}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { ComponentProps } from 'react';
import { TAccount, TBankName, THooks, TName } from 'types';
import { Text, useDevice } from '@deriv-com/ui';
import './PaymentMethodCardBody.scss';

type TPaymentMethodCardBodyProps = {
paymentMethod: THooks.AdvertiserPaymentMethods.Get[number] | THooks.PaymentMethods.Get[number];
shouldShowPaymentMethodDisplayName?: boolean;
size?: ComponentProps<typeof Text>['size'];
};

const PaymentMethodCardBody = ({
paymentMethod,
shouldShowPaymentMethodDisplayName = true,
size,
}: TPaymentMethodCardBodyProps) => {
const displayName = paymentMethod?.display_name;
const modifiedDisplayName = displayName?.replace(/\s|-/gm, '');
Expand All @@ -18,7 +21,9 @@ const PaymentMethodCardBody = ({
const textSize = isMobile ? 'md' : 'sm';
return (
<div className='payment-method-card__body'>
{isBankOrOther && !shouldShowPaymentMethodDisplayName ? null : <Text size={textSize}>{displayName}</Text>}
{isBankOrOther && !shouldShowPaymentMethodDisplayName ? null : (
<Text size={size ?? textSize}>{displayName}</Text>
)}
<Text size={textSize}>
{(paymentMethod.fields?.bank_name as TBankName)?.value ?? (paymentMethod.fields?.name as TName)?.value}
</Text>
Expand Down
4 changes: 2 additions & 2 deletions src/components/PopoverDropdown/PopoverDropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
width: 19.5rem;
box-shadow: 0px 32px 64px 0px #0e0e0e24;
z-index: 999;
top: 2.8rem;
top: 3.8rem;
position: absolute;
background: #fff;
right: 0;
right: 1rem;

&-item {
padding: 1rem 1.6rem;
Expand Down
8 changes: 8 additions & 0 deletions src/components/Wizard/Wizard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@
width: inherit;
height: inherit;
max-width: 67.2rem;

@include mobile-or-tablet-screen {
height: 100%;

& .wizard__main-step {
height: 100%;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const useAdvertiserUpdate = () => {
} = useP2pAdvertiserUpdate({
onSuccess: () => {
invalidate('p2p_advertiser_info');
invalidate('p2p_advertiser_adverts');
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ jest.mock('@/hooks', () => ({
},
}));

const mockInvalidate = jest.fn();

jest.mock('../../api/useInvalidateQuery', () => () => mockInvalidate);
const mockUseGetInfo = api.advertiser.useGetInfo as jest.Mock;

describe('useIsAdvertiserBarred', () => {
Expand Down
10 changes: 8 additions & 2 deletions src/hooks/custom-hooks/useIsAdvertiserBarred.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import { useEffect, useState } from 'react';
import useInvalidateQuery from '../api/useInvalidateQuery';
import { api } from '..';

/**
* Custom hook to check if the current user is temporarily barred from using P2P.
* @returns {boolean} isAdvertiserBarred - True if the current user is temporarily barred from using P2P, false otherwise.
*/
const useIsAdvertiserBarred = (): boolean => {
const { data } = api.advertiser.useGetInfo();
const { data = {} } = api.advertiser.useGetInfo();
const [isAdvertiserBarred, setIsAdvertiserBarred] = useState(false);
const invalidate = useInvalidateQuery();

useEffect(() => {
invalidate('p2p_advertiser_adverts');
if (data.blocked_until) {
setIsAdvertiserBarred(true);
} else {
setIsAdvertiserBarred(false);
}
}, [data]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [data.blocked_until]);

return isAdvertiserBarred;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
width: 12.4rem;
}

&:hover:not(&--selected) {
background-color: #d6dadb;
cursor: pointer;
color: #ffffff;
}
&:active,
&--selected {
background-color: #999999;
border-color: #999999;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const AdConditionBlockElement = ({ isSelected, label, onClick, value }: TAdCondi
})}
onClick={() => onClick(value)}
>
<Text color={isSelected ? 'white' : 'prominent'} size={isDesktop ? 'md' : 'lg'}>
<Text color={isSelected ? 'white' : 'less-prominent'} size={isDesktop ? 'md' : 'lg'}>
{label}
</Text>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type TAdConditionBlockSelectorProps = {
const AdConditionBlockSelector = ({ onClick, selectedValue, type }: TAdConditionBlockSelectorProps) => {
const { localize } = useTranslations();
return (
<div className='flex flex-col gap-[0.8rem] mb-[2.4rem]'>
<div className='flex flex-col mb-[2.4rem]'>
<AdConditionContentHeader type={type} />
<div className='flex gap-[1.6rem]'>
{getAdConditionContent(localize)[type]?.options?.map(option => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ const AdConditionsSection = ({ countryList, currency, localCurrency, rateType, .

const onClickBlockSelector = (value: number, type: string) => {
if (type === AD_CONDITION_TYPES.JOINING_DATE) {
setValue('min-join-days', value);
if (getValues('min-join-days') === value) {
setValue('min-join-days', 0);
} else {
setValue('min-join-days', value);
}
} else if (getValues('min-completion-rate') === value) {
setValue('min-completion-rate', null);
} else {
setValue('min-completion-rate', value);
}
Expand All @@ -44,6 +50,7 @@ const AdConditionsSection = ({ countryList, currency, localCurrency, rateType, .
return (
<div className='ad-conditions-section'>
<AdSummary
adRateType={getValues('ad-rate-type')}
currency={currency}
localCurrency={localCurrency as TCurrency}
offerAmount={errors.amount ? '' : getValues('amount')}
Expand All @@ -52,7 +59,7 @@ const AdConditionsSection = ({ countryList, currency, localCurrency, rateType, .
type={getValues('ad-type')}
/>
<div className='flex flex-col my-[2.4rem]'>
<Text color='prominent' size={labelSize}>
<Text color='general' size={labelSize}>
<Localize i18n_default_text='Counterparty conditions (optional)' />
</Text>
<Text color='less-prominent' size={labelSize}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const AdPaymentDetailsSection = ({
return (
<div className='p-[1.6rem] w-full lg:p-0'>
<AdSummary
adRateType={getValues('ad-rate-type')}
currency={currency}
localCurrency={localCurrency as TCurrency}
offerAmount={errors.amount ? '' : getValues('amount')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const AdPaymentSelection = ({

return (
<>
<div className='mb-[2.4rem]'>
<div className='mb-[2.4rem] lg:mt-[3.2rem]'>
<Text as='div' color='prominent' size={textSize}>
<Localize i18n_default_text='Payment methods' />
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@include mobile-or-tablet-screen {
padding: 0 1.6rem;
overflow: auto;
max-height: calc(100vh - 20rem);
max-height: calc(100% - 20rem);
}

&--edit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
margin-top: -0.4rem;
margin-left: 1rem;
}

& .tooltip-menu-icon:hover {
background: none;
}
}
25 changes: 16 additions & 9 deletions src/pages/my-ads/components/AlertComponent/AlertComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import { TooltipMenuIcon } from '@/components/TooltipMenuIcon';
import { LegacyWarningIcon } from '@deriv/quill-icons';
import { Button, Tooltip } from '@deriv-com/ui';
import { useTranslations } from '@deriv-com/translations';
import './AlertComponent.scss';

type TAlertComponentProps = {
onClick: () => void;
};

const AlertComponent = ({ onClick }: TAlertComponentProps) => (
<div className='alert-component'>
<Tooltip message='Ad not listed' position='bottom'>
<Button className='p-0 hover:bg-none' color='white' onClick={onClick} variant='outlined'>
const AlertComponent = ({ onClick }: TAlertComponentProps) => {
const { localize } = useTranslations();
return (
<div className='alert-component'>
<TooltipMenuIcon
as='button'
onClick={onClick}
tooltipContent={localize('Ad not listed')}
tooltipPosition='top'
>
<LegacyWarningIcon data-testid='dt_alert_icon' iconSize='xs' />
</Button>
</Tooltip>
</div>
);
</TooltipMenuIcon>
</div>
);
};

export default AlertComponent;
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
.order-time-selection {
margin: 1rem 0;

& .deriv-dropdown {
&__items {
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.16);
}
& .deriv-input__container {
width: 100%;
}

& .deriv-dropdown__items--xs {
margin-top: 0.5rem;
max-height: 20rem;

@include mobile-or-tablet-screen {
width: 100%;
}
}
}
}

@include mobile-or-tablet-screen {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ const OrderTimeSelection = ({ orderExpiryOptions }: { orderExpiryOptions: TOrder
<Dropdown
className='items-center h-16'
dropdownIcon={<LabelPairedChevronDownMdRegularIcon />}
list={getOptions()}
isFullWidth={isDesktop}
list={getOptions().sort((a, b) => a.value - b.value)}
name='order-completion-time'
onSelect={onChange}
shouldClearValue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.preferred-countries-selector {
display: flex;
flex-direction: column;
gap: 0.8rem;

&__field {
display: flex;
Expand All @@ -12,6 +11,10 @@
border: 1px solid #d6dadb;
padding: 1rem 1.6rem;
cursor: pointer;
border-radius: 4px;
@include mobile-or-tablet-screen {
width: 100%;
}

&__text {
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const PreferredCountriesSelector = ({ countryList, type }: TPreferredCountriesSe
<div className='preferred-countries-selector__field' onClick={() => setIsModalOpen(true)}>
<Text
className='preferred-countries-selector__field__text'
color='less-prominent'
color={getValues('preferred-countries')?.length !== countries.length ? 'general' : 'less-prominent'}
size={isDesktop ? 'sm' : 'md'}
>
{getSelectedCountriesText()}
Expand All @@ -55,7 +55,10 @@ const PreferredCountriesSelector = ({ countryList, type }: TPreferredCountriesSe
setValue('preferred-countries', selectedValues);
setIsModalOpen(false);
}}
onRequestClose={() => setIsModalOpen(false)}
onRequestClose={() => {
setSelectedValues(getValues('preferred-countries'));
setIsModalOpen(false);
}}
selectedCountries={selectedValues}
setSelectedCountries={setSelectedValues}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
&__card {
display: inline-flex;
flex-wrap: wrap;

@include desktop {
& .payment-method-card--medium {
height: 11.4rem;
width: 16rem;
min-height: unset;
}
}
@include mobile-or-tablet-screen {
flex-wrap: nowrap;
width: calc(100vw - 3.2rem);
Expand Down Expand Up @@ -34,11 +42,17 @@
border: 1px dashed #d6dadb;
min-height: 12.8rem;

@include desktop {
width: 16rem;
height: 11.4rem;
min-height: unset;
}

@include mobile-or-tablet-screen {
margin-right: 0;
min-height: 8.8rem;
min-height: 10.6rem;
padding: 0.9rem 1rem;
min-width: 13.6rem;
min-width: 15.4rem;
}
}
}
Loading

0 comments on commit c28bb34

Please sign in to comment.