исправил клиент, пути в функциях, добавил переменную окружения
This commit is contained in:
1 parent
8aa8e04077
commit
1699873ea8
8 files changed
+59
-19
No files matched your search
@@ -7,10 +7,11 @@ import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import styles from "./ModalRequestForm.module.css";
|
||||
import Button from "../Button/Button";
|
||||
import axios from "axios";
|
||||
import { client } from "../../api/client";
|
||||
|
||||
// ✅ Схема валидации
|
||||
const schema = yup.object().shape({
|
||||
name: yup.string().required("Введите имя"),
|
||||
name: yup.string().required("Введите ФИО"),
|
||||
email: yup.string().email("Некорректный Email").required("Введите Email"),
|
||||
phone: yup.string().min(18, "Введите корректный номер").required("Введите номер"),
|
||||
});
|
||||
@@ -62,10 +63,8 @@ const PriceLisForm: React.FC<Props> = ({ open, onClose }) => {
|
||||
|
||||
const sendToBackend = async (data: FormData): Promise<boolean> => {
|
||||
try{
|
||||
const response = await axios.post("/api/requests", {
|
||||
const response = await client.post<{success: boolean}>("/api/email", {
|
||||
...data,
|
||||
source: "website-form",
|
||||
timestamp: new Date().toISOString(),
|
||||
})
|
||||
|
||||
return response.data.success;
|
||||
@@ -121,7 +120,7 @@ const PriceLisForm: React.FC<Props> = ({ open, onClose }) => {
|
||||
<div className={styles.field}>
|
||||
<input
|
||||
className={styles.input}
|
||||
placeholder="Введите имя *"
|
||||
placeholder="Введите ФИО *"
|
||||
{...register("name")}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user