change date type for req & design and fields & add requests & fix bug appointment and dashboard

This commit is contained in:
Ehsan
2025-07-04 23:44:29 +03:30
parent 597fa1931d
commit f951128074
19 changed files with 273 additions and 58 deletions
@@ -1,5 +1,6 @@
import ArrowLeftWhiteD from "@/components/icons/ArrowLeftWhiteD";
import {
convertJalaliTimestamp,
handleTimeExpiresToken,
removeAdditionalKeysDashboard,
} from "@/helper";
@@ -23,7 +24,23 @@ function ButtonSendData({
setLoading(false);
};
const changeDateType = (data) => {
const newData = data;
const splitedDate = newData.birthday.split("/");
newData.birthday = convertJalaliTimestamp(
{
jy: Number(splitedDate[0]),
jm: Number(splitedDate[1]),
jd: Number(splitedDate[2]),
},
true
);
return newData;
};
const postData = () => {
console.log(changeDateType(information));
request
.postUserProfile(information)
.then((response) => {
@@ -67,6 +84,7 @@ function ButtonSendData({
const patchData = () => {
const usedKays = removeAdditionalKeysDashboard(information);
console.log(changeDateType(information));
request
.patchUserProfile(
@@ -1,8 +1,8 @@
import { getParsedUserInfo } from "@/helper";
import Content from "./Content";
import DateBirthday from "./DateBirthday";
import AutoSelector from "./component/AutoSelector";
import Field from "./component/Field";
import AutoSelector from "../component/AutoSelector";
import Field from "../component/Field";
import {
gender,
blood_group,
@@ -20,6 +20,8 @@ function Form({ insurance, errors, changeData, information }) {
list.find((g) => g.id === information[name]);
const parsedUserInfo = getParsedUserInfo();
console.log(information);
return (
<div className="grid grid-cols-1 lg:grid-cols-2 gap-x-[24px] gap-y-[10px]">
<Content title="شماره موبایل" isConfirmed={true}>
@@ -31,9 +31,3 @@ export const job = [
{ label: "آزاد", id: "azad" },
{ label: "دولتی", id: "dolati" },
];
export const insurance = [
{ label: "بیمه 1", id: 10 },
{ label: "بیمه 2", id: 20 },
{ label: "بیمه 3", id: 30 },
];
@@ -1,9 +1,9 @@
import { useEffect, useState } from "react";
import Form from "./Form";
import Form from "./form";
import { request } from "@/services/response";
import ButtonSendData from "./ButtonSendData";
import { getParsedUserInfo } from "@/helper";
import { disease } from "../information/disease";
import { disease } from "./form/disease";
function Information({ information, setInformation }) {
const [loading, setLoading] = useState(false);
@@ -13,16 +13,11 @@ function ItemRelatives({ row, idx, changeData }) {
address: row.contact.address,
};
const [data, setData] = useState(contentData);
const resetData = () => setData(contentData);
const [data, setData] = useState(row);
const resetData = () => setData(row);
useEffect(() => {
setData({
name: row.name,
relation: row.relation,
phone: row.contact.phone,
address: row.contact.address,
});
setData(row);
}, [row]);
return (
@@ -9,6 +9,7 @@ function Relatives({ data, changeData, loading, updateData }) {
const tableHead = ["ردیف", "نام", "نسبت", "شماره تماس", "آدرس", ""];
const centerTable = [0];
const [open, setOpen] = useState(false);
console.log(relatives);
return (
<div className="opacity-page">
@@ -3,7 +3,18 @@ import Field from "@/app/component/Field";
function Content({ setData, data }) {
const handleChange = (name, value) =>
setData((prev) => ({ ...prev, [name]: value }));
name === "phone" || name === "address"
? setData((prev) => ({
...prev,
contact: {
...prev.contact,
[name]: value,
},
}))
: setData((prev) => ({
...prev,
[name]: value,
}));
return (
<div className="mt-[32px] md:mt-[36px] lg:mt-[40px] flex flex-col gap-[24px] md:gap-[28px] lg:gap-[32px] px-0 sm:px-[52px]">
@@ -33,7 +44,7 @@ function Content({ setData, data }) {
type="number"
name="phone"
isPlaceHolder={true}
value={Number(data?.phone.replace(/^\+/, ""))}
value={Number(data?.contact?.phone.replace(/^\+/, ""))}
handleChange={handleChange}
/>
</FieldLabel>
@@ -43,7 +54,7 @@ function Content({ setData, data }) {
type="text"
name="address"
isPlaceHolder={true}
value={data?.address}
value={data?.contact?.address}
handleChange={handleChange}
/>
</FieldLabel>
@@ -10,27 +10,21 @@ function ModalAddRelatives({ open, setOpen, changeData, loading, updateData }) {
const contentItem = {
name: "",
relation: "",
phone: "",
address: "",
contact: {
phone: "",
address: "",
},
};
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);
const [newItem, setNewItem] = useState(contentItem);
const handleAddData = () => {
const changedKey = {
name: newItem.name,
relation: newItem.relation,
contact: {
phone: newItem.phone,
address: newItem.address,
},
};
changeData("add", "relatives", null, changedKey);
changeData("add", "relatives", null, newItem);
setNewItem(contentItem);
handleClose();
};
console.log(newItem);
return (
<>
@@ -64,8 +58,8 @@ function ModalAddRelatives({ open, setOpen, changeData, loading, updateData }) {
disabled={
!newItem.name ||
!newItem.relation ||
!newItem.phone ||
!newItem.address
!newItem.contact.phone ||
!newItem.contact.address
}
variant="contained"
>