diff --git a/src/components/AuthPages/SignUp/index.jsx b/src/components/AuthPages/SignUp/index.jsx index 1874db3..9440752 100644 --- a/src/components/AuthPages/SignUp/index.jsx +++ b/src/components/AuthPages/SignUp/index.jsx @@ -47,21 +47,20 @@ export default function SignUp() { // Get Country Api const getCountryList = useCallback(async () => { - const res = await userApi.getSignupCountryData(); - + try { - if (res.status === 200) { - const { signup_country } = await res.data; - // setCountries(signup_country); + const res = await userApi.getSignupCountryData(); + if (res.status === 200 && res.data.internal_return >= 0) { + const { result_list } = await res.data; if(country){ // IF LINK/PATHNAME HAS CNT QUERY VALUE - let cnt = signup_country.filter(item => item[0]==country) // test to see country passed in query param exist from list of countries supplied by API + let cnt = result_list.filter(item => item.code == country) // test to see country passed in query param exist from list of countries supplied by API if(!cnt.length){ // IF CNT EMPTY, SET FORMDATA COUNTRY BACK TO EMPTY STRING: RE: THIS IS BCOS WE INITAIL SET COUNTRY VALUE IN FORMDATA, IF COUNTRY PARAM IS PRESENT IN LINK setFormData(prev => ({...prev, country: ''})) - return setCountries({loading: false, data: signup_country}); + return setCountries({loading: false, data: result_list}); } return setCountries({loading: false, data: cnt}); } - setCountries({loading: false, data:signup_country}); + setCountries({loading: false, data:result_list}); } else if (res.data.result !== 100) { setCountries({loading: false, data:[]}); } @@ -375,17 +374,17 @@ const SelectOption = ({ {data?.data?.length > 1 ? <> Select your Country - {data?.data?.map((item, idx) => ( - - {item[1]} + {data?.data?.map((item) => ( + + {item.country} ))} > : data?.data?.length == 1 ? - data?.data?.map((item, idx) => ( - - {item[1]} + data?.data?.map((item) => ( + + {item.country} )) : diff --git a/src/components/MyJobs/MyJobTable.jsx b/src/components/MyJobs/MyJobTable.jsx index 53789cf..6f46aac 100644 --- a/src/components/MyJobs/MyJobTable.jsx +++ b/src/components/MyJobs/MyJobTable.jsx @@ -42,16 +42,16 @@ export default function MyJobTable({ MyJobList, reloadJobList, className }) { // Get Country Api const getCountryList = useCallback(async () => { - const res = await userApi.getSignupCountryData(); - + try { - if (res.status === 200) { + const res = await userApi.getSignupCountryData(); + if (res.status === 200 && res.data.internal_return >= 0) { const { - data: { signup_country }, + data: { result_list }, } = await res; - let checkCountry = signup_country - ?.filter((item) => item[0] == country) - ?.map((item, idx) => item[1]) + let checkCountry = result_list + ?.filter((item) => item.code == country) + ?.map((item) => item.country) .join(""); setCountries(checkCountry); } @@ -59,7 +59,7 @@ export default function MyJobTable({ MyJobList, reloadJobList, className }) { throw new Error(error); } }, [userApi, country]); - + console.log('MY COUNTRY', myCountry) useEffect(() => { getCountryList(); }, [getCountryList]); diff --git a/src/components/MyWallet/Popup/NairaWithdraw.jsx b/src/components/MyWallet/Popup/NairaWithdraw.jsx index c5faf10..d40c642 100644 --- a/src/components/MyWallet/Popup/NairaWithdraw.jsx +++ b/src/components/MyWallet/Popup/NairaWithdraw.jsx @@ -25,7 +25,7 @@ function NairaWithdraw({ }, newAccount: { country: wallet.walletCountry - ? wallet.walletCountry[0][0] + ? wallet.walletCountry[0]?.code : wallet.country, bank: state?.newAccount?.amount || "", accountNumber: state?.newAccount?.amount || "", @@ -34,7 +34,6 @@ function NairaWithdraw({ city: state?.newAccount?.amount || "", }, }; - const [errorMsgs, setErrorMsgs] = useState(initialValues); let [sendMoneyFee, setSendMoneyFee] = useState({ @@ -69,7 +68,7 @@ function NairaWithdraw({ // Handling card change const handleBankOptions = (event) => { let bankCountry = wallet.walletCountry - ? wallet.walletCountry[0][0] + ? wallet.walletCountry[0]?.code : wallet.country setBankName((prev) => ({ loading: true, data: [] })); apiCall @@ -120,7 +119,7 @@ function NairaWithdraw({ } setAllCountries((prev) => ({ loading: false, - data: res.data.signup_country, + data: res.data.result_list, })); }) .catch((error) => { @@ -287,7 +286,7 @@ function NairaWithdraw({ getRecipients(); }, []); - console.log("Testing Wallet Country", wallet?.walletCountry[0][0]); + console.log("Testing Wallet Country", wallet?.walletCountry[0]?.code); return ( @@ -560,7 +559,7 @@ function NairaWithdraw({ - {wallet.walletCountry[0][1]} + {wallet.walletCountry[0]?.country} {/* { apiCall .getSignupCountryData() .then((res) => { - if (res.data.internal_return < 0) { + if (res?.data?.internal_return < 0) { setAllCountries((prev) => ({ loading: false, data: [] })); return; } setAllCountries((prev) => ({ loading: false, - data: res.data.signup_country, + data: res.data.result_list, })); }) .catch((error) => { diff --git a/src/components/MyWallet/WalletItemCard.jsx b/src/components/MyWallet/WalletItemCard.jsx index 2b61cc0..daf2c13 100644 --- a/src/components/MyWallet/WalletItemCard.jsx +++ b/src/components/MyWallet/WalletItemCard.jsx @@ -35,8 +35,8 @@ export default function WalletItemCard({ walletItem, payment, countries }) { }; const currentWalletCurrency = countries - .map((country) => country) - .filter((country) => country[0] === walletItem.country); + // .map((country) => country) + .filter((country) => country.code === walletItem.country); const image = walletItem.code ? `${walletItem.code.toLowerCase()}.svg` diff --git a/src/components/MyWallet/WalletItemCardFamily.jsx b/src/components/MyWallet/WalletItemCardFamily.jsx index 72e9e3a..4600e17 100644 --- a/src/components/MyWallet/WalletItemCardFamily.jsx +++ b/src/components/MyWallet/WalletItemCardFamily.jsx @@ -35,8 +35,8 @@ export default function WalletItemCardFamily({ walletItem, payment, countries }) }; const currentWalletCurrency = countries - .map((country) => country) - .filter((country) => country[0] === walletItem.country); + // .map((country) => country) + .filter((country) => country.code === walletItem.country); const image = walletItem.code ? `${walletItem.code.toLowerCase()}.svg`