Skip to content

Commit

Permalink
Merge pull request #83 from dnd-side-project/fix/production-qa
Browse files Browse the repository at this point in the history
프로덕션에 문제있던 부분들 수정
  • Loading branch information
froggy1014 authored Oct 21, 2024
2 parents 6c28320 + 22b98b8 commit f3d1dbf
Show file tree
Hide file tree
Showing 41 changed files with 304 additions and 248 deletions.
1 change: 0 additions & 1 deletion auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ export const { handlers, auth, signIn, signOut, unstable_update } = NextAuth({
},

async session({ session, token }) {
console.log("🚀 ~ session ~ token:", token);
if (token?.accessToken) {
session.user = {
...session.user,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { TopKeywordParameter } from "./topKeywordFestivalType";
export const topKeywordFestivalKeys = {
all: ["searchFestival"] as const,
list: (params: TopKeywordParameter) =>
[topKeywordFestivalKeys.all, params] as const,
[...topKeywordFestivalKeys.all, params] as const,
};
4 changes: 0 additions & 4 deletions src/apis/onboarding/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const getMoods = async () => {
cache: "force-cache",
next: {
tags: festivalOnBoarding.all,
revalidate: false,
},
})
.json<FiestaResponse<Array<FestivalMood>>>()
Expand All @@ -37,7 +36,6 @@ export const getCategories = async () => {
cache: "force-cache",
next: {
tags: festivalOnBoarding.all,
revalidate: false,
},
})
.json<FiestaResponse<Array<FestivalCategory>>>()
Expand All @@ -52,7 +50,6 @@ export const getCompanions = async () => {
cache: "force-cache",
next: {
tags: festivalOnBoarding.all,
revalidate: false,
},
})
.json<FiestaResponse<Array<FestivalCompanion>>>()
Expand All @@ -67,7 +64,6 @@ export const getPriority = async () => {
cache: "force-cache",
next: {
tags: festivalOnBoarding.all,
revalidate: false,
},
})
.json<FiestaResponse<Array<FestivalPriority>>>()
Expand Down
4 changes: 2 additions & 2 deletions src/apis/review/reviewKeywords/reviewKeywords.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import FiestaInstance from "@/apis/FiestaInstance";
import { FIESTA_ENDPOINTS } from "@/config";

import { ReviewKeyword } from "./reviewKeywordsType";
import { Keyword } from "../reviews/reviewsType";

const ENDPOINT = FIESTA_ENDPOINTS.reviews;

export async function getReviewKeywords() {
const endpoint = ENDPOINT.keywords;
const data = await FiestaInstance.get<Array<ReviewKeyword>>(endpoint, {
const data = await FiestaInstance.get<Array<Keyword>>(endpoint, {
cache: "force-cache",
next: {
tags: ["/reviews/keywords"],
Expand Down
5 changes: 5 additions & 0 deletions src/apis/review/reviewKeywords/reviewKeywordsKeys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const reviewKeywordsKeys = {
all: ["reviews"] as const,
detail: (reviewId: string | number) =>
[...reviewKeywordsKeys.all, reviewId] as const,
};
4 changes: 0 additions & 4 deletions src/apis/review/reviewKeywords/reviewKeywordsType.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/apis/review/reviews/reviewsType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export interface Review {

export interface User {
userId: number;
profileImage: string;
nickname: string;
profileImage: string | null;
nickname: string | null;
}

export interface Image {
Expand Down
2 changes: 1 addition & 1 deletion src/apis/user/badges/badgesType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export type Badge = {
badgeName: string;
description: string;
imageUrl: string;
isAquired: boolean;
isAcquired: boolean;
};

export type BadgesResponse = Array<Badge>;
2 changes: 0 additions & 2 deletions src/apis/user/me/me.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use server";

import FiestaInstance from "@/apis/FiestaInstance";
import { FiestaFetchOptions } from "@/apis/instance";
import { FIESTA_ENDPOINTS } from "@/config";
Expand Down
3 changes: 3 additions & 0 deletions src/apis/user/me/meKeys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const meKeys = {
all: ["user"] as const,
};
2 changes: 0 additions & 2 deletions src/apis/user/onboarding-info/onboarding-info.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use server";

import FiestaInstance from "@/apis/FiestaInstance";
import { FIESTA_ENDPOINTS } from "@/config";

Expand Down
7 changes: 7 additions & 0 deletions src/apis/user/onboarding-info/onboarding-infoKeys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const onboardingInfoKeys = {
all: ["onboardingInfo"] as const,
individual: (userId: string | number | undefined) => [
...onboardingInfoKeys.all,
userId,
],
};
2 changes: 0 additions & 2 deletions src/apis/user/profile/patchProfile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use server";

import FiestaInstance from "@/apis/FiestaInstance";
import { FIESTA_ENDPOINTS } from "@/config";

Expand Down
4 changes: 2 additions & 2 deletions src/app/(route)/(home)/_components/FestivalHot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const FestivalHot = async () => {
</Link>
</div>

<div className="flex w-full gap-[16px]">
{hotFestivals.content.splice(0, 2).map((festival) => (
<div className=" grid w-full grid-cols-2 gap-[16px]">
{hotFestivals.content.splice(0, 4).map((festival) => (
<TrendFestivalCard
key={festival.festivalId}
href={`/festivals/${festival.festivalId}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ const RecommendFestivalHeader: FC<Props> = ({ session }) => {
return (
<div className="relative flex w-full justify-between">
<div className="flex w-1/2 flex-wrap pb-[18px] text-title-bold">
<span className={UserTypeText[user?.userTypeId ?? 1]}>
{user?.nickname ?? "피에스타"}
<span>
<span className={UserTypeText[user?.userTypeId ?? 1]}>
{user?.nickname ?? "피에스타"}
</span>
들을 위한 페스티벌이에요!
</span>
<span>들을</span>
<span>위한 페스티벌이에요!</span>
</div>
<Image
className="absolute bottom-[-15px] right-[20px]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const TotalReviews: FC<Props> = ({ festivals }) => {
const { data } = useSuspenseQuery({
queryKey: reviewsKeys.list(params),
queryFn: () => getReviews(params),
refetchOnMount: true,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ const TotalReviewList: FC<Props> = ({ reviews }) => {
<div className="flex w-full flex-col gap-[4px]">
<div className="flex w-full flex-col">
{reviews.map((review) => (
<TotalReviewListItem key={review?.reviewId} review={review} />
<TotalReviewListItem
key={review?.reviewId ?? review?.createdAt}
review={review}
/>
))}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Image from "next/image";
import { useRouter } from "next/navigation";
import { FC, useMemo, useState } from "react";
import { FC, useState } from "react";

import type { Review } from "@/apis/review/reviews/reviewsType";
import { IconButton } from "@/components/core/Button";
Expand All @@ -12,8 +12,8 @@ import { ProgressCircle } from "@/components/core/Progress";
import { FestivalRequstDialog } from "@/components/Dialog";
import { HeartIcon } from "@/components/icons";
import Ratings from "@/components/rating/Ratings";
import useDeleteReview from "@/hooks/review/useDeleteReview";
import useReportReview from "@/hooks/review/useReportReview";
import useReview from "@/hooks/review/useReview";
import useToggleReviewLike from "@/hooks/review/useToggleReviewLike";
import { formatToYYYYMMDD } from "@/lib/dayjs";
import { useUserStore } from "@/store/user";
Expand All @@ -27,33 +27,33 @@ const TotalReviewListItem: FC<Props> = ({ review }) => {
const router = useRouter();
const [isOpenReportDialog, setIsOpenReportDialog] = useState<boolean>(false);

const { deleteReviewMutate, isDeleting } = useDeleteReview(review);
const { deleteReviewMutate, isLoadingDeleteReview } = useReview();
const { reportReview, isReporting } = useReportReview();
const { mutate: toggleReviewLike } = useToggleReviewLike(review);

const handleReport = async (description: string) => {
reportReview({ reviewId: review.reviewId, description });
reportReview({ reviewId: review?.reviewId, description });
};

const handleDelete = (reviewId: number) => {
deleteReviewMutate(reviewId);
deleteReviewMutate(String(reviewId));
};

const handleToggle = () => {
toggleReviewLike({ reviewId: review.reviewId });
toggleReviewLike({ reviewId: review?.reviewId });
};

const myReviewOptions = [
{
label: "수정하기",
onClick: () =>
router.push(
`/festivals/${review.festivalId}/review/${review.reviewId}`,
`/festivals/${review?.festivalId}/review/${review?.reviewId}`,
),
},
{
label: "삭제하기",
onClick: () => handleDelete(review.reviewId),
onClick: () => handleDelete(review?.reviewId),
},
];

Expand All @@ -64,45 +64,46 @@ const TotalReviewListItem: FC<Props> = ({ review }) => {
},
];

const isMyReviewOptions = useMemo(() => {
return user?.userId === review.user.userId
? myReviewOptions
: othersReviewOptions;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [user?.userId, review.user.userId]);

return (
<div
key={review.reviewId}
key={review?.reviewId}
className="flex flex-col gap-[8px] border-b-[1px] border-gray-scale-100 py-[20px]"
>
<div className="flex w-full items-start justify-between">
<div className="flex w-full gap-[4px] ">
<Image
className="rounded-full"
src={review.user.profileImage ?? "/images/fallbackLogo.png"}
alt={review.user.nickname ?? `${review.reviewId}-image`}
src={review?.user?.profileImage ?? "/images/fallbackLogo.png"}
alt={`${review?.reviewId}-image`}
width={33}
height={33}
/>
<div className="flex flex-col">
<div className="flex items-center gap-[4px]">
<span className="text-body2-semi text-gray-scale-700">
{review.user.nickname}
{review?.user?.nickname ?? "익명"}
</span>
<span className="text-caption1-regular text-gray-scale-400">
{formatToYYYYMMDD(review.createdAt)}
{formatToYYYYMMDD(review?.createdAt)}
</span>
</div>
<Ratings rating={review.rating} />
<Ratings rating={review?.rating} />
</div>
</div>

{!!user && <DropdownMenu options={isMyReviewOptions} />}
{!!user && (
<DropdownMenu
options={
user?.userId === review?.user.userId
? myReviewOptions
: othersReviewOptions
}
/>
)}
</div>
{!!review.images.length && (
{!!review?.images.length && (
<div className="flex w-full gap-[8px]">
{review.images.map((image) => (
{review?.images.map((image) => (
<Image
className="aspect-square"
key={image.imageId}
Expand All @@ -115,21 +116,23 @@ const TotalReviewListItem: FC<Props> = ({ review }) => {
</div>
)}
<p className="text-body1-regular-lh-20 text-gray-scale-700">
{review.content}
{review?.content}
</p>
<div className="flex w-full items-center justify-between">
<div className="flex w-full items-center justify-between gap-1">
<div className="flex gap-[8px] overflow-auto scrollbar-hide">
{review.keywords.slice(0, 2).map((keyword) => (
<BasicChip key={keyword.keywordId} label={keyword.keyword} />
))}
{review?.keywords
.slice(0, 2)
.map((keyword) => (
<BasicChip key={keyword.keywordId} label={keyword.keyword} />
))}
</div>
{!!user && review.user.userId != user?.userId && (
<div className="flex w-[30px] items-center justify-between gap-1">
<IconButton active={review.isLiked} onClick={handleToggle}>
{!!user && review?.user.userId != user?.userId && (
<div className="flex w-[30px] items-center justify-between gap-2">
<IconButton active={review?.isLiked} onClick={handleToggle}>
<HeartIcon width={20} height={20} className="gap-2" />
</IconButton>
<span className="text-caption2-regular text-gray-scale-600">
{review.likeCount}
{review?.likeCount}
</span>
</div>
)}
Expand All @@ -142,7 +145,7 @@ const TotalReviewListItem: FC<Props> = ({ review }) => {
onOpenChange={() => setIsOpenReportDialog((prev) => !prev)}
/>

{(isDeleting || isReporting) && (
{(isLoadingDeleteReview || isReporting) && (
<div className="flex h-[400px] w-full items-center justify-center">
<ProgressCircle className="size-[100px]" />
</div>
Expand Down
1 change: 1 addition & 0 deletions src/app/(route)/festivals/[festivalId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default async function Home({
}: {
params: SearchParams & { festivalId?: string };
}) {
console.log("🚀 ~ festivalId:", params.festivalId);
if (!params.festivalId) {
redirect("/");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Metadata } from "next/types";

import { getReviewKeywords } from "@/apis/review/reviewKeywords/reviewKeywords";

import ReviewEditView from "./view";

export const metadata: Metadata = {
Expand All @@ -13,12 +11,9 @@ export default async function ReviewEditPage({
}: {
params: { festivalId: string; reviewId: string };
}) {
const keywords = await getReviewKeywords();

return (
<section className="mt-[44px]">
<ReviewEditView
keywords={keywords}
festivalId={params.festivalId}
reviewId={params.reviewId}
/>
Expand Down
Loading

0 comments on commit f3d1dbf

Please sign in to comment.