From 7bef2e8b9296592240545c9d4de414a90408f4e3 Mon Sep 17 00:00:00 2001 From: Kakabay <2kakabayashyrberdyew@gmail.com> Date: Thu, 30 Jan 2025 16:31:38 +0500 Subject: [PATCH] contacts ready --- public/contacts/email.svg | 8 +- public/contacts/fax.svg | 8 +- public/contacts/location.svg | 5 +- public/contacts/mail.svg | 5 +- public/contacts/map.svg | 9 ++ public/contacts/mobile.svg | 5 +- public/contacts/phone.svg | 8 +- src/components/layout/header.tsx | 2 +- src/components/shared/contact-card.tsx | 4 +- src/components/shared/forms/contacts-form.tsx | 105 ++++++++++++++++++ src/components/shared/home/home-time.tsx | 2 +- src/lib/get-contacts-form-details.ts | 19 ++++ src/main.tsx | 6 +- src/pages/contacts.tsx | 77 +++++++++++++ src/pages/index.ts | 1 + src/services/service.ts | 11 +- tailwind.config.js | 2 +- 17 files changed, 246 insertions(+), 31 deletions(-) create mode 100644 public/contacts/map.svg create mode 100644 src/components/shared/forms/contacts-form.tsx create mode 100644 src/lib/get-contacts-form-details.ts create mode 100644 src/pages/contacts.tsx diff --git a/public/contacts/email.svg b/public/contacts/email.svg index f07e96f..e666d59 100644 --- a/public/contacts/email.svg +++ b/public/contacts/email.svg @@ -1,9 +1,9 @@ - + - - + + - + diff --git a/public/contacts/fax.svg b/public/contacts/fax.svg index 586dfa9..0b57757 100644 --- a/public/contacts/fax.svg +++ b/public/contacts/fax.svg @@ -1,9 +1,9 @@ - + - - + + - + diff --git a/public/contacts/location.svg b/public/contacts/location.svg index 4a6701b..801ccc0 100644 --- a/public/contacts/location.svg +++ b/public/contacts/location.svg @@ -1,4 +1,3 @@ - - - + + diff --git a/public/contacts/mail.svg b/public/contacts/mail.svg index 0c4f861..c8f873c 100644 --- a/public/contacts/mail.svg +++ b/public/contacts/mail.svg @@ -1,4 +1,3 @@ - - - + + diff --git a/public/contacts/map.svg b/public/contacts/map.svg new file mode 100644 index 0000000..920a765 --- /dev/null +++ b/public/contacts/map.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/public/contacts/mobile.svg b/public/contacts/mobile.svg index 8578a4c..ef43e4b 100644 --- a/public/contacts/mobile.svg +++ b/public/contacts/mobile.svg @@ -1,4 +1,3 @@ - - - + + diff --git a/public/contacts/phone.svg b/public/contacts/phone.svg index 5dd3630..ef25945 100644 --- a/public/contacts/phone.svg +++ b/public/contacts/phone.svg @@ -1,9 +1,9 @@ - + - - + + - + diff --git a/src/components/layout/header.tsx b/src/components/layout/header.tsx index da54cdd..ffb2d4f 100644 --- a/src/components/layout/header.tsx +++ b/src/components/layout/header.tsx @@ -12,7 +12,7 @@ export const navData = [ }, { title: "Контакты", - link: "", + link: "/contacts", }, ]; diff --git a/src/components/shared/contact-card.tsx b/src/components/shared/contact-card.tsx index 22c259d..9f7e179 100644 --- a/src/components/shared/contact-card.tsx +++ b/src/components/shared/contact-card.tsx @@ -11,7 +11,9 @@ interface Props { export const ContactCard: FC = ({ className, subtitle, title, img }) => { return (
- contact icon +
+ contact icon +
{subtitle}
diff --git a/src/components/shared/forms/contacts-form.tsx b/src/components/shared/forms/contacts-form.tsx new file mode 100644 index 0000000..149fcfd --- /dev/null +++ b/src/components/shared/forms/contacts-form.tsx @@ -0,0 +1,105 @@ +import { FC, useState } from "react"; +import { useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { cn } from "@/lib/utils"; +import { Form } from "@/components/ui/form"; +import { Field } from "../field"; +import { Button } from "@/components/ui/button"; +import { + ContactsFormType, + contactsSchema, + defaultValuesContacts, +} from "@/lib/get-contacts-form-details"; +import { postContact } from "@/services/service"; +import { FormSuccesStatus } from "../form-succes-status"; +import { Loader2 } from "lucide-react"; + +interface Props { + className?: string; +} + +export const ContactsForm: FC = ({ className }) => { + const [success, setSuccess] = useState(false); + const form = useForm({ + resolver: zodResolver(contactsSchema), + defaultValues: defaultValuesContacts, + }); + + async function onSubmit(data: ContactsFormType) { + try { + const status = await postContact(data); + + setSuccess(status); + } catch (error) { + console.error("POST contact", error); + } + } + + const { errors } = form.formState; + + return ( +
+
+ +

Связаться с нами

+ +
+ + +
+ + +
+ + + + +
+
+ +
+ ); +}; diff --git a/src/components/shared/home/home-time.tsx b/src/components/shared/home/home-time.tsx index 453e96f..0bb048d 100644 --- a/src/components/shared/home/home-time.tsx +++ b/src/components/shared/home/home-time.tsx @@ -46,7 +46,7 @@ export const HomeTime: FC = ({ className }) => { return (
-

Время мероприятий

+

Время выставки

diff --git a/src/lib/get-contacts-form-details.ts b/src/lib/get-contacts-form-details.ts new file mode 100644 index 0000000..9a271ce --- /dev/null +++ b/src/lib/get-contacts-form-details.ts @@ -0,0 +1,19 @@ +import { z } from "zod"; + +export type ContactsFormType = z.infer; + +export const contactsSchema = z.object({ + name: z.string().min(2, "error"), + email: z.string().email(), + phone: z.string().min(8, "error"), + company: z.string().min(2, "error"), + msg: z.string().min(5, "error"), +}); + +export const defaultValuesContacts = { + name: "", + email: "", + phone: "", + company: "", + msg: "", +}; diff --git a/src/main.tsx b/src/main.tsx index 2421c3b..4d99784 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -3,7 +3,7 @@ import { createRoot } from "react-dom/client"; import "./index.css"; import App from "./App.tsx"; import { createBrowserRouter, RouterProvider } from "react-router-dom"; -import { About, B2b, BecomeSponsor, Home, StendForm } from "./pages"; +import { About, B2b, BecomeSponsor, Contacts, Home, StendForm } from "./pages"; const router = createBrowserRouter([ { @@ -30,6 +30,10 @@ const router = createBrowserRouter([ element: , path: "/stend-form", }, + { + element: , + path: "/contacts", + }, ], }, ]); diff --git a/src/pages/contacts.tsx b/src/pages/contacts.tsx new file mode 100644 index 0000000..86541c4 --- /dev/null +++ b/src/pages/contacts.tsx @@ -0,0 +1,77 @@ +import { Container } from "@/components/layout"; +import { ContactsForm } from "@/components/shared/forms/contacts-form"; +import { useScrollTop } from "@/hooks/use-scroll-top"; +import { FC } from "react"; + +interface Props { + className?: string; +} + +export const Contacts: FC = () => { + useScrollTop(); + + return ( +
+ +
+ + +
+

Контакты

+ +
+
+ address + +
+

Адрес офиса:

+
+ 744000, г. Ашхабад, просп. Битарап Туркменистан, 183 +
+
+
+
+ phone + +
+

Телефон:

+

+ +99371871812; 99363719588 +

+
+
+ +
+ fax + +
+

Факс:

+

+99312454111

+
+
+ +
+ email + +
+

E-mail:

+

contact@turkmenexpo.com

+
+
+
+
+
+
+ +
+