handle update data in tab dashboard
This commit is contained in:
@@ -24,7 +24,9 @@ function AutoSelector({
|
|||||||
return option?.name || option?.label || "";
|
return option?.name || option?.label || "";
|
||||||
}}
|
}}
|
||||||
className="!w-full !rounded-lg auto-complete-selector"
|
className="!w-full !rounded-lg auto-complete-selector"
|
||||||
onChange={(e, newValue) => updateData(name, newValue?.label || "")}
|
onChange={(e, newValue) => {
|
||||||
|
updateData(name, newValue?.label || newValue || "");
|
||||||
|
}}
|
||||||
sx={{
|
sx={{
|
||||||
...styleTextSelectRight,
|
...styleTextSelectRight,
|
||||||
// Hide Icon Number
|
// Hide Icon Number
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ 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 { fetchReq } from "@/lib/req";
|
import { fetchReq } from "@/lib/req";
|
||||||
|
import { removeToken } from "@/utils";
|
||||||
import { cookies, headers } from "next/headers";
|
import { cookies, headers } from "next/headers";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
@@ -13,22 +14,20 @@ export default async function Dashboard({ searchParams }) {
|
|||||||
const cookieStore = cookies();
|
const cookieStore = cookies();
|
||||||
const token = cookieStore.get("access_token");
|
const token = cookieStore.get("access_token");
|
||||||
const userInfo = cookieStore.get("userInfo");
|
const userInfo = cookieStore.get("userInfo");
|
||||||
console.log(userInfo.value.uuid);
|
|
||||||
|
|
||||||
if (!ability.can("access", "Dashboard")) {
|
if (!ability.can("access", "Dashboard")) {
|
||||||
return redirect("/");
|
removeToken();
|
||||||
|
return redirect("/login");
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetchReq(
|
const response = await fetchReq(
|
||||||
`https://back-dev.clinic-pro.ir/api/v1/user-profile/${userInfo.value.uuid}`,
|
`https://back-dev.clinic-pro.ir/api/v1/user-profile/${JSON.parse(userInfo?.value).uuid}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token.value}`,
|
Authorization: `Bearer ${token.value}`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
.then((res) => console.log(res))
|
|
||||||
.catch((err) => console.log(err));
|
|
||||||
|
|
||||||
const userAgent = headers().get("user-agent") || "";
|
const userAgent = headers().get("user-agent") || "";
|
||||||
const isMobile = /Mobi|Android/i.test(userAgent);
|
const isMobile = /Mobi|Android/i.test(userAgent);
|
||||||
@@ -40,6 +39,7 @@ export default async function Dashboard({ searchParams }) {
|
|||||||
params={searchParams}
|
params={searchParams}
|
||||||
matchedCity={matchedCity}
|
matchedCity={matchedCity}
|
||||||
initialTurnsDetails={isMobile}
|
initialTurnsDetails={isMobile}
|
||||||
|
userInfo={JSON.parse(userInfo.value || {})}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,17 @@ import userData from "@/data/userData.json";
|
|||||||
import DashboardPage from "@/components/dashboard";
|
import DashboardPage from "@/components/dashboard";
|
||||||
import UserAccountPage from "./userAccount";
|
import UserAccountPage from "./userAccount";
|
||||||
|
|
||||||
function Content({ matchedCity, params, logged, initialIsOpenSide, dataUser }) {
|
function Content({
|
||||||
|
matchedCity,
|
||||||
|
userInfo,
|
||||||
|
params,
|
||||||
|
logged,
|
||||||
|
initialIsOpenSide,
|
||||||
|
dataUser,
|
||||||
|
}) {
|
||||||
const [value, setValue] = useState(Number(params?.sidebar) || 0);
|
const [value, setValue] = useState(Number(params?.sidebar) || 0);
|
||||||
const [isOpenSide, setIsOpenSide] = useState(initialIsOpenSide);
|
const [isOpenSide, setIsOpenSide] = useState(initialIsOpenSide);
|
||||||
const [isTurnsDetails, setIsTurnsDetails] = useState(false);
|
const [isTurnsDetails, setIsTurnsDetails] = useState(false);
|
||||||
console.log(dataUser);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardPage
|
<DashboardPage
|
||||||
@@ -27,6 +33,7 @@ function Content({ matchedCity, params, logged, initialIsOpenSide, dataUser }) {
|
|||||||
<UserAccountPage
|
<UserAccountPage
|
||||||
value={value}
|
value={value}
|
||||||
dataUser={dataUser}
|
dataUser={dataUser}
|
||||||
|
userInfo={userInfo}
|
||||||
user={userData.data}
|
user={userData.data}
|
||||||
setIsOpenSide={setIsOpenSide}
|
setIsOpenSide={setIsOpenSide}
|
||||||
isTurnsDetails={isTurnsDetails}
|
isTurnsDetails={isTurnsDetails}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import UpdateList from "@/components/icons/UpdateList";
|
import UpdateList from "@/components/icons/UpdateList";
|
||||||
import { Button } from "@mui/material";
|
import { Button } from "@mui/material";
|
||||||
|
|
||||||
function UpdateBtn() {
|
function UpdateBtn({ updateData }) {
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
|
onClick={updateData}
|
||||||
className="!border-[#5559CE] !border-[2px] !flex !items-center !justify-center !gap-2 !text-[14px] !font-medium
|
className="!border-[#5559CE] !border-[2px] !flex !items-center !justify-center !gap-2 !text-[14px] !font-medium
|
||||||
!py-[6px] md:!py-2 lg:!py-[9px] !px-[16px] sm:!px-[23px] md:!px-[29px] lg:!px-[36px] !mr-0 md:!mr-4"
|
!py-[6px] md:!py-2 lg:!py-[9px] !px-[16px] sm:!px-[23px] md:!px-[29px] lg:!px-[36px] !mr-0 md:!mr-4"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -3,31 +3,42 @@ 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/dashboard/userAccount/components/Head";
|
import Head from "@/components/dashboard/userAccount/components/Head";
|
||||||
import UpdateBtn from "@/components/dashboard/userAccount/components/UpdateBtn";
|
import UpdateBtn from "@/components/dashboard/userAccount/components/UpdateBtn";
|
||||||
import { useState } from "react";
|
|
||||||
import { dieses } from "../information/dieses";
|
|
||||||
|
|
||||||
function Disease() {
|
function Disease({ data, setData, updateData }) {
|
||||||
|
const { other } = data;
|
||||||
|
const { disease } = other && other[0];
|
||||||
const tableHead = ["ردیف", "اسم", "وضعیت", ""];
|
const tableHead = ["ردیف", "اسم", "وضعیت", ""];
|
||||||
const [data, setData] = useState(dieses);
|
|
||||||
const centerTable = [0];
|
const centerTable = [0];
|
||||||
|
|
||||||
const changeData = (id, payload) => {
|
const changeData = (id, payload) => {
|
||||||
const updatedData = data.map((item, index) =>
|
const newDisease = data.other[0].disease?.map((item, index) =>
|
||||||
index === id ? { ...item, status: payload } : item
|
index === id ? { ...item, status: payload } : item
|
||||||
);
|
);
|
||||||
setData(updatedData);
|
|
||||||
|
const newData = {
|
||||||
|
...data,
|
||||||
|
other: [
|
||||||
|
{
|
||||||
|
...data.other[0],
|
||||||
|
disease: newDisease,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
setData(newData);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="opacity-page">
|
<div className="opacity-page">
|
||||||
<Head text="لیست بیماری ها" add={false}>
|
<Head text="لیست بیماری ها" add={false}>
|
||||||
<UpdateBtn />
|
<UpdateBtn updateData={updateData} />
|
||||||
</Head>
|
</Head>
|
||||||
<CustomTable
|
<CustomTable
|
||||||
zeroRadius={true}
|
zeroRadius={true}
|
||||||
tableHead={tableHead}
|
tableHead={tableHead}
|
||||||
centerTable={centerTable}
|
centerTable={centerTable}
|
||||||
>
|
>
|
||||||
{data.map((row, idx) => (
|
{disease?.map((row, idx) => (
|
||||||
<TableRow
|
<TableRow
|
||||||
key={idx}
|
key={idx}
|
||||||
className="!border-0 !border-b !border-[#DBDBDB] dark:!border-transparent"
|
className="!border-0 !border-b !border-[#DBDBDB] dark:!border-transparent"
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
export 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);
|
||||||
|
};
|
||||||
@@ -10,10 +10,60 @@ import Allergies from "./allergies";
|
|||||||
import Surgeries from "./surgeries";
|
import Surgeries from "./surgeries";
|
||||||
import FamilyHistory from "./familyHistory";
|
import FamilyHistory from "./familyHistory";
|
||||||
import Relatives from "./relatives";
|
import Relatives from "./relatives";
|
||||||
|
import { request } from "@/services/response";
|
||||||
|
import { changeData } from "./function";
|
||||||
|
|
||||||
function DetailUser({ user, isTurnsDetails, setIsTurnsDetails, dataUser }) {
|
function DetailUser({
|
||||||
|
user,
|
||||||
|
dataUser,
|
||||||
|
userInfo,
|
||||||
|
isTurnsDetails,
|
||||||
|
setIsTurnsDetails,
|
||||||
|
}) {
|
||||||
const [tab, setTab] = useState(0);
|
const [tab, setTab] = useState(0);
|
||||||
const [data, setData] = useState(profileData[0]);
|
const {
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
birthday,
|
||||||
|
insurance_id,
|
||||||
|
basic_insurance,
|
||||||
|
blood_type,
|
||||||
|
education,
|
||||||
|
fathers_name,
|
||||||
|
gender,
|
||||||
|
home_phone,
|
||||||
|
job,
|
||||||
|
marital_status,
|
||||||
|
national_code,
|
||||||
|
national_code_approved,
|
||||||
|
supplementary_insurance,
|
||||||
|
work_phone,
|
||||||
|
address,
|
||||||
|
other,
|
||||||
|
} = dataUser;
|
||||||
|
const [data, setData] = useState({
|
||||||
|
name: name,
|
||||||
|
description: description,
|
||||||
|
birthday: birthday,
|
||||||
|
insurance_id: insurance_id,
|
||||||
|
basic_insurance: basic_insurance,
|
||||||
|
blood_type: blood_type,
|
||||||
|
education: education,
|
||||||
|
fathers_name: fathers_name,
|
||||||
|
gender: gender,
|
||||||
|
home_phone: home_phone,
|
||||||
|
job: job,
|
||||||
|
marital_status: marital_status,
|
||||||
|
national_code: national_code,
|
||||||
|
national_code_approved: national_code_approved,
|
||||||
|
supplementary_insurance: supplementary_insurance,
|
||||||
|
work_phone: work_phone,
|
||||||
|
address: address,
|
||||||
|
other: other,
|
||||||
|
});
|
||||||
|
console.log(data);
|
||||||
|
console.log(dataUser);
|
||||||
|
console.log(userInfo);
|
||||||
|
|
||||||
const listTab = [
|
const listTab = [
|
||||||
"اطلاعات عمومی",
|
"اطلاعات عمومی",
|
||||||
@@ -26,40 +76,24 @@ function DetailUser({ user, isTurnsDetails, setIsTurnsDetails, dataUser }) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const handleChange = (_, newValue) => setTab(newValue);
|
const handleChange = (_, newValue) => setTab(newValue);
|
||||||
const changeData = (action, name, id, payload) => {
|
const updateData = () => {
|
||||||
const newData = {
|
request
|
||||||
...data,
|
.patchUserProfile(data, data.uuid)
|
||||||
[name]: [...data[name]],
|
.then((res) => {})
|
||||||
};
|
.catch((err) => {});
|
||||||
|
|
||||||
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 = [
|
const components = [
|
||||||
<Information
|
<Information
|
||||||
user={user}
|
user={user}
|
||||||
|
data={data}
|
||||||
|
setData={setData}
|
||||||
|
userInfo={userInfo}
|
||||||
dataUser={dataUser}
|
dataUser={dataUser}
|
||||||
isTurnsDetails={isTurnsDetails}
|
isTurnsDetails={isTurnsDetails}
|
||||||
setIsTurnsDetails={setIsTurnsDetails}
|
setIsTurnsDetails={setIsTurnsDetails}
|
||||||
/>,
|
/>,
|
||||||
<Disease data={data} />,
|
<Disease data={data} setData={setData} updateData={updateData} />,
|
||||||
<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} />,
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import Content from "./Content";
|
|||||||
import DateBirthday from "./DateBirthday";
|
import DateBirthday from "./DateBirthday";
|
||||||
import Field from "./Field";
|
import Field from "./Field";
|
||||||
import {
|
import {
|
||||||
insurance,
|
|
||||||
gender,
|
gender,
|
||||||
blood_group,
|
blood_group,
|
||||||
marital_status,
|
marital_status,
|
||||||
@@ -11,8 +10,9 @@ import {
|
|||||||
} from "./listSelector";
|
} from "./listSelector";
|
||||||
import AutoSelector from "@/app/component/element/AutoSelector";
|
import AutoSelector from "@/app/component/element/AutoSelector";
|
||||||
|
|
||||||
function Form({ data, changeData, prevData }) {
|
function Form({ data, userInfo, insurance, changeData, prevData }) {
|
||||||
const findVal = (list, name) => data && list.find((g) => g.id === data[name]);
|
const findVal = (list, name) =>
|
||||||
|
data && list && list.length && list.find((g) => g.id === data[name]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-[24px]">
|
<div className="grid grid-cols-1 lg:grid-cols-2 gap-[24px]">
|
||||||
@@ -22,8 +22,8 @@ function Form({ data, changeData, prevData }) {
|
|||||||
iconGray={true}
|
iconGray={true}
|
||||||
type="number"
|
type="number"
|
||||||
changeData={changeData}
|
changeData={changeData}
|
||||||
data={data?.work_phone}
|
data={userInfo?.username}
|
||||||
disable={prevData}
|
disable={true}
|
||||||
name="work_phone"
|
name="work_phone"
|
||||||
/>
|
/>
|
||||||
</Content>
|
</Content>
|
||||||
@@ -75,7 +75,9 @@ function Form({ data, changeData, prevData }) {
|
|||||||
</Content>
|
</Content>
|
||||||
<Content title="نوع بیمه">
|
<Content title="نوع بیمه">
|
||||||
<AutoSelector
|
<AutoSelector
|
||||||
updateData={changeData}
|
updateData={(name, val) => {
|
||||||
|
changeData([Number(val.id)], "value", name);
|
||||||
|
}}
|
||||||
value={findVal(insurance, "basic_insurance")}
|
value={findVal(insurance, "basic_insurance")}
|
||||||
label="نوع بیمه"
|
label="نوع بیمه"
|
||||||
name="basic_insurance"
|
name="basic_insurance"
|
||||||
@@ -88,8 +90,8 @@ function Form({ data, changeData, prevData }) {
|
|||||||
iconGray={true}
|
iconGray={true}
|
||||||
type="number"
|
type="number"
|
||||||
changeData={changeData}
|
changeData={changeData}
|
||||||
data={data?.insurance_number}
|
data={data?.supplementary_insurance}
|
||||||
name="insurance_number"
|
name="supplementary_insurance"
|
||||||
/>
|
/>
|
||||||
</Content>
|
</Content>
|
||||||
<Content title="گروه خونی">
|
<Content title="گروه خونی">
|
||||||
|
|||||||
@@ -1,13 +1,25 @@
|
|||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import Form from "./Form";
|
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";
|
||||||
import { request } from "@/services/response";
|
import { request } from "@/services/response";
|
||||||
|
import Cookies from "js-cookie";
|
||||||
|
|
||||||
function Information({ user, dataUser }) {
|
function Information({ user, data, setData, userInfo, dataUser }) {
|
||||||
const [disable, setDisable] = useState(true);
|
const [disable, setDisable] = useState(true);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [data, setData] = useState(dataUser || {});
|
const [insurance, setInsurance] = useState();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
request
|
||||||
|
.getInsuranceType()
|
||||||
|
.then((res) => {
|
||||||
|
if (res && res.data) {
|
||||||
|
setInsurance(res.data);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {});
|
||||||
|
}, []);
|
||||||
|
|
||||||
const changeData = (value, type, name) => {
|
const changeData = (value, type, name) => {
|
||||||
disable && setDisable(false);
|
disable && setDisable(false);
|
||||||
@@ -19,7 +31,10 @@ function Information({ user, dataUser }) {
|
|||||||
|
|
||||||
const sendReq = () => {
|
const sendReq = () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
request[dataUser ? "patchUserProfile" : "postUserProfile"](data)
|
request[dataUser ? "patchUserProfile" : "postUserProfile"](
|
||||||
|
data,
|
||||||
|
Cookies.get("uuid")
|
||||||
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
})
|
})
|
||||||
@@ -30,7 +45,13 @@ function Information({ user, dataUser }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="opacity-page">
|
<div className="opacity-page">
|
||||||
<Form data={data} changeData={changeData} prevData={dataUser} />
|
<Form
|
||||||
|
data={data}
|
||||||
|
userInfo={userInfo}
|
||||||
|
prevData={dataUser}
|
||||||
|
insurance={insurance}
|
||||||
|
changeData={changeData}
|
||||||
|
/>
|
||||||
<Button
|
<Button
|
||||||
disabled={disable}
|
disabled={disable}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import Transactions from "./sidebars/transactions";
|
|||||||
import Turns from "./sidebars/turns";
|
import Turns from "./sidebars/turns";
|
||||||
import DownloadD from "@/components/icons/DownloadD";
|
import DownloadD from "@/components/icons/DownloadD";
|
||||||
import ArrowRightD from "@/components/icons/ArrowRightD";
|
import ArrowRightD from "@/components/icons/ArrowRightD";
|
||||||
import { useState } from "react";
|
|
||||||
|
|
||||||
const listTab = [
|
const listTab = [
|
||||||
"حساب کاربری",
|
"حساب کاربری",
|
||||||
@@ -28,11 +27,13 @@ function UserAccountPage({
|
|||||||
value,
|
value,
|
||||||
setIsOpenSide,
|
setIsOpenSide,
|
||||||
dataUser,
|
dataUser,
|
||||||
|
userInfo,
|
||||||
}) {
|
}) {
|
||||||
const sidebars = [
|
const sidebars = [
|
||||||
<DetailUser
|
<DetailUser
|
||||||
user={user}
|
user={user}
|
||||||
dataUser={dataUser}
|
dataUser={dataUser}
|
||||||
|
userInfo={userInfo}
|
||||||
isTurnsDetails={isTurnsDetails}
|
isTurnsDetails={isTurnsDetails}
|
||||||
setIsTurnsDetails={setIsTurnsDetails}
|
setIsTurnsDetails={setIsTurnsDetails}
|
||||||
/>,
|
/>,
|
||||||
|
|||||||
@@ -44,7 +44,13 @@ function SelectSort() {
|
|||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
IconComponent={() => (
|
IconComponent={() => (
|
||||||
<div className="mx-3 min-w-[20px] md:min-w-[22px] lg:min-w-[24px] min-h-[20px] md:min-h-[22px] lg:min-h-[24px]">
|
<div
|
||||||
|
className="mx-3
|
||||||
|
min-w-[20px] md:min-w-[22px] lg:min-w-[24px] min-h-[20px] md:min-h-[22px] lg:min-h-[24px]
|
||||||
|
max-w-[20px] md:max-w-[22px] lg:max-w-[24px] max-h-[20px] md:max-h-[22px] lg:max-h-[24px]
|
||||||
|
w-[20px] md:w-[22px] lg:w-[24px] h-[20px] md:h-[22px] lg:h-[24px]
|
||||||
|
"
|
||||||
|
>
|
||||||
<ArrowBottomD />
|
<ArrowBottomD />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
+5
-1
@@ -2,7 +2,11 @@ import { cookies } from "next/headers";
|
|||||||
|
|
||||||
export async function getUser() {
|
export async function getUser() {
|
||||||
const cookieStore = cookies();
|
const cookieStore = cookies();
|
||||||
const raw = cookieStore.get("access_token");
|
const raw =
|
||||||
|
cookieStore.get("access_token") &&
|
||||||
|
cookieStore.get("refresh_token") &&
|
||||||
|
cookieStore.get("uuid") &&
|
||||||
|
cookieStore.get("userInfo");
|
||||||
if (!raw) return null;
|
if (!raw) return null;
|
||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,4 +34,10 @@ export const request = {
|
|||||||
patchUserProfile: (data, uuid) =>
|
patchUserProfile: (data, uuid) =>
|
||||||
api.patch(`api/v1/user-profile/${uuid}`, data),
|
api.patch(`api/v1/user-profile/${uuid}`, data),
|
||||||
getUserInfo: (headers) => api.get("oauth/userinfo", headers),
|
getUserInfo: (headers) => api.get("oauth/userinfo", headers),
|
||||||
|
getInsuranceType: () =>
|
||||||
|
api.get("api/v1/categorys/insurance_type", {
|
||||||
|
headers: {
|
||||||
|
Authorization: "",
|
||||||
|
},
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user