used result_list array as list of countries #531

Merged
ameye merged 1 commits from signup-country into master 2023-12-18 08:59:28 +00:00
6 changed files with 32 additions and 34 deletions
+13 -14
View File
@@ -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 ?
<>
<option value={""}>Select your Country</option>
{data?.data?.map((item, idx) => (
<option value={item[0]} key={idx}>
{item[1]}
{data?.data?.map((item) => (
<option value={item.code} key={item.uid}>
{item.country}
</option>
))}
</>
:
data?.data?.length == 1 ?
data?.data?.map((item, idx) => (
<option value={item[0]} key={idx}>
{item[1]}
data?.data?.map((item) => (
<option value={item.code} key={item.uid}>
{item.country}
</option>
))
:
+8 -8
View File
@@ -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]);
@@ -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 (
<ModalCom action={action} situation={situation} className="edit-popup">
@@ -560,7 +559,7 @@ function NairaWithdraw({
</label>
<div className="w-full text-base p-2 text-dark-gray dark:text-white border border-slate-300 outline-0 flex-[0.6] rounded-full h-[42px] overflow-hidden relative font-medium leading-6 bg-clip-padding tracking-[1.5px] flex items-center pointer-events-none">
<span className="text-slate-500 text-lg italic">
{wallet.walletCountry[0][1]}
{wallet.walletCountry[0]?.country}
</span>
</div>
{/* <select
+2 -2
View File
@@ -41,13 +41,13 @@ const WalletRoutes = () => {
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) => {
+2 -2
View File
@@ -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`
@@ -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`