GiftBottomSheet: update phone number

This commit is contained in:
2025-11-12 23:50:35 +03:00
parent 3865a96682
commit 208437f262
2 changed files with 26 additions and 36 deletions

View File

@@ -1,4 +1,5 @@
import { Button, Checkbox, Form, Input } from "antd"; import { Button, Checkbox, Form, Input } from "antd";
import ProPhoneInput from "components/ProPhoneInput";
import { GiftDetailsType } from "features/order/orderSlice"; import { GiftDetailsType } from "features/order/orderSlice";
import { useEffect } from "react"; import { useEffect } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
@@ -70,21 +71,13 @@ export function GiftBottomSheet({
autoFocus={false} autoFocus={false}
/> />
</Form.Item> </Form.Item>
<Form.Item
name="receiverPhone" <ProPhoneInput
phone={giftForm.getFieldValue("receiverPhone")}
setPhone={(phone) => giftForm.setFieldValue("receiverPhone", phone)}
propName="receiverPhone"
label={t("address.receiverPhone")} label={t("address.receiverPhone")}
rules={[{ required: true, message: "" }]} />
colon={false}
>
<Input
placeholder={t("address.receiverPhone")}
size="large"
style={{
fontSize: 14,
}}
autoFocus={false}
/>
</Form.Item>
<Form.Item name="message" label={t("address.message")}> <Form.Item name="message" label={t("address.message")}>
<TextArea <TextArea
@@ -115,21 +108,12 @@ export function GiftBottomSheet({
/> />
</Form.Item> </Form.Item>
<Form.Item <ProPhoneInput
name="senderPhone" phone={giftForm.getFieldValue("senderPhone")}
label={t("address.senderPhone")} setPhone={(phone) => giftForm.setFieldValue("senderPhone", phone)}
rules={[{ required: true, message: "" }]} propName="senderPhone"
colon={false} label={t("address.receiverPhone")}
> />
<Input
placeholder={t("address.senderPhone")}
size="large"
style={{
fontSize: 14,
}}
autoFocus={false}
/>
</Form.Item>
<Form.Item <Form.Item
name="senderEmail" name="senderEmail"

View File

@@ -9,17 +9,19 @@ import { ProBlack1 } from "ThemeConstants";
interface ProPhoneInput extends TitleProps { interface ProPhoneInput extends TitleProps {
phone: string; phone: string;
setPhone: (phone: string) => void; setPhone: (phone: string) => void;
propName?: string
label?: string
} }
const ProPhoneInput: FunctionComponent<ProPhoneInput> = ({ phone, setPhone }) => { const ProPhoneInput: FunctionComponent<ProPhoneInput> = ({ phone, setPhone, propName, label }) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { themeName } = useAppSelector((state) => state.theme); const { themeName } = useAppSelector((state) => state.theme);
const { isRTL } = useAppSelector((state) => state.locale); const { isRTL } = useAppSelector((state) => state.locale);
return ( return (
<Form.Item <Form.Item
name="phone" name={propName}
label={t("login.phone")} label={label}
rules={[ rules={[
{ required: true, message: "" }, { required: true, message: "" },
{ {
@@ -43,18 +45,22 @@ const ProPhoneInput: FunctionComponent<ProPhoneInput> = ({ phone, setPhone }) =>
themeName={themeName} themeName={themeName}
isRTL={isRTL} isRTL={isRTL}
placeholder={t("login.mobileNumber")} placeholder={t("login.mobileNumber")}
propName={propName}
label={label}
/> />
</Form.Item> </Form.Item>
); );
}; };
const PhoneInputWrapper = ({ phone, themeName, isRTL, placeholder, value, onChange }: { export const PhoneInputWrapper = ({ phone, themeName, isRTL, placeholder, value, onChange, propName, label }: {
phone: string; phone: string;
themeName: string; themeName: string;
isRTL: boolean; isRTL: boolean;
placeholder: string; placeholder: string;
value?: string; value?: string;
onChange?: (value: string) => void; onChange?: (value: string) => void;
propName?: string;
label?: string;
}) => { }) => {
return ( return (
<div className="pro-phone-input"> <div className="pro-phone-input">
@@ -72,7 +78,7 @@ const PhoneInputWrapper = ({ phone, themeName, isRTL, placeholder, value, onChan
paddingRight: "50px", paddingRight: "50px",
borderColor: themeName === "light" ? "#d9d9d9" : "#363636", borderColor: themeName === "light" ? "#d9d9d9" : "#363636",
}} }}
placeholder={placeholder} placeholder={label || placeholder}
value={value || phone} value={value || phone}
onChange={(value) => { onChange={(value) => {
onChange?.(value); onChange?.(value);
@@ -93,8 +99,8 @@ const PhoneInputWrapper = ({ phone, themeName, isRTL, placeholder, value, onChan
}} }}
autocompleteSearch autocompleteSearch
inputProps={{ inputProps={{
id: "phone", // Required for accessibility & autofill id: propName || "phone", // Required for accessibility & autofill
name: "phone", name: propName || "phone",
required: true, required: true,
autoFocus: false, autoFocus: false,
autoComplete: "tel", autoComplete: "tel",