handle update data in tab dashboard
This commit is contained in:
@@ -24,7 +24,9 @@ function AutoSelector({
|
||||
return option?.name || option?.label || "";
|
||||
}}
|
||||
className="!w-full !rounded-lg auto-complete-selector"
|
||||
onChange={(e, newValue) => updateData(name, newValue?.label || "")}
|
||||
onChange={(e, newValue) => {
|
||||
updateData(name, newValue?.label || newValue || "");
|
||||
}}
|
||||
sx={{
|
||||
...styleTextSelectRight,
|
||||
// Hide Icon Number
|
||||
|
||||
@@ -3,6 +3,7 @@ import { defineAbilitiesFor } from "@/lib/ability";
|
||||
import { getUser } from "@/lib/auth";
|
||||
import { getStateInfo } from "@/lib/getStateInfo";
|
||||
import { fetchReq } from "@/lib/req";
|
||||
import { removeToken } from "@/utils";
|
||||
import { cookies, headers } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
@@ -13,22 +14,20 @@ export default async function Dashboard({ searchParams }) {
|
||||
const cookieStore = cookies();
|
||||
const token = cookieStore.get("access_token");
|
||||
const userInfo = cookieStore.get("userInfo");
|
||||
console.log(userInfo.value.uuid);
|
||||
|
||||
if (!ability.can("access", "Dashboard")) {
|
||||
return redirect("/");
|
||||
removeToken();
|
||||
return redirect("/login");
|
||||
}
|
||||
|
||||
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: {
|
||||
Authorization: `Bearer ${token.value}`,
|
||||
},
|
||||
}
|
||||
)
|
||||
.then((res) => console.log(res))
|
||||
.catch((err) => console.log(err));
|
||||
);
|
||||
|
||||
const userAgent = headers().get("user-agent") || "";
|
||||
const isMobile = /Mobi|Android/i.test(userAgent);
|
||||
@@ -40,6 +39,7 @@ export default async function Dashboard({ searchParams }) {
|
||||
params={searchParams}
|
||||
matchedCity={matchedCity}
|
||||
initialTurnsDetails={isMobile}
|
||||
userInfo={JSON.parse(userInfo.value || {})}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user