Skip to content

Commit

Permalink
feat: [GPR-536][Sale Widget] Get multiple currencies (#1653)
Browse files Browse the repository at this point in the history
Co-authored-by: Jhonatan Gonzalez <[email protected]>
  • Loading branch information
mimi-imtbl and jhesgodi authored Apr 12, 2024
1 parent 8e853a3 commit 915b273
Show file tree
Hide file tree
Showing 7 changed files with 738 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,20 +172,26 @@ export function SaleContextProvider(props: {
>(undefined);

const [fundingRoutes, setFundingRoutes] = useState<FundingRoute[]>([]);
const [disabledPaymentTypes, setDisabledPaymentTypes] = useState<SalePaymentTypes[]>([]);
const [disabledPaymentTypes, setDisabledPaymentTypes] = useState<
SalePaymentTypes[]
>([]);

const disablePaymentTypes = (types: SalePaymentTypes[]) => {
setDisabledPaymentTypes((prev) => Array.from(new Set([...(prev || []), ...types])));
};

const [invalidParameters, setInvalidParameters] = useState<boolean>(false);

const { currency, clientConfig } = useClientConfig({
const {
selectedCurrency, clientConfig, clientConfigError,
} = useClientConfig({
environmentId,
environment: config.environment,
checkout,
provider,
});

const fromTokenAddress = currency?.erc20Address || '';
const fromTokenAddress = selectedCurrency?.address || '';

const goBackToPaymentMethods = useCallback(
(type?: SalePaymentTypes | undefined, data?: Record<string, unknown>) => {
Expand Down Expand Up @@ -303,6 +309,11 @@ export function SaleContextProvider(props: {
goToErrorView(signError.type, signError.data);
}, [signError]);

useEffect(() => {
if (!clientConfigError) return;
goToErrorView(clientConfigError.type, clientConfigError.data);
}, [clientConfigError]);

const { smartCheckout, smartCheckoutResult, smartCheckoutError } = useSmartCheckout({
provider,
checkout,
Expand All @@ -327,7 +338,7 @@ export function SaleContextProvider(props: {
data: getTopUpViewData(
smartCheckoutError,
fromTokenAddress,
currency?.name!,
selectedCurrency?.name!,
),
},
},
Expand Down
Loading

0 comments on commit 915b273

Please sign in to comment.