Skip to content

Commit

Permalink
Merge pull request #69 from dnd-side-project/feature/65-route-manage
Browse files Browse the repository at this point in the history
라우트 정리 및 린트 경고 제거
  • Loading branch information
froggy1014 authored Oct 13, 2024
2 parents 44e2511 + ea25445 commit 9ec3fba
Show file tree
Hide file tree
Showing 113 changed files with 180 additions and 158 deletions.
40 changes: 22 additions & 18 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,7 @@
"plugin:@tanstack/eslint-plugin-query/recommended"
],
"rules": {
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"@typescript-eslint/no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_" }
],
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn",
{
"vars": "all",
"varsIgnorePattern": "^_",
"args": "after-used",
"argsIgnorePattern": "^_"
}
],
"react-hooks/rules-of-hooks": "off",
"react-hooks/exhaustive-deps": "off",
"eol-last": ["error", "always"],
Expand Down Expand Up @@ -53,11 +39,29 @@
"rules": {
"simple-import-sort/imports": "warn",
"simple-import-sort/exports": "warn",
"no-unused-vars": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"tailwindcss/no-custom-classname": "warn",
"tailwindcss/no-custom-classname": [
"warn",
{
"whitelist": ["pagination_fraction"]
}
],
"tailwindcss/no-unnecessary-arbitrary-value": "off",
"tailwindcss/enforces-shorthand": "off"
"tailwindcss/enforces-shorthand": "off",

// ? https://velog.io/@sumi-0011/eslint%EC%9D%98-no-unused-vars-%EA%B7%9C%EC%B9%99%EA%B3%BC-typescript%EC%9D%98-interface-%EB%AC%B8%EB%B2%95-%EC%B6%A9%EB%8F%8C-%ED%95%B4%EA%B2%B0%EB%B0%A9%EB%B2%95
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"args": "all",
"argsIgnorePattern": "^_",
"caughtErrors": "all",
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"ignoreRestSiblings": true
}
]
}
}
],
Expand Down
54 changes: 33 additions & 21 deletions auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { SocialLoginRequest } from "@/apis/auth/authType";
import { getMe } from "@/apis/user/me/me";
import { env } from "@/env";
import { decodeToken } from "@/lib/jwt";
import type { UserMeResponse } from "@/apis/user/me/meType";

export const { handlers, auth, signIn, signOut, unstable_update } = NextAuth({
providers: [
Expand All @@ -26,6 +27,7 @@ export const { handlers, auth, signIn, signOut, unstable_update } = NextAuth({
async signIn() {
return true;
},

redirect: async ({ url, baseUrl }) => {
if (url.startsWith("/")) return `${baseUrl}${url}`;
if (url) {
Expand All @@ -40,27 +42,6 @@ export const { handlers, auth, signIn, signOut, unstable_update } = NextAuth({
return baseUrl;
},
async jwt({ token, session, user, trigger, account }) {
if (!!token.accessToken) {
const decodedJWT = decodeToken(token.accessToken);

if (
!!token.refreshToken &&
!!decodedJWT?.exp &&
decodedJWT?.exp * 1000 < Date.now()
) {
console.log("토큰 재발급");
const { accessToken, refreshToken } = await getRefreshToken(
token.refreshToken,
);

const decodedJWT = decodeToken(accessToken);

token.accessToken = accessToken;
token.refreshToken = refreshToken;
token.exp = decodedJWT?.exp;
}
}

if (trigger === "update") {
token.user = {
...session.user,
Expand Down Expand Up @@ -93,6 +74,28 @@ export const { handlers, auth, signIn, signOut, unstable_update } = NextAuth({
}
}

if (!token.accessToken) {
return null;
}

const decodedJWT = decodeToken(token.accessToken);
if (
!!token.refreshToken &&
!!decodedJWT?.exp &&
decodedJWT?.exp * 1000 < Date.now()
) {
console.log("토큰 재발급");
const { accessToken, refreshToken } = await getRefreshToken(
token.refreshToken,
);

const decodedJWT = decodeToken(accessToken);

token.accessToken = accessToken;
token.refreshToken = refreshToken;
token.exp = decodedJWT?.exp;
}

return token;
},

Expand Down Expand Up @@ -145,6 +148,15 @@ declare module "next-auth" {
iat?: number;
sub?: string;
}

interface User {
userId: number;
nickname: string;
statusMessage: string;
profileImage: string;
isProfileRegistered: boolean;
userTypeId: number;
}
}
declare module "next-auth/jwt" {
interface JWT {
Expand Down
2 changes: 2 additions & 0 deletions src/apis/user/me/me.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import instance, { FiestaFetchOptions } from "@/apis/instance";
import { FIESTA_ENDPOINTS } from "@/config";
import { ProfileMeUpdateSchemaType } from "@/validations/ProfileUpdateMeSchema";

import { UserMeResponse } from "./meType";

export const getMe = async (options?: FiestaFetchOptions) => {
const endpoint = FIESTA_ENDPOINTS.users.me;
const { data } = await instance.get<UserMeResponse>(endpoint, {
Expand Down
2 changes: 1 addition & 1 deletion src/apis/user/me/meType.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type UserMeResponse = {
export type UserMeResponse = {
userId: number;
email: string;
nickname: string;
Expand Down
26 changes: 0 additions & 26 deletions src/app/(home)/page.tsx

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
53 changes: 53 additions & 0 deletions src/app/(route)/(home)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Metadata } from "next";

import { FloatingButton } from "@/components/core/Button";
import { HomeHeader } from "@/layout/Mobile/MobileHeader";
import NavigationBar from "@/layout/Mobile/NavigationBar";

import {
FestivalHot,
FestivalRecommend,
FestivalThisWeek,
TopReviews,
} from "./_components";

export const metadata: Metadata = {
title: {
default: "피에스타",
template: "%s - 피에스타",
},
description:
"한국의 공식 및 비공식 축제 모두를 한곳에서! 날짜, 장소, 프로그램 등 다양한 국내 축제 정보를 확인하고, 대학 축제와 같은 특별한 행사도 피에스타에서 만나보세요.",
openGraph: {
siteName: "피에스타",
title: "피에스타",
type: "website",
description:
"한국의 공식 및 비공식 축제 모두를 한곳에서! 날짜, 장소, 프로그램 등 다양한 국내 축제 정보를 확인하고, 대학 축제와 같은 특별한 행사도 피에스타에서 만나보세요.",
images: [
{
url: "/opengraph-image.png",
alt: "Fiesta OG Image",
width: 1200,
height: 630,
},
],
url: "https://www.odiga.kr",
},
};

export default async function Home() {
return (
<div className="mb-[60px] mt-[44px]">
<HomeHeader />
<FestivalRecommend />
<main className="flex flex-col gap-[40px] rounded-t-[20px] bg-gray-scale-100 px-[16px] pb-[36px] pt-[16px]">
<FestivalHot />
<FestivalThisWeek />
<TopReviews />
</main>
<FloatingButton />
<NavigationBar />
</div>
);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const SignIn = () => {
</h1>
<Image
priority
className="absolute -right-[20px] bottom-0"
className="absolute bottom-0 right-[-20px]"
width={140}
height={117}
src="/images/romantist.png"
Expand All @@ -45,15 +45,15 @@ const SignIn = () => {
/>
<Image
priority
className="absolute -left-[50px] bottom-0 rotate-12"
className="absolute bottom-0 left-[-50px] rotate-12"
width={176}
height={163}
src="/images/inspirer.png"
alt="inspirer"
/>
<Image
priority
className="absolute -left-[50px] top-[70px] rotate-[24deg]"
className="absolute left-[-50px] top-[70px] rotate-[24deg]"
width={153}
height={150}
src="/images/healer.png"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { postReviewReport } from "@/apis/review/reviewReport/reviewReport";
import { reviewsKeys } from "@/apis/review/reviews/reviewKeys";
import { Review } from "@/apis/review/reviews/reviewsType";
import { BasicChip } from "@/components/core/Chip";
import { DropdownMenu, DropdownOption } from "@/components/core/Dropdown";
import { DropdownMenu } from "@/components/core/Dropdown";
import { ProgressCircle } from "@/components/core/Progress";
import { FestivalRequstDialog } from "@/components/Dialog";
import Ratings from "@/components/rating/Ratings";
Expand All @@ -32,7 +32,7 @@ const TotalReviewListItem: FC<Props> = ({ review }) => {

const { mutate: deleteReviewMutate, isPending: isDeleting } = useMutation({
mutationFn: async (reviewId: number) => await deleteReview(reviewId),
onSuccess: (data) => {
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: reviewsKeys.all,
}),
Expand All @@ -52,8 +52,7 @@ const TotalReviewListItem: FC<Props> = ({ review }) => {
const handleDelete = (reviewId: number) => {
deleteReviewMutate(reviewId);
};

const myReviewOptions: Array<DropdownOption> = [
const myReviewOptions = [
{
label: "수정하기",
onClick: () =>
Expand All @@ -67,7 +66,7 @@ const TotalReviewListItem: FC<Props> = ({ review }) => {
},
];

const othersReviewOptions: Array<DropdownOption> = [
const othersReviewOptions = [
{
label: "신고하기",
onClick: () => setIsOpenReportDialog(true),
Expand All @@ -78,7 +77,8 @@ const TotalReviewListItem: FC<Props> = ({ review }) => {
return user?.userId === review.user.userId
? myReviewOptions
: othersReviewOptions;
}, [review]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [user?.userId, review.user.userId]);

return (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ const DetailFestivalTab: FC<Props> = ({ festivals, session }) => {
};

return (
<Tabs.Root className="TabsRoot " defaultValue={TabList[0].name}>
<Tabs.Root id="TabsRoot " defaultValue={TabList[0].name}>
<Tabs.List
id={"tab"}
className="flex h-[47px] w-full"
aria-label="Manage your account"
>
{TabList.map(({ name }, index) => (
{TabList.map(({ name }) => (
<Tabs.Trigger
key={name}
className="TabsTrigger w-full border-b-[1px] border-gray-scale-400 text-subtitle-semi text-gray-scale-400"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ const ReviewEditView: FC<Props> = ({ keywords, reviewId, festivalId }) => {
const queryClient = useQueryClient();
const router = useRouter();

const { data: review, isLoading } = useQuery({
const { data: review } = useQuery({
queryKey: reviewsKeys.detail(reviewId),
queryFn: () => getReview(reviewId),
});

const { mutate: updateReviewMutate } = useMutation({
mutationFn: (payload: UpdateReviewSchemaType) => updateReview(payload),
onSuccess: (data) => {
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: reviewsKeys.all });
queryClient.invalidateQueries({
queryKey: topKeywordFestivalKeys.list({ festivalId }),
Expand All @@ -70,16 +70,16 @@ const ReviewEditView: FC<Props> = ({ keywords, reviewId, festivalId }) => {
formState: { isSubmitting },
} = methods;

const handleReviewImagesToFile = async (review: Review) => {
const files = await reviewEntityToFiles(review.images);
setValue("images", files);
};

useEffect(() => {
const handleReviewImagesToFile = async (review: Review) => {
const files = await reviewEntityToFiles(review.images);
setValue("images", files);
};

if (review) {
handleReviewImagesToFile(review);
}
}, [review]);
}, [review, setValue]);

const onSubmit = async (data: UpdateReviewSchemaType) => {
try {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const CreateFestivalFirstStep = () => {
<Controller
control={control}
name="images"
render={({ field: { onChange, value }, formState: { errors } }) => (
render={({ field: { onChange, value } }) => (
<ImageUploader
label="대표 이미지"
value={value}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const MypageBookmarkSkeleton = () => {
{Array.from({ length: 6 }).map((_, idx) => (
<div
key={idx}
className="rounded-mg h-[196px] w-[200px] bg-gray-scale-200"
className="h-[196px] w-[200px] rounded-md bg-gray-scale-200"
/>
))}
</div>
Expand Down
Loading

0 comments on commit 9ec3fba

Please sign in to comment.