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 { getUser } from "@/lib/auth";
|
||||
import { getStateInfo } from "@/lib/getStateInfo";
|
||||
import axios from "axios";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
async function UserAccount() {
|
||||
export default async function Dashboard() {
|
||||
const { matchedCity } = getStateInfo();
|
||||
const user = await getUser();
|
||||
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")) {
|
||||
return redirect("/");
|
||||
}
|
||||
|
||||
return <Content matchedCity={matchedCity} />;
|
||||
}
|
||||
|
||||
export default UserAccount;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useState } from "react";
|
||||
|
||||
import userData from "@/data/userData.json";
|
||||
import DashboardPage from "@/components/dashboard";
|
||||
import UserAccountPage from "@/components/dashboard/userAccount/UserAccount";
|
||||
import UserAccountPage from "./userAccount";
|
||||
|
||||
function Content({ matchedCity }) {
|
||||
const [value, setValue] = useState(0);
|
||||
@@ -15,7 +15,7 @@ function Content({ matchedCity }) {
|
||||
<DashboardPage
|
||||
value={value}
|
||||
setValue={setValue}
|
||||
user={userData.data}
|
||||
user={userData.data}
|
||||
isOpenSide={isOpenSide}
|
||||
matchedCity={matchedCity}
|
||||
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,
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<div className="opacity-page">
|
||||
{isTurnsDetails ? (
|
||||
<IsTurnsDetails
|
||||
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
|
||||
style={{
|
||||
".MuiTabs-indicator": {
|
||||
@@ -50,7 +50,7 @@ function HeadTab({
|
||||
<div className="mt-[22px] px-0 md:px-[24px]">{components[tab]}</div>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import profileData from "@/data/profile_other.json";
|
||||
|
||||
import ArrowRightD from "@/components/icons/ArrowRightD";
|
||||
import { Button } from "@mui/material";
|
||||
import DownloadD from "@/components/icons/DownloadD";
|
||||
import Disease from "../tabs/disease";
|
||||
import Allergies from "../tabs/allergies";
|
||||
import Medications from "../tabs/medications";
|
||||
import Surgeries from "../tabs/surgeries";
|
||||
import FamilyHistory from "../tabs/familyHistory";
|
||||
import Relatives from "../tabs/relatives";
|
||||
import Disease from "../detailUser/disease";
|
||||
import Allergies from "../detailUser/allergies";
|
||||
import Medications from "../detailUser/medications";
|
||||
import Surgeries from "../detailUser/surgeries";
|
||||
import FamilyHistory from "../detailUser/familyHistory";
|
||||
import Relatives from "../detailUser/relatives";
|
||||
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 = [
|
||||
"بیماریها",
|
||||
@@ -59,18 +65,27 @@ function ContentTabs({
|
||||
console.warn(`Unknown action: ${action}`);
|
||||
return;
|
||||
}
|
||||
console.log(newData);
|
||||
|
||||
setData(newData);
|
||||
};
|
||||
|
||||
const components = [
|
||||
<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} />,
|
||||
// <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} />,
|
||||
|
||||
<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 (
|
||||
@@ -102,7 +117,8 @@ function ContentTabs({
|
||||
</Button>
|
||||
) : undefined}
|
||||
</div>
|
||||
<HeadTab
|
||||
<div className="mt-[22px] px-0 md:px-[24px]">{components[value]}</div>
|
||||
{/* <HeadTab
|
||||
tab={tab}
|
||||
user={user}
|
||||
listTab={listTab}
|
||||
@@ -110,7 +126,7 @@ function ContentTabs({
|
||||
handleChange={handleChange}
|
||||
isTurnsDetails={isTurnsDetails}
|
||||
setIsTurnsDetails={setIsTurnsDetails}
|
||||
/>
|
||||
/> */}
|
||||
</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 { 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 { useState } from "react";
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
import CustomTable from "@/app/component/CustomTable";
|
||||
import Head from "../../components/Head";
|
||||
import Head from "@/components/dashboard/userAccount/components/Head";
|
||||
import { useState } from "react";
|
||||
import ModalAddAlergie from "./modal";
|
||||
import ItemAllergie from "./ItemAllergie";
|
||||
import ModalAddAlergie from "./modal";
|
||||
|
||||
function Allergies({ data, changeData }) {
|
||||
const tableHead = ["ردیف", "ماده آلرژیزا", "واکنش", "شدت", ""];
|
||||
@@ -10,7 +10,7 @@ function Allergies({ data, changeData }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="opacity-page">
|
||||
<Head text="لیست آلرژی ها">
|
||||
<ModalAddAlergie
|
||||
open={open}
|
||||
+5
-3
@@ -1,6 +1,6 @@
|
||||
import { styleDefault } from "@/mui";
|
||||
import AddBtn from "../../../components/AddBtn";
|
||||
import UpdateBtn from "../../../components/UpdateBtn";
|
||||
import AddBtn from "@/components/dashboard/userAccount/components/AddBtn";
|
||||
import UpdateBtn from "@/components/dashboard/userAccount/components/UpdateBtn";
|
||||
import { Button, Modal } from "@mui/material";
|
||||
import Content from "./Content";
|
||||
import { useState } from "react";
|
||||
@@ -51,7 +51,9 @@ function ModalAddAlergie({ open, setOpen, changeData }) {
|
||||
<Button
|
||||
className="!mt-[32px] md:!mt-[36px] lg:!mt-[40px] !px-3 !py-2 !text-[16px] !font-medium !w-fit !mr-auto"
|
||||
onClick={handleAddData}
|
||||
disabled={!newItem.reaction || !newItem.severity || !newItem.substance}
|
||||
disabled={
|
||||
!newItem.reaction || !newItem.severity || !newItem.substance
|
||||
}
|
||||
variant="contained"
|
||||
>
|
||||
اضافه کردن
|
||||
+3
-3
@@ -1,15 +1,15 @@
|
||||
import CustomTable from "@/app/component/CustomTable";
|
||||
import TextLoading from "@/app/component/loading/Text";
|
||||
import { Switch, TableCell, TableRow } from "@mui/material";
|
||||
import Head from "../../components/Head";
|
||||
import UpdateBtn from "../../components/UpdateBtn";
|
||||
import Head from "@/components/dashboard/userAccount/components/Head";
|
||||
import UpdateBtn from "@/components/dashboard/userAccount/components/UpdateBtn";
|
||||
|
||||
function Disease({ data, changeData }) {
|
||||
const tableHead = ["ردیف", "اسم", "وضعیت", ""];
|
||||
const centerTable = [0];
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="opacity-page">
|
||||
<Head text="لیست بیماری ها" add={false}>
|
||||
<UpdateBtn />
|
||||
</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 { 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 { useState } from "react";
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import CustomTable from "@/app/component/CustomTable";
|
||||
import Head from "../../components/Head";
|
||||
import Head from "@/components/dashboard/userAccount/components/Head";
|
||||
import { useState } from "react";
|
||||
import ModalAddHistory from "./modal";
|
||||
import ItemHistory from "./ItemHistory";
|
||||
@@ -10,7 +10,7 @@ function FamilyHistory({ data, changeData }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="opacity-page">
|
||||
<Head text="لیست سابقه خانوادگی بیماری">
|
||||
<ModalAddHistory
|
||||
open={open}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import { styleDefault } from "@/mui";
|
||||
import AddBtn from "../../../components/AddBtn";
|
||||
import UpdateBtn from "../../../components/UpdateBtn";
|
||||
import AddBtn from "@/components/dashboard/userAccount/components/AddBtn";
|
||||
import UpdateBtn from "@/components/dashboard/userAccount/components/UpdateBtn";
|
||||
import { Button, Modal } from "@mui/material";
|
||||
import Content from "./Content";
|
||||
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 { Button, Popover } from "@mui/material";
|
||||
import { DatePicker } from "jalaali-react-date-picker";
|
||||
import React, { useState } from "react";
|
||||
import { useState } from "react";
|
||||
|
||||
function DateBirthday({ data, changeData }) {
|
||||
const [anchorEl, setAnchorEl] = useState(null);
|
||||
+2
-2
@@ -3,7 +3,7 @@ import Form from "./Form";
|
||||
import { Button } from "@mui/material";
|
||||
import ArrowLeftWhiteD from "@/components/icons/ArrowLeftWhiteD";
|
||||
|
||||
function DetailUser({ user }) {
|
||||
function Information({ user }) {
|
||||
const [data, setData] = useState({
|
||||
phone: { value: user.phone, 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 { 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 { useState } from "react";
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
import CustomTable from "@/app/component/CustomTable";
|
||||
import Head from "../../components/Head";
|
||||
import ModalAddMedications from "./modal";
|
||||
import Head from "@/components/dashboard/userAccount/components/Head";
|
||||
import { useState } from "react";
|
||||
import ItemMedication from "./ItemMedication";
|
||||
import ModalAddMedications from "./modal";
|
||||
|
||||
function Medications({ data, changeData }) {
|
||||
const tableHead = ["ردیف", "نام دارو", "دوز مصرفی", "تعداد و زمان مصرف", ""];
|
||||
@@ -10,7 +10,7 @@ function Medications({ data, changeData }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="opacity-page">
|
||||
<Head text="لیست دارو های مصرفی">
|
||||
<ModalAddMedications
|
||||
open={open}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import { styleDefault } from "@/mui";
|
||||
import AddBtn from "../../../components/AddBtn";
|
||||
import UpdateBtn from "../../../components/UpdateBtn";
|
||||
import AddBtn from "@/components/dashboard/userAccount/components/AddBtn";
|
||||
import UpdateBtn from "@/components/dashboard/userAccount/components/UpdateBtn";
|
||||
import { Button, Modal } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
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 { 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 { 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 CustomTable from "@/app/component/CustomTable";
|
||||
import Head from "@/components/dashboard/userAccount/components/Head";
|
||||
import ModalAddRelatives from "./modal";
|
||||
import ItemRelatives from "./ItemRelatives";
|
||||
|
||||
function Relatives({ data, changeData }) {
|
||||
@@ -10,7 +10,7 @@ function Relatives({ data, changeData }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="opacity-page">
|
||||
<Head text="لیست بستگان">
|
||||
<ModalAddRelatives
|
||||
open={open}
|
||||
-1
@@ -4,7 +4,6 @@ import Field from "@/app/component/Field";
|
||||
function Content({ setData, data }) {
|
||||
const handleChange = (name, value) =>
|
||||
setData((prev) => ({ ...prev, [name]: value }));
|
||||
console.log(data);
|
||||
|
||||
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]">
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import { styleDefault } from "@/mui";
|
||||
import AddBtn from "../../../components/AddBtn";
|
||||
import UpdateBtn from "../../../components/UpdateBtn";
|
||||
import AddBtn from "@/components/dashboard/userAccount/components/AddBtn";
|
||||
import UpdateBtn from "@/components/dashboard/userAccount/components/UpdateBtn";
|
||||
import { Button, Modal } from "@mui/material";
|
||||
import Content from "./Content";
|
||||
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 { 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 { useState } from "react";
|
||||
|
||||
+4
-8
@@ -1,14 +1,10 @@
|
||||
import CustomTable from "@/app/component/CustomTable";
|
||||
import TextLoading from "@/app/component/loading/Text";
|
||||
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 Head from "@/components/dashboard/userAccount/components/Head";
|
||||
import { useState } from "react";
|
||||
import ItemSurgeries from "./ItemSurgeries";
|
||||
import ModalAddSurgeries from "./modal";
|
||||
|
||||
function Surgeries({ data, updateData, changeData }) {
|
||||
function Surgeries({ data, changeData }) {
|
||||
const tableHead = [
|
||||
"ردیف",
|
||||
"نوع جراحی",
|
||||
@@ -20,7 +16,7 @@ function Surgeries({ data, updateData, changeData }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="opacity-page">
|
||||
<Head text="لیست جراحی ها">
|
||||
<ModalAddSurgeries
|
||||
open={open}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import { styleDefault } from "@/mui";
|
||||
import AddBtn from "../../../components/AddBtn";
|
||||
import UpdateBtn from "../../../components/UpdateBtn";
|
||||
import AddBtn from "@/components/dashboard/userAccount/components/AddBtn";
|
||||
import UpdateBtn from "@/components/dashboard/userAccount/components/UpdateBtn";
|
||||
import { Button, Modal } from "@mui/material";
|
||||
import Content from "./Content";
|
||||
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 TextLoading from "@/app/component/loading/Text";
|
||||
|
||||
function Head({ user, setIsTurnsDetails, loading }) {
|
||||
function Head({ setIsTurnsDetails }) {
|
||||
return (
|
||||
<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]">
|
||||
@@ -13,13 +13,13 @@ function Head({ user, setIsTurnsDetails, loading }) {
|
||||
>
|
||||
<ArrowRightS />
|
||||
</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>
|
||||
</TextLoading>
|
||||
</div>
|
||||
<ButtonData loading={loading} />
|
||||
<ButtonData loading={false} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import Head from "./Head";
|
||||
function IsTurnsDetails({ user, setIsTurnsDetails }) {
|
||||
return (
|
||||
<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} />
|
||||
<DetailSm user={user} loading={false} />
|
||||
</div>
|
||||
|
||||
+4
-6
@@ -3,13 +3,11 @@ import { AbilityBuilder, createMongoAbility } from "@casl/ability";
|
||||
export function defineAbilitiesFor(user) {
|
||||
const { can, cannot, build } = new AbilityBuilder(createMongoAbility);
|
||||
|
||||
if (user?.role === "admin") {
|
||||
if (user) {
|
||||
can("access", "Dashboard");
|
||||
} else if (user?.role === "manager") {
|
||||
can("access", "Dashboard");
|
||||
} else {
|
||||
can("access", "Dashboard");
|
||||
// cannot("access", "Dashboard");
|
||||
} else {
|
||||
// can("access", "Dashboard");
|
||||
cannot("access", "Dashboard");
|
||||
}
|
||||
|
||||
return build();
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ import { cookies } from "next/headers";
|
||||
|
||||
export async function getUser() {
|
||||
const cookieStore = cookies();
|
||||
const raw = cookieStore.get("user");
|
||||
const raw = cookieStore.get("access_token");
|
||||
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