Skip to content

Commit

Permalink
fix: guest login error
Browse files Browse the repository at this point in the history
  • Loading branch information
SeungJL committed Sep 25, 2024
1 parent 75ab1ee commit f6b8c1c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
8 changes: 5 additions & 3 deletions pageTemplates/group/GroupBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dayjs from "dayjs";
import Link from "next/link";
import { useSession } from "next-auth/react";
import { MouseEvent } from "react";
import { useSetRecoilState } from "recoil";
import styled from "styled-components";

Expand Down Expand Up @@ -43,8 +44,9 @@ function GroupBlock({ group }: IGroupBlock) {
개설: dayjsToFormat(dayjs(group.createdAt), "YY년 M월 D일"),
};

const onClick = () => {
const onClick = (e: MouseEvent<HTMLAnchorElement, globalThis.MouseEvent>) => {
if (isGuest) {
e.preventDefault();
failToast("guest");
return;
}
Expand Down Expand Up @@ -90,8 +92,8 @@ function GroupBlock({ group }: IGroupBlock) {
};

return (
<Link href={`/group/${group.id}`}>
<Layout onClick={onClick}>
<Link href={`/group/${group.id}`} onClick={(e) => onClick(e)}>
<Layout>
<Header>
<div>
<span>{group.category.main}</span>·<span>{group.category.sub}</span>
Expand Down
10 changes: 5 additions & 5 deletions pageTemplates/user/userProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ function UserProfile() {
return (
<>
<Info>
<Link href="/user/friend" passHref>
<BlockItem onClick={handleClick}>
<Link href="/user/friend" passHref onClick={handleClick}>
<BlockItem>
<span>
내 친구{" "}
<b style={{ display: "inline-block", width: "20px", textAlign: "center" }}>
Expand All @@ -36,8 +36,8 @@ function UserProfile() {
<i className="fa-solid fa-chevron-right" />
</BlockItem>
</Link>
<Link href="/user/like" passHref>
<BlockItem onClick={handleClick}>
<Link href="/user/like" passHref onClick={handleClick}>
<BlockItem>
<span>
받은 좋아요{" "}
<b style={{ display: "inline-block", width: "20px", textAlign: "center" }}>
Expand All @@ -58,7 +58,7 @@ const Info = styled.div`
flex-direction: column;
`;

const BlockItem = styled.a`
const BlockItem = styled.div`
width: 100%;
display: flex;
align-items: center;
Expand Down
5 changes: 3 additions & 2 deletions pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ export const authOptions: NextAuthOptions = {
if (account && account.provider === "guest") {
token = {
...token,
id: "0",
uid: "0",
id: "66f29811e0f0564ae35c52a4",
uid: "1234567890",
name: "guest",
role: "guest",
location: "수원",
isActive: false,
profileImage: "",
};
Expand Down
5 changes: 3 additions & 2 deletions pages/group/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ function GroupPage() {
}, [category.sub, groups]);

useEffect(() => {
if (!isGuest && groupStudies.length && !myGroups) {
if (isGuest) setMyGroups([]);
else if (groupStudies.length && !myGroups) {
setMyGroups(
groupStudies.filter((item) =>
item.participants.some((who) => {
Expand Down Expand Up @@ -150,7 +151,7 @@ function GroupPage() {
function StatusSelector() {
return <Selector defaultValue={status} setValue={setStatus} options={["모집중", "종료"]} />;
}

console.log(24, myGroups);
return (
<>
<Header title="소모임" url="/home" isBack={false} />
Expand Down

0 comments on commit f6b8c1c

Please sign in to comment.