change fields component & handle edit, delete, add data and save & change functional page doctor

This commit is contained in:
Ehsan
2025-07-02 01:58:44 +03:30
parent 43eb9c2b78
commit 04d3e38859
22 changed files with 290 additions and 313 deletions
+5 -29
View File
@@ -1,9 +1,5 @@
import Field from "@/app/component/element/Field";
import {
changeNumToDefault,
formatPhoneNumber,
validatePhoneNumber,
} from "@/helper";
import { validatePhoneNumber } from "@/helper";
import { request } from "@/services/response";
import { InputAdornment, Button } from "@mui/material";
import Link from "next/link";
@@ -14,15 +10,14 @@ function LogInPage({ setIsSendMsg, num, setNum, setUuid, matchedCity }) {
const [loading, setLoading] = useState(false);
const handleChange = (val) => {
const formatted = formatPhoneNumber(val);
const checkedNum = validatePhoneNumber(formatted);
const checkedNum = validatePhoneNumber(val);
setError(checkedNum);
setNum(formatted);
setNum(val);
};
const handleReq = async () => {
setLoading(true);
request
.sendCode(changeNumToDefault(num), "")
.sendCode(num, "")
.then((response) => {
setLoading(false);
if (response.uuid) {
@@ -52,26 +47,7 @@ function LogInPage({ setIsSendMsg, num, setNum, setUuid, matchedCity }) {
value={num}
type="tel"
error={!error.valid}
spaceNull={true}
inputProps={{
startAdornment: (
<InputAdornment
className="!ml-4"
position="start"
sx={{
".MuiTypography-root": {
lineHeight: "0 !important",
},
".muirtl-1qj5e5k-MuiTypography-root": {
color: "#000000de !important",
},
}}
>
09
</InputAdornment>
),
}}
title="شماره همراه"
placeholder="09xxxxxxxxx"
updateState={handleChange}
/>
<p
@@ -1,6 +1,7 @@
import { Button } from "@mui/material";
import { request } from "@/services/response";
import Cookies from "js-cookie";
import { handleTimeExpiresToken } from "@/helper";
function SendReq({
loading,
@@ -30,29 +31,24 @@ function SendReq({
};
const handleSetCookie = (response) => {
const accessTokenExpires = new Date();
accessTokenExpires.setSeconds(
accessTokenExpires.getSeconds() + response.expires_in
);
const refreshTokenExpires = new Date();
refreshTokenExpires.setDate(refreshTokenExpires.getDate() + 30);
const expiresTime = handleTimeExpiresToken(response.expires_in);
Cookies.set("access_token", response.access_token, {
expires: accessTokenExpires,
expires: expiresTime.accessTokenExpires,
path: "/",
secure: true,
sameSite: "strict",
});
Cookies.set("refresh_token", response.refresh_token, {
expires: refreshTokenExpires,
expires: expiresTime.refreshTokenExpires,
path: "/",
secure: true,
sameSite: "strict",
});
Cookies.set("uuid", uuid, {
expires: refreshTokenExpires,
expires: expiresTime.refreshTokenExpires,
path: "/",
secure: true,
sameSite: "strict",