From c2bee615fa313b3ab5e8208a27320d1550def547 Mon Sep 17 00:00:00 2001 From: inmake Date: Tue, 21 Apr 2026 18:08:41 +0500 Subject: [PATCH] Refactor feedback forms to include MAIL_REQUEST_FROM in API requests. Updated API utility to use mailApi for mail-related endpoints. Enhanced FeedbackFormModal and LeadForm components for improved data handling and user experience. --- src/components/FeedbackForm.tsx | 2 ++ src/landing/components/modals/FeedbackFormModal.tsx | 11 +++++++---- src/landing/features/lead-form/LeadForm.tsx | 9 ++++++--- src/landing/lib/api.ts | 5 +++++ src/mailFrom.ts | 2 ++ 5 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 src/mailFrom.ts diff --git a/src/components/FeedbackForm.tsx b/src/components/FeedbackForm.tsx index 3c11265..53ad11a 100644 --- a/src/components/FeedbackForm.tsx +++ b/src/components/FeedbackForm.tsx @@ -1,4 +1,5 @@ import ky from "ky"; +import { MAIL_REQUEST_FROM } from "@/mailFrom"; import { ChangeEvent, FormEvent, useState } from "react"; import { Trans, useTranslation } from "react-i18next"; import InputMask from "react-input-mask"; @@ -29,6 +30,7 @@ function FeedbackForm() { phone, email, request: description, + from: MAIL_REQUEST_FROM, }, }) .json(); diff --git a/src/landing/components/modals/FeedbackFormModal.tsx b/src/landing/components/modals/FeedbackFormModal.tsx index 87213d9..616d5fb 100644 --- a/src/landing/components/modals/FeedbackFormModal.tsx +++ b/src/landing/components/modals/FeedbackFormModal.tsx @@ -1,7 +1,8 @@ import { useMemo, useState } from "react"; import { Trans, useTranslation } from "react-i18next"; import { Button } from "@/landing/ui/Button"; -import { api } from "@/landing/lib/api"; +import { MAIL_REQUEST_FROM } from "@/mailFrom"; +import { mailApi } from "@/landing/lib/api"; import { useModalStore } from "@/landing/stores/useModalStore"; import CustomCheckbox from "@/landing/ui/CustomCheckbox"; import CheckIcon from "@/landing/components/icons/CheckIcon"; @@ -17,7 +18,9 @@ function FeedbackModal({ id }: { id: string }) { ); async function sendSources() { - await api.put(`mail/${id}`, { json: { source: selectedOptions } }); + await mailApi.put(`mail/${id}`, { + json: { source: selectedOptions, from: MAIL_REQUEST_FROM }, + }); setModal(null); } @@ -30,7 +33,7 @@ function FeedbackModal({ id }: { id: string }) { } return ( -
+
@@ -61,7 +64,7 @@ function FeedbackModal({ id }: { id: string }) {
    {modalOptions.map((item) => ( -
  • +
  • ))} diff --git a/src/landing/features/lead-form/LeadForm.tsx b/src/landing/features/lead-form/LeadForm.tsx index 36c9d92..be4eee8 100644 --- a/src/landing/features/lead-form/LeadForm.tsx +++ b/src/landing/features/lead-form/LeadForm.tsx @@ -1,6 +1,7 @@ import { useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; -import { api } from "@/landing/lib/api"; +import { MAIL_REQUEST_FROM } from "@/mailFrom"; +import { mailApi } from "@/landing/lib/api"; import { productOptionsFromT } from "@/landing/lib/productLabels"; import type { Product } from "@/landing/types"; import { Button } from "@/landing/ui/Button"; @@ -52,8 +53,10 @@ export function LeadForm({ const onSubmit: SubmitHandler = async (data) => { setSubmitError(null); try { - const { id } = await api - .post("mail", { json: { ...data, referer } }) + const { id } = await mailApi + .post("mail", { + json: { ...data, referer, from: MAIL_REQUEST_FROM }, + }) .json<{ id: string }>(); onSuccess(id); } catch { diff --git a/src/landing/lib/api.ts b/src/landing/lib/api.ts index e425c82..034488c 100644 --- a/src/landing/lib/api.ts +++ b/src/landing/lib/api.ts @@ -13,3 +13,8 @@ export const api = ky.create({ prefixUrl: base || undefined, credentials: "include", }); + +/** Lead/mail endpoints are served from graff.estate, not `VITE_API_URL`. */ +export const mailApi = ky.create({ + prefixUrl: "https://graff.estate/api/", +}); diff --git a/src/mailFrom.ts b/src/mailFrom.ts new file mode 100644 index 0000000..b246c7f --- /dev/null +++ b/src/mailFrom.ts @@ -0,0 +1,2 @@ +/** Sent with graff.estate mail API payloads to identify this client. */ +export const MAIL_REQUEST_FROM = "stream.graff.tech";