fix(doctor claim): mobile field is the account number, read-only
Mobile is prefilled from the logged-in user's cookie (userInfo.mobile_number) and rendered read-only; removed it from editable form state/validation and send that number in the claim body. Backend already enforces it must match the account, so the field can't diverge. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,11 +7,20 @@ import { Box, Button, Modal, TextField } from "@mui/material";
|
||||
import { styleDefault } from "@/mui";
|
||||
import JalaliDatePicker from "@/components/common/JalaliDatePicker";
|
||||
import CloseModalD from "@/components/icons/CloseModalD";
|
||||
import Cookies from "js-cookie";
|
||||
import { convertToJalali, isUserLoggedIn } from "@/helper";
|
||||
import { request } from "@/services/response";
|
||||
import Altcha from "@/components/Altcha";
|
||||
|
||||
const initialForm = { national_code: "", birth_date: "", first_name: "", last_name: "", mobile: "" };
|
||||
const initialForm = { national_code: "", birth_date: "", first_name: "", last_name: "" };
|
||||
|
||||
function currentUserMobile() {
|
||||
try {
|
||||
return JSON.parse(Cookies.get("userInfo") || "{}")?.mobile_number || "";
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* احراز مالکیت پروفایل پزشک ایمپورتشده (unclaimed).
|
||||
@@ -37,6 +46,7 @@ function ClaimProfileSection({ doctor }) {
|
||||
}
|
||||
|
||||
const loggedIn = isUserLoggedIn();
|
||||
const userMobile = currentUserMobile();
|
||||
|
||||
const setField = (key, value) => {
|
||||
setForm((f) => ({ ...f, [key]: value }));
|
||||
@@ -50,8 +60,6 @@ function ClaimProfileSection({ doctor }) {
|
||||
if (!form.birth_date) errs.birth_date = "تاریخ تولد را انتخاب کنید";
|
||||
if (!form.first_name.trim()) errs.first_name = "نام الزامی است";
|
||||
if (!form.last_name.trim()) errs.last_name = "نام خانوادگی الزامی است";
|
||||
const mob = form.mobile.replace(/[۰-۹]/g, (d) => "۰۱۲۳۴۵۶۷۸۹".indexOf(d));
|
||||
if (!/^09\d{9}$/.test(mob)) errs.mobile = "شماره موبایل نامعتبر است";
|
||||
setFieldErrors(errs);
|
||||
return Object.keys(errs).length === 0;
|
||||
};
|
||||
@@ -61,7 +69,7 @@ function ClaimProfileSection({ doctor }) {
|
||||
setLoading(true);
|
||||
setError("");
|
||||
try {
|
||||
await request.postDoctorClaim(doctor.uuid, { ...form, altcha });
|
||||
await request.postDoctorClaim(doctor.uuid, { ...form, mobile: userMobile, altcha });
|
||||
setLoading(false);
|
||||
setSuccess(true);
|
||||
} catch (err) {
|
||||
@@ -219,11 +227,10 @@ function ClaimProfileSection({ doctor }) {
|
||||
/>
|
||||
<TextField
|
||||
label="شماره موبایل"
|
||||
value={form.mobile}
|
||||
error={!!fieldErrors.mobile}
|
||||
helperText={fieldErrors.mobile || "باید با شماره حساب کاربری شما یکی باشد"}
|
||||
onChange={(e) => setField("mobile", e.target.value)}
|
||||
inputProps={{ maxLength: 11, dir: "ltr" }}
|
||||
value={userMobile}
|
||||
helperText="شمارهٔ حساب کاربری شما (غیرقابل ویرایش)"
|
||||
InputProps={{ readOnly: true }}
|
||||
inputProps={{ dir: "ltr" }}
|
||||
fullWidth
|
||||
/>
|
||||
<JalaliDatePicker
|
||||
|
||||
Reference in New Issue
Block a user