Add FA, EN, and AR static copy, with English LTR and catalog hidden outside Persian.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
51fb9f6a26
commit
6543c994c3
@@ -2,7 +2,11 @@
|
||||
|
||||
import { FormEvent, useState } from "react";
|
||||
|
||||
import { interpolate } from "@/i18n/index";
|
||||
import { useMessages } from "@/i18n/locale-context";
|
||||
|
||||
export default function CallbackForm() {
|
||||
const t = useMessages();
|
||||
const [status, setStatus] = useState<"idle" | "sending" | "ok" | "error">("idle");
|
||||
const [message, setMessage] = useState("");
|
||||
|
||||
@@ -21,35 +25,35 @@ export default function CallbackForm() {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
name,
|
||||
title: "درخواست تماس",
|
||||
title: t.callback.title,
|
||||
cellNumber,
|
||||
text: `درخواست تماس از صفحه اصلی. شماره: ${cellNumber}`,
|
||||
text: interpolate(t.callback.body, { phone: cellNumber }),
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
setStatus("error");
|
||||
setMessage("ثبت شماره انجام نشد. لطفاً دوباره تلاش کنید.");
|
||||
setMessage(t.callback.error);
|
||||
return;
|
||||
}
|
||||
|
||||
setStatus("ok");
|
||||
setMessage("شماره شما ثبت شد. بهزودی تماس میگیریم.");
|
||||
setMessage(t.callback.ok);
|
||||
form.reset();
|
||||
} catch {
|
||||
setStatus("error");
|
||||
setMessage("ارتباط با سرور برقرار نشد.");
|
||||
setMessage(t.callback.network);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<form className="callback-form" onSubmit={onSubmit}>
|
||||
<label className="sr-only" htmlFor="callback-name">
|
||||
نام
|
||||
{t.callback.name}
|
||||
</label>
|
||||
<input id="callback-name" name="name" type="text" required placeholder="نام" autoComplete="name" />
|
||||
<input id="callback-name" name="name" type="text" required placeholder={t.callback.name} autoComplete="name" />
|
||||
<label className="sr-only" htmlFor="callback-phone">
|
||||
شماره تماس
|
||||
{t.callback.phone}
|
||||
</label>
|
||||
<input
|
||||
id="callback-phone"
|
||||
@@ -57,11 +61,11 @@ export default function CallbackForm() {
|
||||
type="tel"
|
||||
required
|
||||
inputMode="tel"
|
||||
placeholder="شماره تماس"
|
||||
placeholder={t.callback.phone}
|
||||
autoComplete="tel"
|
||||
/>
|
||||
<button type="submit" className="btn btn-gold" disabled={status === "sending"}>
|
||||
{status === "sending" ? "در حال ارسال…" : "ثبت شماره"}
|
||||
{status === "sending" ? t.callback.sending : t.callback.submit}
|
||||
</button>
|
||||
{message ? <p className={status === "ok" ? "ok" : "err"}>{message}</p> : null}
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user