Skip to content

Commit

Permalink
add: logout 만들기
Browse files Browse the repository at this point in the history
add: logout 구현
  • Loading branch information
heedda authored May 1, 2024
2 parents 07debd4 + 8058c42 commit f37884f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Link from "next/link";
import React, { useEffect, useState } from "react";
import pick from "@/assets/svg/PiCKLogo.svg";
import { useRouter } from "next/navigation";
import { cookie } from "@/util/auth";

const Header: NextPage = ({}) => {
const [teacherName, setTeacherName] = useState<string | null>(null);
Expand All @@ -21,12 +22,26 @@ const Header: NextPage = ({}) => {
router.push(`/outList`);
}

const logout = () => {
const temp = confirm("로그아웃 하시겠습니까?");
if (temp) {
cookie.remove("refresh_token");
cookie.remove("access_token");
router.push("login");
}
};

return (
<div className="flex justify-between items-center py-1 bg-primary-1200 px-6 pt-3">
<Link href={"/main"}>
<Image src={pick} alt="" width={48} />
</Link>
<div className="flex text-nowrap text-sub-title4-M text-neutral-50">
<div
className="flex text-nowrap text-sub-title4-M text-neutral-50 cursor-pointer"
onClick={() => {
logout();
}}
>
{teacherName ? `${teacherName}선생님` : "선생님"}
</div>
</div>
Expand Down

0 comments on commit f37884f

Please sign in to comment.