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

Shayan/fix exchange rates type error #79

Merged
merged 3 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
106 changes: 57 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"@babel/preset-env": "^7.24.5",
"@deriv-com/api-hooks": "^0.1.19",
"@deriv-com/api-hooks": "^0.1.24",
"@deriv-com/translations": "^1.2.4",
"@deriv-com/ui": "^1.26.0",
"@deriv-com/utils": "latest",
Expand Down
5 changes: 3 additions & 2 deletions src/components/AdvertsTableRow/AdvertsTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ const AdvertsTableRow = memo((props: TAdvertsTableRowRenderer) => {
}, [local_currency]);

useEffect(() => {
if (exchangeRateData?.exchange_rates?.rates) {
exchangeRateRef.current = exchangeRateData?.exchange_rates?.rates?.[local_currency];
const rate = exchangeRateData?.exchange_rates?.rates?.[local_currency];
if (typeof rate === 'number') {
exchangeRateRef.current = rate;
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [exchangeRateData]);
Expand Down
6 changes: 4 additions & 2 deletions src/components/BuySellForm/BuySellForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ const BuySellForm = ({ advertId, isModalOpen, onRequestClose }: TBuySellFormProp
}, [local_currency]);

useEffect(() => {
if (exchangeRatesData?.exchange_rates?.rates) {
exchangeRateRef.current = exchangeRatesData?.exchange_rates.rates?.[local_currency];
const rate = exchangeRatesData?.exchange_rates?.rates?.[local_currency];
if (typeof rate === 'number') {
exchangeRateRef.current = rate;
}

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [exchangeRatesData]);

Expand Down
5 changes: 3 additions & 2 deletions src/components/FloatingRate/FloatingRate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ const FloatingRate = ({
}, [localCurrency]);

useEffect(() => {
if (exchangeRateData?.exchange_rates?.rates) {
exchangeRateRef.current = exchangeRateData?.exchange_rates?.rates?.[localCurrency];
const rate = exchangeRateData?.exchange_rates?.rates?.[localCurrency];
if (typeof rate === 'number') {
exchangeRateRef.current = rate;
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [exchangeRateData]);
Expand Down
6 changes: 4 additions & 2 deletions src/pages/my-ads/components/AdSummary/AdSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ const AdSummary = ({
}, [currency, localCurrency]);

useEffect(() => {
if (exchangeRatesData?.exchange_rates?.rates) {
exchangeRateRef.current = exchangeRatesData.exchange_rates?.rates?.[localCurrency];
const rate = exchangeRatesData?.exchange_rates?.rates?.[localCurrency];
if (typeof rate === 'number') {
exchangeRateRef.current = rate;
}

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [exchangeRatesData]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,13 @@ const MyAdsTableRow = ({ currentRateType, showModal, ...rest }: TMyAdsTableProps
}, [localCurrency]);

useEffect(() => {
if (exchangeRatesData?.exchange_rates?.rates) {
exchangeRateRef.current = exchangeRatesData.exchange_rates?.rates?.[localCurrency ?? ''];
const rate = exchangeRatesData?.exchange_rates?.rates?.[localCurrency ?? ''];
if (typeof rate === 'number') {
exchangeRateRef.current = rate;
}
// if (exchangeRatesData?.exchange_rates?.rates) {
// exchangeRateRef.current = exchangeRatesData.exchange_rates?.rates?.[localCurrency ?? ''];
// }
shayan-deriv marked this conversation as resolved.
Show resolved Hide resolved
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [exchangeRatesData]);

Expand Down
Loading