Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ient into fix/#310/mainpage
  • Loading branch information
JeongWuk committed Dec 4, 2023
2 parents f387047 + f547554 commit 9233435
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/components/_common/AppBar/AuthAppBar.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
import Image from "next/image";
import Link from "next/link";
import { useToast } from "@/components/ui/use-toast";
import Logo from "@/images/logo.svg";
import { cn } from "@/lib/utils";
import { useSuspenseQuery } from "@tanstack/react-query";
import useAuthStore from "@/stores/isAuth";
import { useQuery } from "@tanstack/react-query";
import getMyProfile from "@/services/user/getMyProfile";
import { MyProfileKey } from "@/constants/queryKeys";
import { appBarTextStyles } from ".";
import Dropdown from "../Dropdown";
import NotificationPopup from "../NotificationPopup";

const AuthAppBar = () => {
const { data: myProfileData } = useSuspenseQuery({
const { isAuth, setIsAuth } = useAuthStore();
const { toast } = useToast();
const { data: myProfileData, error: myProfileDataError } = useQuery({
queryKey: MyProfileKey,
queryFn: () => getMyProfile(),
enabled: isAuth,
});

if (myProfileDataError) {
if (myProfileDataError.response?.data.code === "A002") {
toast({
description: "로그인 정보가 존재하지 않습니다. 다시 로그인해주세요.",
variant: "red",
});
setIsAuth(false);
}
}

return (
<div className="flex w-150 items-center justify-between sm:w-170 md:w-250">
<Link href={"/mysteady"}>
Expand All @@ -29,7 +45,7 @@ const AuthAppBar = () => {
<div className="flex h-30 w-30 items-center justify-center md:h-45 md:w-45">
<Image
className="aspect-square rounded-full border-1"
src={myProfileData.profileImage}
src={myProfileData?.profileImage ?? Logo}
alt="유저 로고"
width={45}
height={45}
Expand Down

0 comments on commit 9233435

Please sign in to comment.