change response file & request get user-profile & change design dashboard page & handle limit page dashboard
This commit is contained in:
@@ -2,18 +2,23 @@ import Content from "@/components/dashboard/Content";
|
|||||||
import { defineAbilitiesFor } from "@/lib/ability";
|
import { defineAbilitiesFor } from "@/lib/ability";
|
||||||
import { getUser } from "@/lib/auth";
|
import { getUser } from "@/lib/auth";
|
||||||
import { getStateInfo } from "@/lib/getStateInfo";
|
import { getStateInfo } from "@/lib/getStateInfo";
|
||||||
|
import axios from "axios";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
async function UserAccount() {
|
export default async function Dashboard() {
|
||||||
const { matchedCity } = getStateInfo();
|
const { matchedCity } = getStateInfo();
|
||||||
const user = await getUser();
|
const user = await getUser();
|
||||||
const ability = defineAbilitiesFor(user);
|
const ability = defineAbilitiesFor(user);
|
||||||
|
|
||||||
|
const response = await axios.get(
|
||||||
|
"https://back-dev.clinic-pro.ir/api/v1/user-profile/e4fd81b4-31bc-4f9a-b300-da23026f9d79"
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(response);
|
||||||
|
|
||||||
if (!ability.can("access", "Dashboard")) {
|
if (!ability.can("access", "Dashboard")) {
|
||||||
return redirect("/");
|
return redirect("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Content matchedCity={matchedCity} />;
|
return <Content matchedCity={matchedCity} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UserAccount;
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useState } from "react";
|
|||||||
|
|
||||||
import userData from "@/data/userData.json";
|
import userData from "@/data/userData.json";
|
||||||
import DashboardPage from "@/components/dashboard";
|
import DashboardPage from "@/components/dashboard";
|
||||||
import UserAccountPage from "@/components/dashboard/userAccount/UserAccount";
|
import UserAccountPage from "./userAccount";
|
||||||
|
|
||||||
function Content({ matchedCity }) {
|
function Content({ matchedCity }) {
|
||||||
const [value, setValue] = useState(0);
|
const [value, setValue] = useState(0);
|
||||||
@@ -15,7 +15,7 @@ function Content({ matchedCity }) {
|
|||||||
<DashboardPage
|
<DashboardPage
|
||||||
value={value}
|
value={value}
|
||||||
setValue={setValue}
|
setValue={setValue}
|
||||||
user={userData.data}
|
user={userData.data}
|
||||||
isOpenSide={isOpenSide}
|
isOpenSide={isOpenSide}
|
||||||
matchedCity={matchedCity}
|
matchedCity={matchedCity}
|
||||||
setIsOpenSide={setIsOpenSide}
|
setIsOpenSide={setIsOpenSide}
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
import ContentTabs from "./content";
|
|
||||||
import Head from "./Head";
|
|
||||||
import NotfoundDashboard from "./NotfoundDashboard";
|
|
||||||
|
|
||||||
function UserAccountPage({
|
|
||||||
user,
|
|
||||||
isTurnsDetails,
|
|
||||||
setIsTurnsDetails,
|
|
||||||
value,
|
|
||||||
setValue,
|
|
||||||
isOpenSide,
|
|
||||||
setIsOpenSide,
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<div className="w-full md:w-[68%] lg:w-[72%]">
|
|
||||||
{value === 5 ? (
|
|
||||||
<NotfoundDashboard />
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<Head user={user} />
|
|
||||||
<ContentTabs
|
|
||||||
user={user}
|
|
||||||
value={value}
|
|
||||||
setValue={setValue}
|
|
||||||
isOpenSide={isOpenSide}
|
|
||||||
setIsOpenSide={setIsOpenSide}
|
|
||||||
isTurnsDetails={isTurnsDetails}
|
|
||||||
setIsTurnsDetails={setIsTurnsDetails}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default UserAccountPage;
|
|
||||||
@@ -11,7 +11,7 @@ function HeadTab({
|
|||||||
components,
|
components,
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="opacity-page">
|
||||||
{isTurnsDetails ? (
|
{isTurnsDetails ? (
|
||||||
<IsTurnsDetails
|
<IsTurnsDetails
|
||||||
user={user}
|
user={user}
|
||||||
@@ -19,7 +19,7 @@ function HeadTab({
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<div className="!w-full mt-[24px] sm:mt-[26px] md:mt-[28px] lg:mt-[30px]">
|
<div className="!w-full">
|
||||||
<Tabs
|
<Tabs
|
||||||
style={{
|
style={{
|
||||||
".MuiTabs-indicator": {
|
".MuiTabs-indicator": {
|
||||||
@@ -50,7 +50,7 @@ function HeadTab({
|
|||||||
<div className="mt-[22px] px-0 md:px-[24px]">{components[tab]}</div>
|
<div className="mt-[22px] px-0 md:px-[24px]">{components[tab]}</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,25 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
import profileData from "@/data/profile_other.json";
|
||||||
|
|
||||||
import ArrowRightD from "@/components/icons/ArrowRightD";
|
import ArrowRightD from "@/components/icons/ArrowRightD";
|
||||||
import { Button } from "@mui/material";
|
import { Button } from "@mui/material";
|
||||||
import DownloadD from "@/components/icons/DownloadD";
|
import DownloadD from "@/components/icons/DownloadD";
|
||||||
import Disease from "../tabs/disease";
|
import Disease from "../detailUser/disease";
|
||||||
import Allergies from "../tabs/allergies";
|
import Allergies from "../detailUser/allergies";
|
||||||
import Medications from "../tabs/medications";
|
import Medications from "../detailUser/medications";
|
||||||
import Surgeries from "../tabs/surgeries";
|
import Surgeries from "../detailUser/surgeries";
|
||||||
import FamilyHistory from "../tabs/familyHistory";
|
import FamilyHistory from "../detailUser/familyHistory";
|
||||||
import Relatives from "../tabs/relatives";
|
import Relatives from "../detailUser/relatives";
|
||||||
import HeadTab from "./HeadTab";
|
import HeadTab from "./HeadTab";
|
||||||
|
|
||||||
import profileData from "@/data/profile_other.json";
|
import DetailUser from "../detailUser/information";
|
||||||
|
import Turns from "../sidebars/turns";
|
||||||
|
import Transactions from "../sidebars/transactions";
|
||||||
|
import Comments from "../sidebars/comments";
|
||||||
|
import Messages from "../sidebars/messages";
|
||||||
|
import NotfoundDashboard from "../NotfoundDashboard";
|
||||||
|
|
||||||
const listTab = [
|
const listTab = [
|
||||||
"بیماریها",
|
"بیماریها",
|
||||||
@@ -59,18 +65,27 @@ function ContentTabs({
|
|||||||
console.warn(`Unknown action: ${action}`);
|
console.warn(`Unknown action: ${action}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(newData);
|
|
||||||
|
|
||||||
setData(newData);
|
setData(newData);
|
||||||
};
|
};
|
||||||
|
|
||||||
const components = [
|
const components = [
|
||||||
<Disease data={data} changeData={changeData} />,
|
// <Disease data={data} changeData={changeData} />,
|
||||||
<Allergies data={data} changeData={changeData} />,
|
// <Allergies data={data} changeData={changeData} />,
|
||||||
<Medications data={data} changeData={changeData} />,
|
// <Medications data={data} changeData={changeData} />,
|
||||||
<Surgeries data={data} changeData={changeData} />,
|
// <Surgeries data={data} changeData={changeData} />,
|
||||||
<FamilyHistory data={data} changeData={changeData} />,
|
// <FamilyHistory data={data} changeData={changeData} />,
|
||||||
<Relatives data={data} changeData={changeData} />,
|
// <Relatives data={data} changeData={changeData} />,
|
||||||
|
|
||||||
|
<DetailUser
|
||||||
|
user={user}
|
||||||
|
isTurnsDetails={isTurnsDetails}
|
||||||
|
setIsTurnsDetails={setIsTurnsDetails}
|
||||||
|
/>,
|
||||||
|
<Turns user={user} loading={false} setIsTurnsDetails={setIsTurnsDetails} />,
|
||||||
|
<Transactions user={user} loading={false} />,
|
||||||
|
<Comments user={user} loading={false} />,
|
||||||
|
<Messages user={user} loading={false} />,
|
||||||
|
<NotfoundDashboard />,
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -102,7 +117,8 @@ function ContentTabs({
|
|||||||
</Button>
|
</Button>
|
||||||
) : undefined}
|
) : undefined}
|
||||||
</div>
|
</div>
|
||||||
<HeadTab
|
<div className="mt-[22px] px-0 md:px-[24px]">{components[value]}</div>
|
||||||
|
{/* <HeadTab
|
||||||
tab={tab}
|
tab={tab}
|
||||||
user={user}
|
user={user}
|
||||||
listTab={listTab}
|
listTab={listTab}
|
||||||
@@ -110,7 +126,7 @@ function ContentTabs({
|
|||||||
handleChange={handleChange}
|
handleChange={handleChange}
|
||||||
isTurnsDetails={isTurnsDetails}
|
isTurnsDetails={isTurnsDetails}
|
||||||
setIsTurnsDetails={setIsTurnsDetails}
|
setIsTurnsDetails={setIsTurnsDetails}
|
||||||
/>
|
/> */}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
import ModalDeleteItem from "../../components/modal/ModalDeleteItem";
|
import ModalDeleteItem from "@/components/dashboard/userAccount/components/modal/ModalDeleteItem";
|
||||||
import TextLoading from "@/app/component/loading/Text";
|
import TextLoading from "@/app/component/loading/Text";
|
||||||
import { TableCell, TableRow } from "@mui/material";
|
import { TableCell, TableRow } from "@mui/material";
|
||||||
import ModalEditItem from "../../components/modal/ModalEditItem";
|
import ModalEditItem from "@/components/dashboard/userAccount/components/modal/ModalEditItem";
|
||||||
import Content from "./modal/Content";
|
import Content from "./modal/Content";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
import CustomTable from "@/app/component/CustomTable";
|
import CustomTable from "@/app/component/CustomTable";
|
||||||
import Head from "../../components/Head";
|
import Head from "@/components/dashboard/userAccount/components/Head";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import ModalAddAlergie from "./modal";
|
|
||||||
import ItemAllergie from "./ItemAllergie";
|
import ItemAllergie from "./ItemAllergie";
|
||||||
|
import ModalAddAlergie from "./modal";
|
||||||
|
|
||||||
function Allergies({ data, changeData }) {
|
function Allergies({ data, changeData }) {
|
||||||
const tableHead = ["ردیف", "ماده آلرژیزا", "واکنش", "شدت", ""];
|
const tableHead = ["ردیف", "ماده آلرژیزا", "واکنش", "شدت", ""];
|
||||||
@@ -10,7 +10,7 @@ function Allergies({ data, changeData }) {
|
|||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="opacity-page">
|
||||||
<Head text="لیست آلرژی ها">
|
<Head text="لیست آلرژی ها">
|
||||||
<ModalAddAlergie
|
<ModalAddAlergie
|
||||||
open={open}
|
open={open}
|
||||||
+5
-3
@@ -1,6 +1,6 @@
|
|||||||
import { styleDefault } from "@/mui";
|
import { styleDefault } from "@/mui";
|
||||||
import AddBtn from "../../../components/AddBtn";
|
import AddBtn from "@/components/dashboard/userAccount/components/AddBtn";
|
||||||
import UpdateBtn from "../../../components/UpdateBtn";
|
import UpdateBtn from "@/components/dashboard/userAccount/components/UpdateBtn";
|
||||||
import { Button, Modal } from "@mui/material";
|
import { Button, Modal } from "@mui/material";
|
||||||
import Content from "./Content";
|
import Content from "./Content";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -51,7 +51,9 @@ function ModalAddAlergie({ open, setOpen, changeData }) {
|
|||||||
<Button
|
<Button
|
||||||
className="!mt-[32px] md:!mt-[36px] lg:!mt-[40px] !px-3 !py-2 !text-[16px] !font-medium !w-fit !mr-auto"
|
className="!mt-[32px] md:!mt-[36px] lg:!mt-[40px] !px-3 !py-2 !text-[16px] !font-medium !w-fit !mr-auto"
|
||||||
onClick={handleAddData}
|
onClick={handleAddData}
|
||||||
disabled={!newItem.reaction || !newItem.severity || !newItem.substance}
|
disabled={
|
||||||
|
!newItem.reaction || !newItem.severity || !newItem.substance
|
||||||
|
}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
>
|
>
|
||||||
اضافه کردن
|
اضافه کردن
|
||||||
+3
-3
@@ -1,15 +1,15 @@
|
|||||||
import CustomTable from "@/app/component/CustomTable";
|
import CustomTable from "@/app/component/CustomTable";
|
||||||
import TextLoading from "@/app/component/loading/Text";
|
import TextLoading from "@/app/component/loading/Text";
|
||||||
import { Switch, TableCell, TableRow } from "@mui/material";
|
import { Switch, TableCell, TableRow } from "@mui/material";
|
||||||
import Head from "../../components/Head";
|
import Head from "@/components/dashboard/userAccount/components/Head";
|
||||||
import UpdateBtn from "../../components/UpdateBtn";
|
import UpdateBtn from "@/components/dashboard/userAccount/components/UpdateBtn";
|
||||||
|
|
||||||
function Disease({ data, changeData }) {
|
function Disease({ data, changeData }) {
|
||||||
const tableHead = ["ردیف", "اسم", "وضعیت", ""];
|
const tableHead = ["ردیف", "اسم", "وضعیت", ""];
|
||||||
const centerTable = [0];
|
const centerTable = [0];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="opacity-page">
|
||||||
<Head text="لیست بیماری ها" add={false}>
|
<Head text="لیست بیماری ها" add={false}>
|
||||||
<UpdateBtn />
|
<UpdateBtn />
|
||||||
</Head>
|
</Head>
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
import ModalDeleteItem from "../../components/modal/ModalDeleteItem";
|
import ModalDeleteItem from "@/components/dashboard/userAccount/components/modal/ModalDeleteItem";
|
||||||
import TextLoading from "@/app/component/loading/Text";
|
import TextLoading from "@/app/component/loading/Text";
|
||||||
import { TableCell, TableRow } from "@mui/material";
|
import { TableCell, TableRow } from "@mui/material";
|
||||||
import ModalEditItem from "../../components/modal/ModalEditItem";
|
import ModalEditItem from "@/components/dashboard/userAccount/components/modal/ModalEditItem";
|
||||||
import Content from "./modal/Content";
|
import Content from "./modal/Content";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import CustomTable from "@/app/component/CustomTable";
|
import CustomTable from "@/app/component/CustomTable";
|
||||||
import Head from "../../components/Head";
|
import Head from "@/components/dashboard/userAccount/components/Head";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import ModalAddHistory from "./modal";
|
import ModalAddHistory from "./modal";
|
||||||
import ItemHistory from "./ItemHistory";
|
import ItemHistory from "./ItemHistory";
|
||||||
@@ -10,7 +10,7 @@ function FamilyHistory({ data, changeData }) {
|
|||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="opacity-page">
|
||||||
<Head text="لیست سابقه خانوادگی بیماری">
|
<Head text="لیست سابقه خانوادگی بیماری">
|
||||||
<ModalAddHistory
|
<ModalAddHistory
|
||||||
open={open}
|
open={open}
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import { styleDefault } from "@/mui";
|
import { styleDefault } from "@/mui";
|
||||||
import AddBtn from "../../../components/AddBtn";
|
import AddBtn from "@/components/dashboard/userAccount/components/AddBtn";
|
||||||
import UpdateBtn from "../../../components/UpdateBtn";
|
import UpdateBtn from "@/components/dashboard/userAccount/components/UpdateBtn";
|
||||||
import { Button, Modal } from "@mui/material";
|
import { Button, Modal } from "@mui/material";
|
||||||
import Content from "./Content";
|
import Content from "./Content";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import HeadTab from "../content/HeadTab";
|
||||||
|
import profileData from "@/data/profile_other.json";
|
||||||
|
|
||||||
|
// Tabs
|
||||||
|
import Medications from "./medications";
|
||||||
|
import Information from "./information";
|
||||||
|
import Disease from "./disease";
|
||||||
|
import Allergies from "./allergies";
|
||||||
|
import Surgeries from "./surgeries";
|
||||||
|
import FamilyHistory from "./familyHistory";
|
||||||
|
import Relatives from "./relatives";
|
||||||
|
|
||||||
|
const listTab = [
|
||||||
|
"اطلاعات عمومی",
|
||||||
|
"بیماریها",
|
||||||
|
"آلرژیها",
|
||||||
|
"داروهای مصرفی",
|
||||||
|
"جراحیها",
|
||||||
|
"سابقه خانوادگی بیماری",
|
||||||
|
"بستگان",
|
||||||
|
];
|
||||||
|
|
||||||
|
function DetailUser({ user, isTurnsDetails, setIsTurnsDetails }) {
|
||||||
|
const [tab, setTab] = useState(0);
|
||||||
|
const [data, setData] = useState(profileData[0]);
|
||||||
|
|
||||||
|
const handleChange = (_, newValue) => setTab(newValue);
|
||||||
|
const changeData = (action, name, id, payload) => {
|
||||||
|
const newData = {
|
||||||
|
...data,
|
||||||
|
[name]: [...data[name]],
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (action) {
|
||||||
|
case "update":
|
||||||
|
newData[name][id] = payload;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "add":
|
||||||
|
newData[name].push(payload);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "delete":
|
||||||
|
newData[name].splice(id, 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
console.warn(`Unknown action: ${action}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setData(newData);
|
||||||
|
};
|
||||||
|
|
||||||
|
const components = [
|
||||||
|
<Information
|
||||||
|
user={user}
|
||||||
|
isTurnsDetails={isTurnsDetails}
|
||||||
|
setIsTurnsDetails={setIsTurnsDetails}
|
||||||
|
/>,
|
||||||
|
<Disease data={data} changeData={changeData} />,
|
||||||
|
<Allergies data={data} changeData={changeData} />,
|
||||||
|
<Medications data={data} changeData={changeData} />,
|
||||||
|
<Surgeries data={data} changeData={changeData} />,
|
||||||
|
<FamilyHistory data={data} changeData={changeData} />,
|
||||||
|
<Relatives data={data} changeData={changeData} />,
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<HeadTab
|
||||||
|
tab={tab}
|
||||||
|
user={user}
|
||||||
|
listTab={listTab}
|
||||||
|
components={components}
|
||||||
|
handleChange={handleChange}
|
||||||
|
isTurnsDetails={isTurnsDetails}
|
||||||
|
setIsTurnsDetails={setIsTurnsDetails}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DetailUser;
|
||||||
+1
-1
@@ -2,7 +2,7 @@ import CalendarEdit from "@/components/icons/CalendarEdit";
|
|||||||
import { convertToJalali } from "@/helper";
|
import { convertToJalali } from "@/helper";
|
||||||
import { Button, Popover } from "@mui/material";
|
import { Button, Popover } from "@mui/material";
|
||||||
import { DatePicker } from "jalaali-react-date-picker";
|
import { DatePicker } from "jalaali-react-date-picker";
|
||||||
import React, { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
function DateBirthday({ data, changeData }) {
|
function DateBirthday({ data, changeData }) {
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
+2
-2
@@ -3,7 +3,7 @@ import Form from "./Form";
|
|||||||
import { Button } from "@mui/material";
|
import { Button } from "@mui/material";
|
||||||
import ArrowLeftWhiteD from "@/components/icons/ArrowLeftWhiteD";
|
import ArrowLeftWhiteD from "@/components/icons/ArrowLeftWhiteD";
|
||||||
|
|
||||||
function DetailUser({ user }) {
|
function Information({ user }) {
|
||||||
const [data, setData] = useState({
|
const [data, setData] = useState({
|
||||||
phone: { value: user.phone, isEdit: true },
|
phone: { value: user.phone, isEdit: true },
|
||||||
national_code: { value: user.national_code, isEdit: true },
|
national_code: { value: user.national_code, isEdit: true },
|
||||||
@@ -50,4 +50,4 @@ function DetailUser({ user }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DetailUser;
|
export default Information;
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
import ModalDeleteItem from "../../components/modal/ModalDeleteItem";
|
import ModalDeleteItem from "@/components/dashboard/userAccount/components/modal/ModalDeleteItem";
|
||||||
import TextLoading from "@/app/component/loading/Text";
|
import TextLoading from "@/app/component/loading/Text";
|
||||||
import { TableCell, TableRow } from "@mui/material";
|
import { TableCell, TableRow } from "@mui/material";
|
||||||
import ModalEditItem from "../../components/modal/ModalEditItem";
|
import ModalEditItem from "@/components/dashboard/userAccount/components/modal/ModalEditItem";
|
||||||
import Content from "./modal/Content";
|
import Content from "./modal/Content";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
import CustomTable from "@/app/component/CustomTable";
|
import CustomTable from "@/app/component/CustomTable";
|
||||||
import Head from "../../components/Head";
|
import Head from "@/components/dashboard/userAccount/components/Head";
|
||||||
import ModalAddMedications from "./modal";
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import ItemMedication from "./ItemMedication";
|
import ItemMedication from "./ItemMedication";
|
||||||
|
import ModalAddMedications from "./modal";
|
||||||
|
|
||||||
function Medications({ data, changeData }) {
|
function Medications({ data, changeData }) {
|
||||||
const tableHead = ["ردیف", "نام دارو", "دوز مصرفی", "تعداد و زمان مصرف", ""];
|
const tableHead = ["ردیف", "نام دارو", "دوز مصرفی", "تعداد و زمان مصرف", ""];
|
||||||
@@ -10,7 +10,7 @@ function Medications({ data, changeData }) {
|
|||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="opacity-page">
|
||||||
<Head text="لیست دارو های مصرفی">
|
<Head text="لیست دارو های مصرفی">
|
||||||
<ModalAddMedications
|
<ModalAddMedications
|
||||||
open={open}
|
open={open}
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import { styleDefault } from "@/mui";
|
import { styleDefault } from "@/mui";
|
||||||
import AddBtn from "../../../components/AddBtn";
|
import AddBtn from "@/components/dashboard/userAccount/components/AddBtn";
|
||||||
import UpdateBtn from "../../../components/UpdateBtn";
|
import UpdateBtn from "@/components/dashboard/userAccount/components/UpdateBtn";
|
||||||
import { Button, Modal } from "@mui/material";
|
import { Button, Modal } from "@mui/material";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import Content from "./Content";
|
import Content from "./Content";
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
import ModalDeleteItem from "../../components/modal/ModalDeleteItem";
|
import ModalDeleteItem from "@/components/dashboard/userAccount/components/modal/ModalDeleteItem";
|
||||||
import TextLoading from "@/app/component/loading/Text";
|
import TextLoading from "@/app/component/loading/Text";
|
||||||
import { TableCell, TableRow } from "@mui/material";
|
import { TableCell, TableRow } from "@mui/material";
|
||||||
import ModalEditItem from "../../components/modal/ModalEditItem";
|
import ModalEditItem from "@/components/dashboard/userAccount/components/modal/ModalEditItem";
|
||||||
import Content from "./modal/Content";
|
import Content from "./modal/Content";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
+4
-4
@@ -1,7 +1,7 @@
|
|||||||
import CustomTable from "@/app/component/CustomTable";
|
|
||||||
import Head from "../../components/Head";
|
|
||||||
import ModalAddRelatives from "./modal";
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import CustomTable from "@/app/component/CustomTable";
|
||||||
|
import Head from "@/components/dashboard/userAccount/components/Head";
|
||||||
|
import ModalAddRelatives from "./modal";
|
||||||
import ItemRelatives from "./ItemRelatives";
|
import ItemRelatives from "./ItemRelatives";
|
||||||
|
|
||||||
function Relatives({ data, changeData }) {
|
function Relatives({ data, changeData }) {
|
||||||
@@ -10,7 +10,7 @@ function Relatives({ data, changeData }) {
|
|||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="opacity-page">
|
||||||
<Head text="لیست بستگان">
|
<Head text="لیست بستگان">
|
||||||
<ModalAddRelatives
|
<ModalAddRelatives
|
||||||
open={open}
|
open={open}
|
||||||
-1
@@ -4,7 +4,6 @@ import Field from "@/app/component/Field";
|
|||||||
function Content({ setData, data }) {
|
function Content({ setData, data }) {
|
||||||
const handleChange = (name, value) =>
|
const handleChange = (name, value) =>
|
||||||
setData((prev) => ({ ...prev, [name]: value }));
|
setData((prev) => ({ ...prev, [name]: value }));
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
return (
|
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]">
|
<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]">
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import { styleDefault } from "@/mui";
|
import { styleDefault } from "@/mui";
|
||||||
import AddBtn from "../../../components/AddBtn";
|
import AddBtn from "@/components/dashboard/userAccount/components/AddBtn";
|
||||||
import UpdateBtn from "../../../components/UpdateBtn";
|
import UpdateBtn from "@/components/dashboard/userAccount/components/UpdateBtn";
|
||||||
import { Button, Modal } from "@mui/material";
|
import { Button, Modal } from "@mui/material";
|
||||||
import Content from "./Content";
|
import Content from "./Content";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
import ModalDeleteItem from "../../components/modal/ModalDeleteItem";
|
import ModalDeleteItem from "@/components/dashboard/userAccount/components/modal/ModalDeleteItem";
|
||||||
import TextLoading from "@/app/component/loading/Text";
|
import TextLoading from "@/app/component/loading/Text";
|
||||||
import { TableCell, TableRow } from "@mui/material";
|
import { TableCell, TableRow } from "@mui/material";
|
||||||
import ModalEditItem from "../../components/modal/ModalEditItem";
|
import ModalEditItem from "@/components/dashboard/userAccount/components/modal/ModalEditItem";
|
||||||
import Content from "./modal/Content";
|
import Content from "./modal/Content";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
+4
-8
@@ -1,14 +1,10 @@
|
|||||||
import CustomTable from "@/app/component/CustomTable";
|
import CustomTable from "@/app/component/CustomTable";
|
||||||
import TextLoading from "@/app/component/loading/Text";
|
import Head from "@/components/dashboard/userAccount/components/Head";
|
||||||
import EditB from "@/components/icons/EditB";
|
|
||||||
import TrashB from "@/components/icons/TrashB";
|
|
||||||
import { Button, TableCell, TableRow } from "@mui/material";
|
|
||||||
import Head from "../../components/Head";
|
|
||||||
import ModalAddSurgeries from "./modal";
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import ItemSurgeries from "./ItemSurgeries";
|
import ItemSurgeries from "./ItemSurgeries";
|
||||||
|
import ModalAddSurgeries from "./modal";
|
||||||
|
|
||||||
function Surgeries({ data, updateData, changeData }) {
|
function Surgeries({ data, changeData }) {
|
||||||
const tableHead = [
|
const tableHead = [
|
||||||
"ردیف",
|
"ردیف",
|
||||||
"نوع جراحی",
|
"نوع جراحی",
|
||||||
@@ -20,7 +16,7 @@ function Surgeries({ data, updateData, changeData }) {
|
|||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="opacity-page">
|
||||||
<Head text="لیست جراحی ها">
|
<Head text="لیست جراحی ها">
|
||||||
<ModalAddSurgeries
|
<ModalAddSurgeries
|
||||||
open={open}
|
open={open}
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import { styleDefault } from "@/mui";
|
import { styleDefault } from "@/mui";
|
||||||
import AddBtn from "../../../components/AddBtn";
|
import AddBtn from "@/components/dashboard/userAccount/components/AddBtn";
|
||||||
import UpdateBtn from "../../../components/UpdateBtn";
|
import UpdateBtn from "@/components/dashboard/userAccount/components/UpdateBtn";
|
||||||
import { Button, Modal } from "@mui/material";
|
import { Button, Modal } from "@mui/material";
|
||||||
import Content from "./Content";
|
import Content from "./Content";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import DetailUser from "./detailUser";
|
||||||
|
import Head from "./Head";
|
||||||
|
import NotfoundDashboard from "./NotfoundDashboard";
|
||||||
|
|
||||||
|
// Sidebars
|
||||||
|
import Comments from "./sidebars/comments";
|
||||||
|
import Messages from "./sidebars/messages";
|
||||||
|
import Transactions from "./sidebars/transactions";
|
||||||
|
import Turns from "./sidebars/turns";
|
||||||
|
|
||||||
|
function UserAccountPage({
|
||||||
|
user,
|
||||||
|
isTurnsDetails,
|
||||||
|
setIsTurnsDetails,
|
||||||
|
value,
|
||||||
|
setValue,
|
||||||
|
isOpenSide,
|
||||||
|
setIsOpenSide,
|
||||||
|
}) {
|
||||||
|
const sidebars = [
|
||||||
|
<DetailUser
|
||||||
|
user={user}
|
||||||
|
isTurnsDetails={isTurnsDetails}
|
||||||
|
setIsTurnsDetails={setIsTurnsDetails}
|
||||||
|
/>,
|
||||||
|
<Turns user={user} loading={false} setIsTurnsDetails={setIsTurnsDetails} />,
|
||||||
|
<Transactions user={user} loading={false} />,
|
||||||
|
<Comments user={user} loading={false} />,
|
||||||
|
<Messages user={user} loading={false} />,
|
||||||
|
<NotfoundDashboard />,
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="w-full md:w-[68%] lg:w-[72%]">
|
||||||
|
{value === 5 ? (
|
||||||
|
<NotfoundDashboard />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Head user={user} />
|
||||||
|
<div className=" mt-[24px] sm:mt-[26px] md:mt-[28px] lg:mt-[30px]">
|
||||||
|
{sidebars[value]}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default UserAccountPage;
|
||||||
@@ -3,7 +3,7 @@ import { Button } from "@mui/material";
|
|||||||
import ButtonData from "./ButtonData";
|
import ButtonData from "./ButtonData";
|
||||||
import TextLoading from "@/app/component/loading/Text";
|
import TextLoading from "@/app/component/loading/Text";
|
||||||
|
|
||||||
function Head({ user, setIsTurnsDetails, loading }) {
|
function Head({ setIsTurnsDetails }) {
|
||||||
return (
|
return (
|
||||||
<div className="hidden md:flex flex-wrap gap-x-[24px] gap-y-[12px] items-center justify-between">
|
<div className="hidden md:flex flex-wrap gap-x-[24px] gap-y-[12px] items-center justify-between">
|
||||||
<div className="flex items-center justify-start gap-[12px] sm:gap-[16px] md:gap-[20px] lg:gap-[24px]">
|
<div className="flex items-center justify-start gap-[12px] sm:gap-[16px] md:gap-[20px] lg:gap-[24px]">
|
||||||
@@ -13,13 +13,13 @@ function Head({ user, setIsTurnsDetails, loading }) {
|
|||||||
>
|
>
|
||||||
<ArrowRightS />
|
<ArrowRightS />
|
||||||
</Button>
|
</Button>
|
||||||
<TextLoading width={70} height={20} loading={loading}>
|
<TextLoading width={70} height={20} loading={false}>
|
||||||
<p className="text-[#3B3B3B] text-[14px] sm:text-[16px] md:text-[18px] lg:text-[20px] font-bold">
|
<p className="text-[#3B3B3B] text-[14px] sm:text-[16px] md:text-[18px] lg:text-[20px] font-bold">
|
||||||
جزئیات نوبت شما
|
جزئیات نوبت شما
|
||||||
</p>
|
</p>
|
||||||
</TextLoading>
|
</TextLoading>
|
||||||
</div>
|
</div>
|
||||||
<ButtonData loading={loading} />
|
<ButtonData loading={false} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import Head from "./Head";
|
|||||||
function IsTurnsDetails({ user, setIsTurnsDetails }) {
|
function IsTurnsDetails({ user, setIsTurnsDetails }) {
|
||||||
return (
|
return (
|
||||||
<div className="md:py-[20px] md:px-[24px] opacity-page">
|
<div className="md:py-[20px] md:px-[24px] opacity-page">
|
||||||
<Head user={user} loading={false} setIsTurnsDetails={setIsTurnsDetails} />
|
<Head setIsTurnsDetails={setIsTurnsDetails} />
|
||||||
<DetailLg user={user} loading={false} />
|
<DetailLg user={user} loading={false} />
|
||||||
<DetailSm user={user} loading={false} />
|
<DetailSm user={user} loading={false} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+4
-6
@@ -3,13 +3,11 @@ import { AbilityBuilder, createMongoAbility } from "@casl/ability";
|
|||||||
export function defineAbilitiesFor(user) {
|
export function defineAbilitiesFor(user) {
|
||||||
const { can, cannot, build } = new AbilityBuilder(createMongoAbility);
|
const { can, cannot, build } = new AbilityBuilder(createMongoAbility);
|
||||||
|
|
||||||
if (user?.role === "admin") {
|
if (user) {
|
||||||
can("access", "Dashboard");
|
can("access", "Dashboard");
|
||||||
} else if (user?.role === "manager") {
|
} else {
|
||||||
can("access", "Dashboard");
|
// can("access", "Dashboard");
|
||||||
} else {
|
cannot("access", "Dashboard");
|
||||||
can("access", "Dashboard");
|
|
||||||
// cannot("access", "Dashboard");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return build();
|
return build();
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@ import { cookies } from "next/headers";
|
|||||||
|
|
||||||
export async function getUser() {
|
export async function getUser() {
|
||||||
const cookieStore = cookies();
|
const cookieStore = cookies();
|
||||||
const raw = cookieStore.get("user");
|
const raw = cookieStore.get("access_token");
|
||||||
if (!raw) return null;
|
if (!raw) return null;
|
||||||
return JSON.parse(raw.value);
|
return raw;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,4 +29,5 @@ export const request = {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getUserProfile: (uuid) => api.get(`/api/v1/user-profile/${uuid}`),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user