Skip to content

Commit

Permalink
feat: redemption widget - manage callbacks (#594)
Browse files Browse the repository at this point in the history
* allow to predefined a country code

* feat: define several callback URL at the different steps of redemption process

* fix ERC20test address on local environment

* deal with callbacks response for RedemptionSubmitted and RedemptionConfirmed

* take PR remarks into account
  • Loading branch information
levalleux-ludo authored Oct 20, 2023
1 parent c847f01 commit c56c682
Show file tree
Hide file tree
Showing 10 changed files with 570 additions and 81 deletions.
2 changes: 1 addition & 1 deletion packages/common/src/mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const chainIdToDefaultTokens = new Map<ChainId, Token[]>([
{
symbol: "TETH",
name: "testErc20",
address: "0x998abeb3E57409262aE5b751f60747921B33613E",
address: "0x851356ae760d987E095750cCeb3bC6014560891C",
decimals: "18"
}
]
Expand Down
13 changes: 11 additions & 2 deletions packages/react-kit/src/components/form/CountrySelect.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint @typescript-eslint/no-explicit-any: "off" */
import { useField, useFormikContext } from "formik";
import { GlobeHemisphereWest } from "phosphor-react";
import React, { forwardRef, useState } from "react";
import React, { forwardRef, useState, useEffect } from "react";
import type { Country as CountryCode } from "react-phone-number-input";
import PhoneInput from "react-phone-number-input";
import Select, { components } from "react-select";
Expand Down Expand Up @@ -112,13 +112,22 @@ type Props = InputProps & {

export function CountrySelect({ name, countries, ...props }: Props) {
const { status } = useFormikContext();
const [, meta, helpers] = useField(name);
const [initialized, setInitialized] = useState<boolean>(false);
const [field, meta, helpers] = useField(name);
const errorText = meta.error || status?.[name];
const errorMessage = errorText && meta.touched ? errorText : "";
const displayError =
typeof errorMessage === typeof "string" && errorMessage !== "";
const [phone, setPhone] = useState<string | undefined>(undefined);
const [countryCode, setCountryCode] = useState<CountryCode | undefined>();

useEffect(() => {
if (!initialized && field.value) {
setCountryCode(field.value as CountryCode);
setInitialized(true);
}
}, [field.value, initialized]); // eslint-disable-line

return (
<>
<PhoneWrapper>
Expand Down
Loading

0 comments on commit c56c682

Please sign in to comment.