handle update data in tab dashboard

This commit is contained in:
Ehsan
2025-06-10 14:27:06 +03:30
parent f52eb43326
commit 72ed07071c
13 changed files with 181 additions and 61 deletions
+3 -1
View File
@@ -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
+6 -6
View File
@@ -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 || {})}
/>
);
}