Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

farrah/FEQ-2543/fix: rate and button issues #240

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/AdvertsTableRow/AdvertsTableRow.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.adverts-table-row {
width: 100%;
display: grid;
grid-template-columns: 2fr 1.4fr 1.4fr 2.4fr auto;
grid-template-columns: 2fr 1.4fr 1.4fr 2.4fr 1.4fr;
padding: 1.6rem;
align-items: center;

Expand Down
2 changes: 1 addition & 1 deletion src/components/BuySellForm/BuySellForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const BuySellForm = ({ advertId, isModalOpen, onRequestClose }: TBuySellFormProp
const [buySellAmount, setBuySellAmount] = useState('0');

const {
account_currency: accountCurrency,
account_currency: accountCurrency = '',
advertiser_details: advertiserDetails,
description,
effective_rate: adEffectiveRate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
&__header {
padding: 1.6rem;
border-bottom: 1px solid #f2f3f4;
grid-template-columns: 2fr 1.4fr 1.4fr 2.4fr 0.8fr;
grid-template-columns: 2fr 1.4fr 1.4fr 2.4fr 1.4fr;
}

&__content {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const OrderDetailsCardFooter = ({ sendFile }: { sendFile: (file: File) => void }
};

return (
<div className='order-details-card-footer'>
<div className='order-details-card-footer justify-end'>
{shouldShowCancelAndPaidButton && (
<div className='flex gap-3 ml-auto'>
<Button
Expand All @@ -168,43 +168,22 @@ const OrderDetailsCardFooter = ({ sendFile }: { sendFile: (file: File) => void }
</Button>
</div>
)}
{shouldShowComplainAndReceivedButton && (
<div className='flex gap-[0.8rem] justify-end w-full'>
<Button
className='border-2'
color='primary-light'
onClick={() => showModal('OrderDetailsComplainModal')}
size='lg'
textSize={textSize}
variant='ghost'
>
<Localize i18n_default_text='Complain' />
</Button>
<Button onClick={() => mutate({ id })} size='lg' textSize={textSize}>
<Localize i18n_default_text='I’ve received payment' />
</Button>
</div>
)}
{shouldShowOnlyComplainButton && (
<div className='ml-auto'>
<Button
className='border-2'
color='primary-light'
onClick={() => showModal('OrderDetailsComplainModal')}
size='lg'
textSize={textSize}
variant='ghost'
>
<Localize i18n_default_text='Complain' />
</Button>
</div>
{(shouldShowOnlyComplainButton || shouldShowComplainAndReceivedButton) && (
<Button
className='border-2 mr-[0.8rem]'
color='primary-light'
onClick={() => showModal('OrderDetailsComplainModal')}
size='lg'
textSize={textSize}
variant='ghost'
>
<Localize i18n_default_text='Complain' />
</Button>
)}
{shouldShowOnlyReceivedButton && (
<div className='ml-auto'>
<Button onClick={() => mutate({ id })} size='lg' textSize={textSize}>
<Localize i18n_default_text='I’ve received payment' />
</Button>
</div>
{(shouldShowOnlyReceivedButton || shouldShowComplainAndReceivedButton) && (
<Button onClick={() => mutate({ id })} size='lg' textSize={textSize}>
<Localize i18n_default_text='I’ve received payment' />
</Button>
)}
{!!isModalOpenFor('OrderDetailsComplainModal') && (
<OrderDetailsComplainModal
Expand Down
18 changes: 11 additions & 7 deletions src/utils/format-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,20 @@ export const generateEffectiveRate = ({

if (rateType === RATE_TYPE.FIXED) {
effectiveRate = price;
displayEffectiveRate = FormatUtils.formatMoney(effectiveRate, { currency: localCurrency });
displayEffectiveRate = effectiveRate
? FormatUtils.formatMoney(effectiveRate, { currency: localCurrency })
: '-';
} else {
effectiveRate = exchangeRate > 0 ? percentOf(exchangeRate, rate) : marketRate;
const decimalPlace = setDecimalPlaces(effectiveRate, 6);
displayEffectiveRate = removeTrailingZeros(
FormatUtils.formatMoney(Number(roundOffDecimal(effectiveRate, decimalPlace)), {
currency: localCurrency,
decimalPlaces: decimalPlace,
})
);
displayEffectiveRate = effectiveRate
? removeTrailingZeros(
FormatUtils.formatMoney(Number(roundOffDecimal(effectiveRate, decimalPlace)), {
currency: localCurrency,
decimalPlaces: decimalPlace,
})
)
: '-';
}
return { displayEffectiveRate, effectiveRate: Number(effectiveRate) };
};
Expand Down
Loading