Skip to content

Commit

Permalink
perf: guest-login
Browse files Browse the repository at this point in the history
  • Loading branch information
SeungJL committed Aug 12, 2024
1 parent 7506efa commit 01ba4ef
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
5 changes: 5 additions & 0 deletions components/molecules/ContentHeartBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ function ContentHeartBar({ feedId, likeUsers, likeCnt, comments, refetch }: Cont
};

const handleDrawerBtn = (type: "comment" | "like") => {
if (isGuest) {
typeToast("guest");
return;
}

if (type === "comment") {
setModalType("comment");
}
Expand Down
16 changes: 15 additions & 1 deletion pageTemplates/square/SecretSquare/SquareItem.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Box, Flex, Image, Text } from "@chakra-ui/react";
import dayjs from "dayjs";
import Link from "next/link";
import { useSession } from "next-auth/react";
import styled from "styled-components";

import { useTypeToast } from "../../../hooks/custom/CustomToast";
import type { SecretSquareCategory, SecretSquareType } from "../../../types/models/square";
import { getDateDiff } from "../../../utils/dateTimeUtils";

Expand All @@ -22,9 +24,21 @@ interface SquareItemProps {
}

export default function SquareItem({ item }: SquareItemProps) {
const { data: session } = useSession();
const typeToast = useTypeToast();
const isGuest = session?.user.name === "guest";
console.log(item);

const onClick = (e) => {
if (isGuest) {
e.preventDefault();
typeToast("guest");
return;
}
};

return (
<Layout href={`/square/secret/${item._id}`}>
<Layout href={`/square/secret/${item._id}`} onClick={onClick}>
<IconCategory category={item.category} />
<Text
fontSize="16px"
Expand Down
5 changes: 4 additions & 1 deletion pages/square/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useRouter, useSearchParams } from "next/navigation";
import { useSession } from "next-auth/react";
import { useEffect, useState } from "react";

import RuleIcon from "../../components/atoms/Icons/RuleIcon";
Expand All @@ -11,9 +12,11 @@ import SquareSecretSection from "../../pageTemplates/square/SquareSecretSection"
import SquareTabNav, { SquareTab } from "../../pageTemplates/square/SquareTabNav";

function SquarePage() {
const { data: session } = useSession();
const router = useRouter();
const searchParams = useSearchParams();
const tabParam = searchParams.get("tab") as "secret" | "lounge";
const isGuest = session?.user.name === "guest";

const [tab, setTab] = useState<SquareTab>("시크릿 스퀘어");
const [isRuleModal, setIsRuleModal] = useState(false);
Expand All @@ -36,7 +39,7 @@ function SquarePage() {
<SquareTabNav tab={tab} />
{tab === "시크릿 스퀘어" ? <SquareSecretSection /> : <SquareLoungeSection />}
</Slide>
{tab === "시크릿 스퀘어" && <WritingIcon url="/square/secret/writing" />}
{tab === "시크릿 스퀘어" && !isGuest && <WritingIcon url="/square/secret/writing" />}
{isRuleModal && (
<RuleModal
content={tab === "시크릿 스퀘어" ? SECRET_CONTENT : LOUNGE_CONTENT}
Expand Down
1 change: 0 additions & 1 deletion pages/square/secret/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import SecretSquareComments from "../../../pageTemplates/square/SecretSquare/Sec
function SecretSquareDetailPage() {
const router = useRouter();
const squareId = router.query.id as string;

const { data: session } = useSession();
const { mutate: putLikeMutate, isLoading: isPutLikeLoading } = usePutLikeSecretSquareMutation({
squareId,
Expand Down

0 comments on commit 01ba4ef

Please sign in to comment.