fix(dashboard): guard null userInfo in Head to stop 500 crash

getParsedUserInfo() can return null (cookie missing/unparseable), so
reading userInfo.realName crashed the dashboard with a 500. Default to
an empty object and fall back to the user prop's name or 'کاربر'.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-06-15 19:15:25 +03:30
co-authored by Claude Opus 4.8
parent fbb2279b49
commit 96b1684b82
2 changed files with 138 additions and 2 deletions
+3 -2
View File
@@ -4,14 +4,15 @@ import { getParsedUserInfo } from "@/helper";
import Image from "next/image";
function Head({ user }) {
const userInfo = getParsedUserInfo();
const userInfo = getParsedUserInfo() || {};
const displayName = userInfo.realName || user?.name || "کاربر";
return (
<div className="hidden md:flex flex-col lg:flex-row w-full items-stretch justify-center gap-[12px] lg:gap-[24px]">
<div className="bg-head-dashboard rounded-[8px] relative w-full !bg-no-repeat !bg-cover py-[20px] px-[24px] !bg-center flex items-center">
<div className="flex w-full pl-[calc(5%+140px)] lg:pl-[calc(9%+171px)] flex-col justify-start items-start gap-[8px]">
<p className="text-[#3B3B3B] text-[16px] font-bold">
{userInfo.realName}{" "}
{displayName}{" "}
<span className="text-[#3B3B3B] text-[16px] font-normal">
عزیز!
</span>