From b7065344e84039c58243c72353939c3d24a703fd Mon Sep 17 00:00:00 2001 From: VividTruthKeeper Date: Wed, 27 Jul 2022 16:01:20 +0500 Subject: [PATCH] contact page api intergrated --- src/components/contact/ContactForm.tsx | 159 +++++++++++++++++-------- src/helpers/apiRequests.ts | 10 ++ src/links.ts | 2 + src/pages/Structure.tsx | 37 +++++- 4 files changed, 154 insertions(+), 54 deletions(-) diff --git a/src/components/contact/ContactForm.tsx b/src/components/contact/ContactForm.tsx index f6aa2c4..dab3502 100644 --- a/src/components/contact/ContactForm.tsx +++ b/src/components/contact/ContactForm.tsx @@ -1,8 +1,14 @@ // Modules +import React, { useEffect, useState } from "react"; +import Skeleton from "react-loading-skeleton"; // Images import board from "../../images/board.jpg"; +// Helpers +import { getContact } from "../../helpers/apiRequests"; +import { highlightColor } from "../../helpers/otherVariables"; + // Icons import forward from "../../icons/arrow-forward.svg"; import email from "../../icons/email-black.svg"; @@ -14,6 +20,12 @@ import ig from "../../icons/instagram-grey.svg"; import twitter from "../../icons/twitter-gray.svg"; const ContactForm = () => { + const [contact, setContact]: [any, React.Dispatch] = useState(); + + useEffect(() => { + getContact(setContact); + }, []); + return (
{
- -
- -
- +993 12 46-87-87 -
+ {contact ? ( + +
+ +
+ {contact[0].phone} +
+ ) : ( + + )}
- - - - - - + {contact ? ( + + + + ) : ( + + )} + {contact ? ( + + + + ) : ( + + )}
-
-
- + {contact ? ( +
+
+ +
+ {contact[0].address}
- Atatürk köçesi 80, Aşgabat 744000, Туркменистан -
+ ) : ( + + )} +
- - - - - - + {contact ? ( + + + + ) : ( + + )} + {contact ? ( + + + + ) : ( + + )}
diff --git a/src/helpers/apiRequests.ts b/src/helpers/apiRequests.ts index 7dcaef9..64c9272 100644 --- a/src/helpers/apiRequests.ts +++ b/src/helpers/apiRequests.ts @@ -13,6 +13,7 @@ import { post, videos, structure, + contacts, } from "../links"; import React from "react"; @@ -102,3 +103,12 @@ export const getStructure = (setState: any) => { }) .catch(); }; + +export const getContact = (setState: any) => { + axios + .get(contacts) + .then((res) => { + setState(res.data.data); + }) + .catch(); +}; diff --git a/src/links.ts b/src/links.ts index 1bb1c2a..a560223 100644 --- a/src/links.ts +++ b/src/links.ts @@ -15,3 +15,5 @@ export const post: string = hosting + "/api/v1/posts"; // /id ? locale export const videos: string = hosting + "/api/v1/videos"; export const structure: string = hosting + "/api/v1/structure"; + +export const contacts: string = hosting + "/api/v1/contact-info"; diff --git a/src/pages/Structure.tsx b/src/pages/Structure.tsx index 103413e..99d4988 100644 --- a/src/pages/Structure.tsx +++ b/src/pages/Structure.tsx @@ -9,6 +9,7 @@ import SectionTitle from "../components/global/SectionTitle"; // Helpers import { getStructure } from "../helpers/apiRequests"; +import { highlightColor } from "../helpers/otherVariables"; // Links import { hosting } from "../links"; @@ -65,18 +66,42 @@ const Structure = () => { className="person-left" style={{ width: "100%", maxWidth: "40%" }} > - +
- - + +
- - - + + +