From 56d961acbb9055bbdaa823b616f11f4047aeb324 Mon Sep 17 00:00:00 2001 From: "VICTOR\\anumu" Date: Thu, 12 Jan 2023 10:56:39 +0100 Subject: [PATCH] Added country dropdown on contact page --- src/component/Contact/Main.js | 17 ++++++++++++++++- src/vendors/service/siteService.js | 16 +++++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/component/Contact/Main.js b/src/component/Contact/Main.js index 1c4855d..7b65228 100644 --- a/src/component/Contact/Main.js +++ b/src/component/Contact/Main.js @@ -1,11 +1,25 @@ -import React, { useEffect } from "react"; +import React, { useEffect, useState } from "react"; import { Link } from "react-router-dom"; import Bredcrumb from "../Bredcrumb/Main"; import BGImg from "../../assets/images/bread_crumb_bg.png"; import BGImg1 from "../../assets/images/bread_crumb_bg_one.png"; import BGImg2 from "../../assets/images/bread_crumb_bg_two.png"; +import SiteService from "../../vendors/service/siteService"; + const Main = ({ brdcum }) => { + let [countries, setCountries] = useState([]) // initial state for country dropdown + let countryClass = new SiteService() // instantiating the class + + const allCountry = () => { + return countryClass.countryData(); + } + + //CALLS THE API AFTER COMPONENT LOADS + useEffect(()=>{ + allCountry().then((data)=> setCountries(Object.values(data.data))) + },[]) + return ( <> {brdcum.b1 && ( @@ -86,6 +100,7 @@ const Main = ({ brdcum }) => {
diff --git a/src/vendors/service/siteService.js b/src/vendors/service/siteService.js index 7b56d62..dbea9f4 100644 --- a/src/vendors/service/siteService.js +++ b/src/vendors/service/siteService.js @@ -9,7 +9,9 @@ class SiteService { return this.getAuxEnd("blogdata", null); } - countryData() {} + countryData() { + return this.getAuxEnd("/country", null); + } faqData() {} @@ -20,11 +22,11 @@ class SiteService { //---------------------------------------- ----- getAuxEnd(uri, reqData) { const endPoint = process.env.REACT_APP_AUX_ENDPOINT + uri; - Axios.get(endPoint) + return Axios.get(endPoint) .then((response) => { - console.log(response); - res = response; - console.log("~~~~~~~ Toks2 GET ~~~~~~~~"); + // console.log(response); + // res = response; + // console.log("~~~~~~~ Toks2 GET ~~~~~~~~"); return response; }) .catch((error) => { @@ -41,12 +43,12 @@ class SiteService { }); } - getAuxEnd(uri, reqData) { + postAuxEnd(uri, reqData) { const endPoint = process.env.REACT_APP_AUX_ENDPOINT + uri; Axios.post(endPoint) .then((response) => { console.log(response); - res = response; + // res = response; console.log("~~~~~~~ Toks2 POST ~~~~~~~~"); return response; })