diff --git a/auth.ts b/auth.ts index 68d76d7..974fac2 100644 --- a/auth.ts +++ b/auth.ts @@ -71,6 +71,7 @@ export const { handlers, auth, signIn, signOut, unstable_update } = NextAuth({ refreshToken, accessToken, }; + return token; } } diff --git a/package.json b/package.json index 5dccd5a..4e7fc00 100644 --- a/package.json +++ b/package.json @@ -31,14 +31,14 @@ "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", "dayjs": "^1.11.12", + "es-toolkit": "^1.24.0", "framer-motion": "^11.3.24", "html-react-parser": "^5.1.16", "jose": "^5.7.0", - "lodash": "^4.17.21", + "ky": "^1.7.2", "next": "14.2.4", "next-auth": "5.0.0-beta.20", "nuqs": "^1.17.8", - "path-to-regexp": "^7.1.0", "react": "^18", "react-daum-postcode": "^3.1.3", "react-dom": "^18", @@ -71,7 +71,6 @@ "@tanstack/eslint-plugin-query": "^5.50.1", "@types/canvas-confetti": "^1.6.4", "@types/kakao-js-sdk": "^1.39.5", - "@types/lodash": "^4.17.7", "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2c7cd9e..9a628de 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -50,6 +50,9 @@ importers: dayjs: specifier: ^1.11.12 version: 1.11.12 + es-toolkit: + specifier: ^1.24.0 + version: 1.24.0 framer-motion: specifier: ^11.3.24 version: 11.3.24(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -59,9 +62,9 @@ importers: jose: specifier: ^5.7.0 version: 5.7.0 - lodash: - specifier: ^4.17.21 - version: 4.17.21 + ky: + specifier: ^1.7.2 + version: 1.7.2 next: specifier: 14.2.4 version: 14.2.4(@babel/core@7.25.2)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -71,9 +74,6 @@ importers: nuqs: specifier: ^1.17.8 version: 1.17.8(next@14.2.4(@babel/core@7.25.2)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)) - path-to-regexp: - specifier: ^7.1.0 - version: 7.1.0 react: specifier: ^18 version: 18.3.1 @@ -165,9 +165,6 @@ importers: '@types/kakao-js-sdk': specifier: ^1.39.5 version: 1.39.5 - '@types/lodash': - specifier: ^4.17.7 - version: 4.17.7 '@types/node': specifier: ^20 version: 20.14.10 @@ -3591,6 +3588,9 @@ packages: resolution: {integrity: sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==} engines: {node: '>= 0.4'} + es-toolkit@1.24.0: + resolution: {integrity: sha512-nZM+MRSGhKjCdjvqWEFr5Jns6vxoXtBcsl4/cEsGMgsMx8Z2ato4vBTGMUSIQBZJgEdKyNcgGh42yu9xiuNYtQ==} + esbuild-register@3.6.0: resolution: {integrity: sha512-H2/S7Pm8a9CL1uhp9OvjwrBh5Pvx0H8qVOxNu8Wed9Y7qv56MPtq+GGM8RJpq6glYJn9Wspr8uw7l55uyinNeg==} peerDependencies: @@ -4604,6 +4604,10 @@ packages: resolution: {integrity: sha512-dhG34DXATL5hSxJbIexCft8FChFXtmskoZYnoPWjXQuebWYCNkVeV3KkGegCK9CP1oswI/vQibS2GY7Em/sJJA==} engines: {node: '>= 8'} + ky@1.7.2: + resolution: {integrity: sha512-OzIvbHKKDpi60TnF9t7UUVAF1B4mcqc02z5PIvrm08Wyb+yOcz63GRvEuVxNT18a9E1SrNouhB4W2NNLeD7Ykg==} + engines: {node: '>=18'} + language-subtag-registry@0.3.23: resolution: {integrity: sha512-0K65Lea881pHotoGEa5gDlMxt3pctLi2RplBb7Ezh4rRdLEOtgi7n4EwK9lamnUCkKBqaeKRVebTq6BAxSkpXQ==} @@ -5206,10 +5210,6 @@ packages: path-to-regexp@6.2.2: resolution: {integrity: sha512-GQX3SSMokngb36+whdpRXE+3f9V8UzyAorlYvOGx87ufGHehNTn5lCxrKtLyZ4Yl/wEKnNnr98ZzOwwDZV5ogw==} - path-to-regexp@7.1.0: - resolution: {integrity: sha512-ZToe+MbUF4lBqk6dV8GKot4DKfzrxXsplOddH8zN3YK+qw9/McvP7+4ICjZvOne0jQhN4eJwHsX6tT0Ns19fvw==} - engines: {node: '>=16'} - path-type@4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} @@ -10512,6 +10512,8 @@ snapshots: is-date-object: 1.0.5 is-symbol: 1.0.4 + es-toolkit@1.24.0: {} + esbuild-register@3.6.0(esbuild@0.21.5): dependencies: debug: 4.3.5 @@ -11727,6 +11729,8 @@ snapshots: klona@2.0.6: {} + ky@1.7.2: {} + language-subtag-registry@0.3.23: {} language-tags@1.0.9: @@ -12310,8 +12314,6 @@ snapshots: path-to-regexp@6.2.2: {} - path-to-regexp@7.1.0: {} - path-type@4.0.0: {} path-type@5.0.0: {} diff --git a/src/apis/FiestaInstance.ts b/src/apis/FiestaInstance.ts new file mode 100644 index 0000000..58c3303 --- /dev/null +++ b/src/apis/FiestaInstance.ts @@ -0,0 +1,66 @@ +import type { KyRequest, NormalizedOptions } from "ky"; +import ky from "ky"; + +import { env } from "@/env"; +import { getClientSideSession } from "@/lib/session"; + +import { getServerSideSession } from "./auth/auth"; +import { FiestaResponse } from "./instance"; + +const addAuthTokenToHeader = async ( + _request: KyRequest, + _options: NormalizedOptions, +) => { + const isServer = typeof window === "undefined"; + + const session = isServer + ? await getServerSideSession() + : await getClientSideSession(); + + if (session) { + _request.headers.set("Authorization", `Bearer ${session.accessToken}`); + } + + return _request; +}; + +const createKyInstance = () => { + return ky.create({ + prefixUrl: env.NEXT_PUBLIC_BASE_URL, + hooks: { + beforeRequest: [addAuthTokenToHeader], + }, + retry: { + limit: 2, + methods: ["get", "post", "put", "patch", "delete"], + statusCodes: [408, 413, 429, 500, 502, 503, 504], + }, + }); +}; + +const Instance = createKyInstance(); + +const FiestaInstance = { + get: (url: string, options?: RequestInit) => + Instance.get(url, options) + .json>() + .then((res) => res.data), + post: (url: string, json?: unknown, options?: RequestInit) => + Instance.post(url, { json, ...options }) + .json>() + .then((res) => res.data), + put: (url: string, json?: unknown, options?: RequestInit) => + Instance.put(url, { json, ...options }) + .json>() + .then((res) => res.data), + patch: (url: string, json?: unknown, options?: RequestInit) => + Instance.patch(url, { json, ...options }) + .json>() + .then((res) => res.data), + delete: (url: string, options?: RequestInit) => + Instance.delete(url, options) + .json>() + .then((res) => res.data), +}; + +export default FiestaInstance; diff --git a/src/apis/auth/auth.ts b/src/apis/auth/auth.ts index 97dc359..316283d 100644 --- a/src/apis/auth/auth.ts +++ b/src/apis/auth/auth.ts @@ -1,23 +1,26 @@ "use server"; -import instance from "@/apis/instance"; import { auth, signIn, signOut } from "@/auth"; import FIESTA_ENDPOINTS from "@/config/apiEndpoints"; +import { env } from "@/env"; +import FiestaInstance from "../FiestaInstance"; import { RefreshTokenResponse, SocialLoginRequest, SocialLoginResponse, } from "./authType"; -import { env } from "@/env"; const ENDPOINT = FIESTA_ENDPOINTS.users; export async function postOauthLogin(body: SocialLoginRequest) { const endpoint = ENDPOINT.login; - const { data } = await instance.post(endpoint, body); + const response = await FiestaInstance.post( + endpoint, + body, + ); - return data; + return response; } export const postSignOut = async () => { diff --git a/src/apis/error.ts b/src/apis/error.ts index 16afd9d..9ff9634 100644 --- a/src/apis/error.ts +++ b/src/apis/error.ts @@ -49,7 +49,7 @@ export class ReviewError extends FiestaError { } } -function isFiestaError(error: unknown): error is FiestaError { +export function isFiestaError(error: unknown): error is FiestaError { return ( typeof error === "object" && error !== null && @@ -61,7 +61,7 @@ function isFiestaError(error: unknown): error is FiestaError { export function createFiestaError(error: unknown) { if (!isFiestaError(error)) { - return new Error(`Unknown Error: ${JSON.stringify(error)}`); + return new LogsError(500, "C000", "UnknownError"); } const { code, message, statusCode } = error; @@ -86,5 +86,5 @@ export function createFiestaError(error: unknown) { return new ReviewError(statusCode, code, message); } - return new Error(`Something went wrong: ${JSON.stringify(error)}`); + return new LogsError(500, "C000", "UnknownError"); } diff --git a/src/apis/festivals/bookmarkCountFestival/bookmarkCountFestival.ts b/src/apis/festivals/bookmarkCountFestival/bookmarkCountFestival.ts index bb76d48..dd7d2e9 100644 --- a/src/apis/festivals/bookmarkCountFestival/bookmarkCountFestival.ts +++ b/src/apis/festivals/bookmarkCountFestival/bookmarkCountFestival.ts @@ -1,7 +1,7 @@ "use server"; import { ClientError } from "@/apis/error"; -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import FIESTA_ENDPOINTS from "@/config/apiEndpoints"; import { DetailFestivalResponse } from "../detailFestival/detailFestivalType"; @@ -11,13 +11,13 @@ const ENDPOINT = FIESTA_ENDPOINTS.festivals; export async function getFestivalBookmark(festivalId: number) { const endpoint = ENDPOINT.detail(String(festivalId)); try { - const response = await instance.get< + const response = await FiestaInstance.get< Pick >(endpoint, { cache: "no-store", }); - const { isBookmarked, bookmarkCount } = response.data; + const { isBookmarked, bookmarkCount } = response; return { isBookmarked, diff --git a/src/apis/festivals/bookmarkFestival/bookmarkFestival.ts b/src/apis/festivals/bookmarkFestival/bookmarkFestival.ts index a38e576..6b98f3f 100644 --- a/src/apis/festivals/bookmarkFestival/bookmarkFestival.ts +++ b/src/apis/festivals/bookmarkFestival/bookmarkFestival.ts @@ -1,9 +1,9 @@ "use server"; -import debounce from "lodash/debounce"; +import { debounce } from "es-toolkit/function"; import { ClientError } from "@/apis/error"; -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import FIESTA_ENDPOINTS from "@/config/apiEndpoints"; import { bookmarkFestivalResponse } from "./bookmarkFestivalType"; @@ -11,16 +11,18 @@ import { bookmarkFestivalResponse } from "./bookmarkFestivalType"; const ENDPOINT = FIESTA_ENDPOINTS.festivals; export const debouncedPatchBookmarkFestival = debounce( - (endpoint: string) => instance.patch(endpoint), + (endpoint: string) => + FiestaInstance.patch(endpoint), 400, ); export async function patchBookmarkFestival(festivalId: number) { const endpoint = ENDPOINT.bookmark(festivalId); try { - const response = await instance.patch(endpoint); + const response = + await FiestaInstance.patch(endpoint); - return response.data; + return response; } catch (error) { if (error instanceof ClientError) { throw new Error("Session required"); diff --git a/src/apis/festivals/createFestival/createFestival.ts b/src/apis/festivals/createFestival/createFestival.ts index ce94f0b..e4db6d4 100644 --- a/src/apis/festivals/createFestival/createFestival.ts +++ b/src/apis/festivals/createFestival/createFestival.ts @@ -1,4 +1,4 @@ -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import FIESTA_ENDPOINTS from "@/config/apiEndpoints"; import { CreateFestivalType } from "@/validations/CreateFestivalSchema"; @@ -19,10 +19,9 @@ export async function createFestival(payload: CreateFestivalType) { formData.append("images", image); }); - const { data } = await instance.post( - ENDPOINT, - formData, - ); + const response = await FiestaInstance.post(ENDPOINT, { + body: formData, + }); - return data; + return response; } diff --git a/src/apis/festivals/detailFestival/detailFestival.ts b/src/apis/festivals/detailFestival/detailFestival.ts index bf95873..9d05191 100644 --- a/src/apis/festivals/detailFestival/detailFestival.ts +++ b/src/apis/festivals/detailFestival/detailFestival.ts @@ -1,7 +1,6 @@ "use server"; -import { ClientError } from "@/apis/error"; -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import FIESTA_ENDPOINTS from "@/config/apiEndpoints"; import { DetailFestivalResponse } from "./detailFestivalType"; @@ -10,20 +9,12 @@ const ENDPOINT = FIESTA_ENDPOINTS.festivals; export async function getDetailFestival(festivalId: string) { const endpoint = ENDPOINT.detail(festivalId); - try { - const response = await instance.get(endpoint, { - // cache: "no-store", - next: { - revalidate: 86400, - tags: [`festivals/${festivalId}`], - }, - }); + const response = await FiestaInstance.get(endpoint, { + next: { + revalidate: 86400, + tags: [`festivals/${festivalId}`], + }, + }); - return response.data; - } catch (error) { - if (error instanceof ClientError) { - throw new Error("Session required"); - } - throw new Error("something went wrong"); - } + return response; } diff --git a/src/apis/festivals/hotFestival/hotFestival.ts b/src/apis/festivals/hotFestival/hotFestival.ts index 60b0ada..4deaaf6 100644 --- a/src/apis/festivals/hotFestival/hotFestival.ts +++ b/src/apis/festivals/hotFestival/hotFestival.ts @@ -1,6 +1,6 @@ "use server"; -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import { REVALIDATE_DURATION } from "@/config"; import FIESTA_ENDPOINTS from "@/config/apiEndpoints"; import { generateUrlWithParams } from "@/utils/generateUrlWithParams"; @@ -9,13 +9,13 @@ import { hotFestivalKeys } from "./hotFestivalkeys"; import { HostFestivalData, PaginationParamter } from "./hotFestivalType"; const defaultParams: PaginationParamter = { page: 0, size: 6 }; -const ENDPOINT = FIESTA_ENDPOINTS.festivals; export async function getHotFestival( params: PaginationParamter = defaultParams, ) { - const endpoint = ENDPOINT.mostlike; - const { data } = await instance.get( + const endpoint = FIESTA_ENDPOINTS.festivals.mostlike; + + const data = await FiestaInstance.get( generateUrlWithParams(endpoint, params), { next: { @@ -24,5 +24,6 @@ export async function getHotFestival( }, }, ); + return data; } diff --git a/src/apis/festivals/recommendFestival/recommendFestival.ts b/src/apis/festivals/recommendFestival/recommendFestival.ts index edbb822..7a68d08 100644 --- a/src/apis/festivals/recommendFestival/recommendFestival.ts +++ b/src/apis/festivals/recommendFestival/recommendFestival.ts @@ -1,5 +1,4 @@ -import { ClientError } from "@/apis/error"; -import instance from "@/apis/instance"; +import kyInstance from "@/apis/FiestaInstance"; import FIESTA_ENDPOINTS from "@/config/apiEndpoints"; import { generateUrlWithParams } from "@/utils/generateUrlWithParams"; @@ -9,25 +8,17 @@ import { } from "./recommendFestivalType"; const defaultParams: PaginationParamter = { page: 0, size: 5 }; -const ENDPOINT = FIESTA_ENDPOINTS.festivals; export async function getRecommendFestival( params: PaginationParamter = defaultParams, ) { - const endpoint = ENDPOINT.recommend; - try { - const response = await instance.get( - generateUrlWithParams(endpoint, params), - { - cache: "no-store", - }, - ); + const endpoint = FIESTA_ENDPOINTS.festivals.recommend; + const response = await kyInstance.get( + generateUrlWithParams(endpoint, params), + { + cache: "no-store", + }, + ); - return response.data; - } catch (error) { - if (error instanceof ClientError) { - throw new Error("Session required"); - } - throw new Error("something went wrong"); - } + return response; } diff --git a/src/apis/festivals/searchFestival/searchFestival.ts b/src/apis/festivals/searchFestival/searchFestival.ts index 7e38900..b2e39d6 100644 --- a/src/apis/festivals/searchFestival/searchFestival.ts +++ b/src/apis/festivals/searchFestival/searchFestival.ts @@ -1,4 +1,4 @@ -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import FIESTA_ENDPOINTS from "@/config/apiEndpoints"; import { generateUrlWithParams } from "@/utils/generateUrlWithParams"; @@ -15,11 +15,12 @@ export async function getSearchFestival( params: SearchFestivalParameter = defaultParams, ): Promise> { const endpoint = ENDPOINT.search; - const { data } = await instance.get( + const response = await FiestaInstance.get( generateUrlWithParams(endpoint, params), { cache: "no-store", }, ); - return data.content; + + return response.content; } diff --git a/src/apis/festivals/thisweek/thisWeekFestival.ts b/src/apis/festivals/thisweek/thisWeekFestival.ts index a474539..f8b0f21 100644 --- a/src/apis/festivals/thisweek/thisWeekFestival.ts +++ b/src/apis/festivals/thisweek/thisWeekFestival.ts @@ -1,6 +1,6 @@ "use server"; -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import FIESTA_ENDPOINTS from "@/config/apiEndpoints"; import { generateUrlWithParams } from "@/utils/generateUrlWithParams"; @@ -11,13 +11,12 @@ import { } from "./thisWeekFestivalType"; const defaultParams: PaginationParamter = { page: 0, size: 6 }; -const ENDPOINT = FIESTA_ENDPOINTS.festivals; export async function getThisWeekFestival( params: PaginationParamter = defaultParams, ) { - const endpoint = ENDPOINT.thisWeek; - const { data } = await instance.get( + const endpoint = FIESTA_ENDPOINTS.festivals.thisWeek; + const response = await FiestaInstance.get( generateUrlWithParams(endpoint, params), { next: { @@ -26,5 +25,6 @@ export async function getThisWeekFestival( }, }, ); - return data; + + return response; } diff --git a/src/apis/festivals/topKeywordFestival/topKeywordFestival.ts b/src/apis/festivals/topKeywordFestival/topKeywordFestival.ts index ad61d65..53aceaa 100644 --- a/src/apis/festivals/topKeywordFestival/topKeywordFestival.ts +++ b/src/apis/festivals/topKeywordFestival/topKeywordFestival.ts @@ -1,6 +1,6 @@ "use client"; -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import FIESTA_ENDPOINTS from "@/config/apiEndpoints"; import { generateUrlWithParams } from "@/utils"; @@ -13,12 +13,12 @@ export async function getFestivalTopKeywords({ size = 5, }: TopKeywordParameter): Promise { const endpoint = ENDPOINT.topKeywords; - const response = await instance.get( + const response = await FiestaInstance.get( generateUrlWithParams(endpoint, { festivalId, size }), { cache: "no-store", }, ); - return response.data; + return response; } diff --git a/src/apis/festivals/trendingFestival/trendingFestival.ts b/src/apis/festivals/trendingFestival/trendingFestival.ts index 42dac37..1f4d600 100644 --- a/src/apis/festivals/trendingFestival/trendingFestival.ts +++ b/src/apis/festivals/trendingFestival/trendingFestival.ts @@ -1,4 +1,4 @@ -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import FIESTA_ENDPOINTS from "@/config/apiEndpoints"; import { PaginationParamter } from "@/model/festivalTypes"; import { generateUrlWithParams } from "@/utils/generateUrlWithParams"; @@ -6,15 +6,15 @@ import { generateUrlWithParams } from "@/utils/generateUrlWithParams"; import { TrendingFestivalResponse } from "./trendingFestivalType"; const defaultParams: PaginationParamter = { page: 0, size: 5 }; -const ENDPOINT = FIESTA_ENDPOINTS.festivals; export async function getTrendingFestival() { - const endpoint = ENDPOINT.trending; - const { data } = await instance.get( + const endpoint = FIESTA_ENDPOINTS.festivals.trending; + const response = await FiestaInstance.get( generateUrlWithParams(endpoint, defaultParams), { cache: "no-store", }, ); - return data.content; + + return response.content; } diff --git a/src/apis/instance.ts b/src/apis/instance.ts index 6b1d7cd..3918a51 100644 --- a/src/apis/instance.ts +++ b/src/apis/instance.ts @@ -2,7 +2,6 @@ import { Session } from "next-auth"; import { getClientSideSession } from "@/lib/session"; -import { env } from "../env"; import { getServerSideSession } from "./auth/auth"; import { ClientError, @@ -164,6 +163,6 @@ export class CreateFiestaFetch { ): Promise> => this.fetch(url, "DELETE", options); } -const instance = new CreateFiestaFetch(env.NEXT_PUBLIC_BASE_URL); +// const instance = new CreateFiestaFetch(env.NEXT_PUBLIC_BASE_URL); -export default instance; +// export default instance; diff --git a/src/apis/onboarding/onboarding.ts b/src/apis/onboarding/onboarding.ts index ed652e6..2ced841 100644 --- a/src/apis/onboarding/onboarding.ts +++ b/src/apis/onboarding/onboarding.ts @@ -2,7 +2,7 @@ import { FIESTA_ENDPOINTS } from "@/config"; import { getSettledValue } from "@/utils"; -import instance from "../instance"; +import FiestaInstance from "../FiestaInstance"; import { festivalOnBoarding } from "./onboardingKeys"; import { FestivalCategory, @@ -14,7 +14,7 @@ import { export const getMoods = async () => { const endpoint = FIESTA_ENDPOINTS.festivals.moods; - const { data } = await instance.get>(endpoint, { + const data = await FiestaInstance.get>(endpoint, { cache: "force-cache", next: { tags: festivalOnBoarding.all, @@ -25,7 +25,7 @@ export const getMoods = async () => { }; export const getCategories = async () => { const endpoint = FIESTA_ENDPOINTS.festivals.categories; - const { data } = await instance.get>(endpoint, { + const data = await FiestaInstance.get>(endpoint, { cache: "force-cache", next: { tags: festivalOnBoarding.all, @@ -36,7 +36,7 @@ export const getCategories = async () => { }; export const getCompanions = async () => { const endpoint = FIESTA_ENDPOINTS.festivals.companions; - const { data } = await instance.get>(endpoint, { + const data = await FiestaInstance.get>(endpoint, { cache: "force-cache", next: { tags: festivalOnBoarding.all, @@ -48,7 +48,7 @@ export const getCompanions = async () => { export const getPriority = async () => { const endpoint = FIESTA_ENDPOINTS.festivals.priorities; - const { data } = await instance.get>(endpoint, { + const data = await FiestaInstance.get>(endpoint, { cache: "force-cache", next: { tags: festivalOnBoarding.all, diff --git a/src/apis/review/reviewDelete/reviewDelete.ts b/src/apis/review/reviewDelete/reviewDelete.ts index 061cf46..f895e22 100644 --- a/src/apis/review/reviewDelete/reviewDelete.ts +++ b/src/apis/review/reviewDelete/reviewDelete.ts @@ -1,4 +1,4 @@ -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import { FIESTA_ENDPOINTS } from "@/config"; import { ReviewDeleteResponse } from "./reviewDeleteType"; @@ -7,7 +7,7 @@ const ENDPOINT = FIESTA_ENDPOINTS.reviews; export async function deleteReview(reviewId: number) { const endpoint = ENDPOINT.detail(String(reviewId)); - const { data } = await instance.delete(endpoint); + const data = await FiestaInstance.delete(endpoint); return data; } diff --git a/src/apis/review/reviewKeywords/reviewKeywords.ts b/src/apis/review/reviewKeywords/reviewKeywords.ts index 7c62f41..481266e 100644 --- a/src/apis/review/reviewKeywords/reviewKeywords.ts +++ b/src/apis/review/reviewKeywords/reviewKeywords.ts @@ -1,4 +1,4 @@ -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import { FIESTA_ENDPOINTS } from "@/config"; import { ReviewKeyword } from "./reviewKeywordsType"; @@ -7,7 +7,7 @@ const ENDPOINT = FIESTA_ENDPOINTS.reviews; export async function getReviewKeywords() { const endpoint = ENDPOINT.keywords; - const { data } = await instance.get>(endpoint, { + const data = await FiestaInstance.get>(endpoint, { cache: "force-cache", next: { tags: ["/reviews/keywords"], diff --git a/src/apis/review/reviewReport/reviewReport.ts b/src/apis/review/reviewReport/reviewReport.ts index f171e02..dc95c8c 100644 --- a/src/apis/review/reviewReport/reviewReport.ts +++ b/src/apis/review/reviewReport/reviewReport.ts @@ -1,4 +1,4 @@ -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import { FIESTA_ENDPOINTS } from "@/config"; import { ReviewReportResponse } from "./reviewReportType"; @@ -10,7 +10,7 @@ export async function postReviewReport(body: { description: string; }) { const endpoint = ENDPOINT.reports(String(body.reviewId)); - const { data } = await instance.post(endpoint, { + const data = await FiestaInstance.post(endpoint, { description: body.description, }); diff --git a/src/apis/review/reviewUpdate/reviewUpdate.ts b/src/apis/review/reviewUpdate/reviewUpdate.ts index 95054ef..3af618c 100644 --- a/src/apis/review/reviewUpdate/reviewUpdate.ts +++ b/src/apis/review/reviewUpdate/reviewUpdate.ts @@ -1,4 +1,4 @@ -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import { FIESTA_ENDPOINTS } from "@/config"; import { ReviewUpdateBody, ReviewUpdateResponse } from "./reviewUpdateType"; @@ -8,7 +8,7 @@ const ENDPOINT = FIESTA_ENDPOINTS.reviews; export async function patchReview(payload: ReviewUpdateBody) { const { reviewId, ...body } = payload; const endpoint = ENDPOINT.detail(String(reviewId)); - const { data } = await instance.patch(endpoint, body); + const data = await FiestaInstance.patch(endpoint, body); return data; } diff --git a/src/apis/review/reviews/reviews.ts b/src/apis/review/reviews/reviews.ts index 4609de5..f25ec24 100644 --- a/src/apis/review/reviews/reviews.ts +++ b/src/apis/review/reviews/reviews.ts @@ -1,4 +1,4 @@ -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import { FIESTA_ENDPOINTS } from "@/config"; import { generateUrlWithParams } from "@/utils"; import { NewReviewSchemaType } from "@/validations/NewReviewSchema"; @@ -16,7 +16,7 @@ const ENDPOINT = FIESTA_ENDPOINTS.reviews; export async function getReview(reviewId: string) { const endpoint = ENDPOINT.detail(reviewId); - const { data } = await instance.get(endpoint, { + const data = await FiestaInstance.get(endpoint, { cache: "no-store", }); @@ -25,7 +25,7 @@ export async function getReview(reviewId: string) { export async function getReviews(params: FestivalReviewsParameters) { const endpoint = ENDPOINT.base; - const { data } = await instance.get( + const data = await FiestaInstance.get( generateUrlWithParams(endpoint, params), { cache: "no-store", @@ -50,7 +50,10 @@ export async function postReviews(payload: NewReviewSchemaType) { formData.append("images", image); }); - const { data } = await instance.post(endpoint, formData); + const data = await FiestaInstance.post( + endpoint, + formData, + ); return data; } @@ -69,7 +72,10 @@ export async function updateReview(payload: UpdateReviewSchemaType) { formData.append("images", image); }); - const { data } = await instance.patch(endpoint, formData); + const data = await FiestaInstance.patch( + endpoint, + formData, + ); return data; } @@ -77,7 +83,7 @@ export async function updateReview(payload: UpdateReviewSchemaType) { export async function deleteReview(reviewId: string) { const endpoint = ENDPOINT.detail(reviewId); - const { data } = await instance.delete(endpoint); + const data = await FiestaInstance.delete(endpoint); return data; } diff --git a/src/apis/review/topReviews/topReviews.ts b/src/apis/review/topReviews/topReviews.ts index 87c584f..6cfc36e 100644 --- a/src/apis/review/topReviews/topReviews.ts +++ b/src/apis/review/topReviews/topReviews.ts @@ -1,17 +1,17 @@ "use server"; -import instance from "@/apis/instance"; -import { FIESTA_ENDPOINTS } from "@/config"; +import FiestaInstance from "@/apis/FiestaInstance"; +import { FIESTA_ENDPOINTS, REVALIDATE_DURATION } from "@/config"; import { TopReview } from "./topReviewsType"; -const ENDPOINT = FIESTA_ENDPOINTS.reviews; - export async function getTopReviews() { - const endpoint = ENDPOINT.mostlike; - const { data } = await instance.get>(endpoint, { - cache: "no-store", + const endpoint = FIESTA_ENDPOINTS.reviews.mostlike; + const response = await FiestaInstance.get>(endpoint, { + next: { + revalidate: REVALIDATE_DURATION.SECOND * 10, + }, }); - return data; + return response; } diff --git a/src/apis/user/badges/badges.ts b/src/apis/user/badges/badges.ts index 4a9410f..4e61b1f 100644 --- a/src/apis/user/badges/badges.ts +++ b/src/apis/user/badges/badges.ts @@ -1,13 +1,13 @@ "use server"; -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import { FIESTA_ENDPOINTS } from "@/config"; import { BadgesResponse } from "./badgesType"; export const getUserBadges = async () => { const endpoint = FIESTA_ENDPOINTS.users.badges; - const { data } = await instance.get(endpoint, { + const data = await FiestaInstance.get(endpoint, { next: { revalidate: 3600 }, }); diff --git a/src/apis/user/bookmarks/bookmarks.ts b/src/apis/user/bookmarks/bookmarks.ts index d51e7ed..82f9538 100644 --- a/src/apis/user/bookmarks/bookmarks.ts +++ b/src/apis/user/bookmarks/bookmarks.ts @@ -1,4 +1,4 @@ -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import { FIESTA_ENDPOINTS } from "@/config"; import { generateUrlWithParams } from "@/utils"; @@ -13,7 +13,7 @@ export const getBookmarkedFestival = async ( params: BookmarkFestivalParameter = defaultParameter, ) => { const endpoint = FIESTA_ENDPOINTS.users.bookmarks; - const { data } = await instance.get( + const data = await FiestaInstance.get( generateUrlWithParams(endpoint, params), { cache: "no-store", diff --git a/src/apis/user/me/me.ts b/src/apis/user/me/me.ts index 57efa66..44dcd44 100644 --- a/src/apis/user/me/me.ts +++ b/src/apis/user/me/me.ts @@ -1,6 +1,7 @@ "use server"; -import instance, { FiestaFetchOptions } from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; +import { FiestaFetchOptions } from "@/apis/instance"; import { FIESTA_ENDPOINTS } from "@/config"; import { ProfileMeUpdateSchemaType } from "@/validations/ProfileUpdateMeSchema"; @@ -8,7 +9,7 @@ import { UserMeResponse } from "./meType"; export const getMe = async (options?: FiestaFetchOptions) => { const endpoint = FIESTA_ENDPOINTS.users.me; - const { data } = await instance.get(endpoint, { + const data = await FiestaInstance.get(endpoint, { ...options, cache: "no-store", }); @@ -18,7 +19,7 @@ export const getMe = async (options?: FiestaFetchOptions) => { export const updateMe = async (body: ProfileMeUpdateSchemaType) => { const endpoint = FIESTA_ENDPOINTS.users.me; - const { data } = await instance.patch>( + const data = await FiestaInstance.patch>( endpoint, body, ); diff --git a/src/apis/user/onboarding-info/onboarding-info.ts b/src/apis/user/onboarding-info/onboarding-info.ts index 93e574e..0393db6 100644 --- a/src/apis/user/onboarding-info/onboarding-info.ts +++ b/src/apis/user/onboarding-info/onboarding-info.ts @@ -1,6 +1,6 @@ "use server"; -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import { FIESTA_ENDPOINTS } from "@/config"; import { OnboardingInfoResponse } from "./onboarding-infoType"; @@ -8,7 +8,7 @@ import { OnboardingInfoResponse } from "./onboarding-infoType"; export const getUserOnboardingInfo = async () => { const endpoint = FIESTA_ENDPOINTS.users.onboarding_info; - const { data } = await instance.get(endpoint, { + const data = await FiestaInstance.get(endpoint, { cache: "no-store", }); diff --git a/src/apis/user/profile/patchProfile.ts b/src/apis/user/profile/patchProfile.ts index 23a2f22..08aba3e 100644 --- a/src/apis/user/profile/patchProfile.ts +++ b/src/apis/user/profile/patchProfile.ts @@ -1,13 +1,13 @@ "use server"; -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import { FIESTA_ENDPOINTS } from "@/config"; import { UserProfileRequest, UserProfileResponse } from "./profileType"; export const patchProfile = async (body: UserProfileRequest) => { const endpoint = FIESTA_ENDPOINTS.users.profile; - const { data } = await instance.patch(endpoint, body); + const data = await FiestaInstance.patch(endpoint, body); return data; }; diff --git a/src/apis/user/profile/postProfile.ts b/src/apis/user/profile/postProfile.ts index 7995ea7..c9642c9 100644 --- a/src/apis/user/profile/postProfile.ts +++ b/src/apis/user/profile/postProfile.ts @@ -1,13 +1,13 @@ "use server"; -import instance from "@/apis/instance"; +import FiestaInstance from "@/apis/FiestaInstance"; import { FIESTA_ENDPOINTS } from "@/config"; import { UserProfileRequest, UserProfileResponse } from "./profileType"; export const postProfile = async (body: UserProfileRequest) => { const endpoint = FIESTA_ENDPOINTS.users.profile; - const { data } = await instance.post(endpoint, body); + const data = await FiestaInstance.post(endpoint, body); return data; }; diff --git a/src/app/(route)/(home)/_components/FestivalRecommend/index.tsx b/src/app/(route)/(home)/_components/FestivalRecommend/index.tsx index 5634557..c3582c0 100644 --- a/src/app/(route)/(home)/_components/FestivalRecommend/index.tsx +++ b/src/app/(route)/(home)/_components/FestivalRecommend/index.tsx @@ -8,7 +8,6 @@ import { recommendFestivalKeys } from "@/apis/festivals/recommendFestival/recomm import RecommendFestivalList from "@/components/Swiper/RecommendFestival/RecommendFestival"; import { useUserStore } from "@/store/user"; -import RecommendFestivalFallbackUI from "./RecommendFestivalFallbackUI"; import RecommendFestivalSkeleton from "./RecommendFestivalSkeleton"; interface Props {} @@ -26,10 +25,6 @@ const RecommendFestival: FC = ({}) => { return ; } - if (!user) { - return ; - } - return ; }; diff --git a/src/app/(route)/(home)/page.tsx b/src/app/(route)/(home)/page.tsx index aba10db..468737c 100644 --- a/src/app/(route)/(home)/page.tsx +++ b/src/app/(route)/(home)/page.tsx @@ -1,5 +1,6 @@ import { Metadata } from "next"; +import { getServerSideSession } from "@/apis/auth/auth"; import { FloatingButton } from "@/components/core/Button"; import { HomeHeader } from "@/layout/Mobile/MobileHeader"; import NavigationBar from "@/layout/Mobile/NavigationBar"; @@ -10,6 +11,7 @@ import { FestivalThisWeek, TopReviews, } from "./_components"; +import RecommendFestivalFallbackUI from "./_components/FestivalRecommend/RecommendFestivalFallbackUI"; export const metadata: Metadata = { title: { @@ -37,16 +39,18 @@ export const metadata: Metadata = { }; export default async function Home() { + const session = await getServerSideSession(); return (
- + {!!session ? : } +
- + {!!session ? : null}
); diff --git a/src/app/(route)/festivals/[festivalId]/_components/DetailFestivalTab/Review/_components/TotalReviews/TotalReviewListItem.tsx b/src/app/(route)/festivals/[festivalId]/_components/DetailFestivalTab/Review/_components/TotalReviews/TotalReviewListItem.tsx index f43486b..852ca28 100644 --- a/src/app/(route)/festivals/[festivalId]/_components/DetailFestivalTab/Review/_components/TotalReviews/TotalReviewListItem.tsx +++ b/src/app/(route)/festivals/[festivalId]/_components/DetailFestivalTab/Review/_components/TotalReviews/TotalReviewListItem.tsx @@ -1,7 +1,6 @@ "use client"; import { useMutation, useQueryClient } from "@tanstack/react-query"; -import isEmpty from "lodash/isEmpty"; import Image from "next/image"; import { useRouter } from "next/navigation"; import { FC, useMemo, useState } from "react"; @@ -109,7 +108,7 @@ const TotalReviewListItem: FC = ({ review }) => { {!!user && } - {!isEmpty(review.images) && ( + {!!review.images.length && (
{review.images.map((image) => ( { + const setUser = useUserStore((state) => state.updateUser); + + const handleSignOut = () => { + setUser(null); + signOut(); + }; + return ( -
+
{ className="text-gray-scale-900" /> +
); }; diff --git a/src/app/(route)/search/_components/SearchFestivalList/index.tsx b/src/app/(route)/search/_components/SearchFestivalList/index.tsx index 3e8ece4..9bfd410 100644 --- a/src/app/(route)/search/_components/SearchFestivalList/index.tsx +++ b/src/app/(route)/search/_components/SearchFestivalList/index.tsx @@ -1,7 +1,6 @@ "use client"; -import isEmpty from "lodash/isEmpty"; -import isString from "lodash/isString"; +import { isNotNil, isString } from "es-toolkit/predicate"; import { useQueryState } from "nuqs"; import { useEffect } from "react"; @@ -18,10 +17,10 @@ const SearchFestival = () => { const { set } = useSearchHistory(); useEffect(() => { - if (isString(query) && !isEmpty(query)) { + if (isString(query) && isNotNil(query) && query.length > 0) { set(query); } - }, [data, query, set]); + }, [data]); const isQueryStringEmpty = query?.length === 0; const HasNoData = !data || data?.length === 0; diff --git a/src/app/(route)/search/_components/TrendingFestival/TrendingFestivalSkeleton.tsx b/src/app/(route)/search/_components/TrendingFestival/TrendingFestivalSkeleton.tsx index 82b82c2..9a4f86d 100644 --- a/src/app/(route)/search/_components/TrendingFestival/TrendingFestivalSkeleton.tsx +++ b/src/app/(route)/search/_components/TrendingFestival/TrendingFestivalSkeleton.tsx @@ -1,7 +1,7 @@ const TrendingFestivalSkeleton = () => { return (
-
+
    diff --git a/src/app/(route)/search/_components/TrendingFestival/index.tsx b/src/app/(route)/search/_components/TrendingFestival/index.tsx index 1a10067..a258794 100644 --- a/src/app/(route)/search/_components/TrendingFestival/index.tsx +++ b/src/app/(route)/search/_components/TrendingFestival/index.tsx @@ -1,6 +1,6 @@ "use client"; -import { useSuspenseQuery } from "@tanstack/react-query"; +import { useQuery } from "@tanstack/react-query"; import Link from "next/link"; import { useQueryState } from "nuqs"; @@ -8,8 +8,10 @@ import { getTrendingFestival } from "@/apis/festivals/trendingFestival/trendingF import { TrendingFestivalKeys } from "@/apis/festivals/trendingFestival/trendingFestivalKeys"; import { cn } from "@/utils"; +import TrendingFestivalSkeleton from "./TrendingFestivalSkeleton"; + const TrendingFestival = () => { - const { data } = useSuspenseQuery({ + const { data, isLoading } = useQuery({ queryKey: TrendingFestivalKeys.all, queryFn: getTrendingFestival, }); @@ -20,6 +22,10 @@ const TrendingFestival = () => { return null; } + if (isLoading) { + return ; + } + return (
    @@ -30,7 +36,7 @@ const TrendingFestival = () => {
    - {data.map((festival, idx, arr) => { + {data?.map((festival, idx, arr) => { return ( { return (
    - }> - - +
    diff --git a/src/app/error.tsx b/src/app/error.tsx index 3e44453..740f064 100644 --- a/src/app/error.tsx +++ b/src/app/error.tsx @@ -19,7 +19,7 @@ export default function NotFoundPage() { xmlns="http://www.w3.org/2000/svg" > { - return serialize(currentPath, { + return serialize(`/${currentPath}`, { page, size, }); diff --git a/src/components/Swiper/RecommendFestival/RecommendFestival.tsx b/src/components/Swiper/RecommendFestival/RecommendFestival.tsx index 0b82ec6..4519c5a 100644 --- a/src/components/Swiper/RecommendFestival/RecommendFestival.tsx +++ b/src/components/Swiper/RecommendFestival/RecommendFestival.tsx @@ -26,7 +26,7 @@ const RecommendFestivalList: FC = ({ recommendFestivals }) => { delay: 3000, pauseOnMouseEnter: true, }} - loop + loop={!!recommendFestivals?.festivals.length} pagination={{ type: "fraction", el: ".pagination_fraction", diff --git a/src/components/core/Button/FloatingButton/FloatingButton.tsx b/src/components/core/Button/FloatingButton/FloatingButton.tsx index 4727101..748c4e2 100644 --- a/src/components/core/Button/FloatingButton/FloatingButton.tsx +++ b/src/components/core/Button/FloatingButton/FloatingButton.tsx @@ -1,15 +1,8 @@ import Link from "next/link"; -import { getServerSideSession } from "@/apis/auth/auth"; import { PencilIcon } from "@/components/icons"; -const FloatingButton = async () => { - const session = await getServerSideSession(); - - if (!session) { - return null; - } - +const FloatingButton = () => { return ( = ({ festival }) => {
    - console.log("test")} - > +
    diff --git a/src/components/icons/ARROW_BACK_ANDROID_ICON.svg b/src/components/icons/ARROW_BACK_ANDROID_ICON.svg index 55b8629..ded0a80 100644 --- a/src/components/icons/ARROW_BACK_ANDROID_ICON.svg +++ b/src/components/icons/ARROW_BACK_ANDROID_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/ARROW_DECREASE_ICON.svg b/src/components/icons/ARROW_DECREASE_ICON.svg index 1b30978..b899c95 100644 --- a/src/components/icons/ARROW_DECREASE_ICON.svg +++ b/src/components/icons/ARROW_DECREASE_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/ARROW_INCREASE_ICON.svg b/src/components/icons/ARROW_INCREASE_ICON.svg index 3f867e2..12fee52 100644 --- a/src/components/icons/ARROW_INCREASE_ICON.svg +++ b/src/components/icons/ARROW_INCREASE_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/ARROW_LEFT_SMALL_ICON.svg b/src/components/icons/ARROW_LEFT_SMALL_ICON.svg index 684708d..92dd0e1 100644 --- a/src/components/icons/ARROW_LEFT_SMALL_ICON.svg +++ b/src/components/icons/ARROW_LEFT_SMALL_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/ARROW_RIGHT_ANDROID_ICON.svg b/src/components/icons/ARROW_RIGHT_ANDROID_ICON.svg index 244a11a..bd35c12 100644 --- a/src/components/icons/ARROW_RIGHT_ANDROID_ICON.svg +++ b/src/components/icons/ARROW_RIGHT_ANDROID_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/ARROW_RIGHT_SMALL_ICON.svg b/src/components/icons/ARROW_RIGHT_SMALL_ICON.svg index f467c91..9f69516 100644 --- a/src/components/icons/ARROW_RIGHT_SMALL_ICON.svg +++ b/src/components/icons/ARROW_RIGHT_SMALL_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/CALENDAR_CHECK_ICON.svg b/src/components/icons/CALENDAR_CHECK_ICON.svg index a2ab2df..6cffbe6 100644 --- a/src/components/icons/CALENDAR_CHECK_ICON.svg +++ b/src/components/icons/CALENDAR_CHECK_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/CALENDAR_ICON.svg b/src/components/icons/CALENDAR_ICON.svg index 231e80f..f87d640 100644 --- a/src/components/icons/CALENDAR_ICON.svg +++ b/src/components/icons/CALENDAR_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/CAMERA_ICON.svg b/src/components/icons/CAMERA_ICON.svg index f64aa80..6b3b971 100644 --- a/src/components/icons/CAMERA_ICON.svg +++ b/src/components/icons/CAMERA_ICON.svg @@ -1,4 +1,4 @@ - - + + diff --git a/src/components/icons/CHAT_BUBBLE_DOTS_ICON.svg b/src/components/icons/CHAT_BUBBLE_DOTS_ICON.svg index 469a99b..e6844a8 100644 --- a/src/components/icons/CHAT_BUBBLE_DOTS_ICON.svg +++ b/src/components/icons/CHAT_BUBBLE_DOTS_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/CHAT_BUBBLE_ICON.svg b/src/components/icons/CHAT_BUBBLE_ICON.svg index 0f4d6e8..bc3d6ce 100644 --- a/src/components/icons/CHAT_BUBBLE_ICON.svg +++ b/src/components/icons/CHAT_BUBBLE_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/CHECK_CIRCLE_ICON.svg b/src/components/icons/CHECK_CIRCLE_ICON.svg index 9e0a9ad..278bcf9 100644 --- a/src/components/icons/CHECK_CIRCLE_ICON.svg +++ b/src/components/icons/CHECK_CIRCLE_ICON.svg @@ -1,4 +1,4 @@ - + diff --git a/src/components/icons/CHECK_ICON.svg b/src/components/icons/CHECK_ICON.svg index 38fca3b..c85fae5 100644 --- a/src/components/icons/CHECK_ICON.svg +++ b/src/components/icons/CHECK_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/CLOCK_ICON.svg b/src/components/icons/CLOCK_ICON.svg index 874ca95..3ed7efd 100644 --- a/src/components/icons/CLOCK_ICON.svg +++ b/src/components/icons/CLOCK_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/DOTS_ICON.svg b/src/components/icons/DOTS_ICON.svg index 3080c71..399a926 100644 --- a/src/components/icons/DOTS_ICON.svg +++ b/src/components/icons/DOTS_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/ERROR_ICON.svg b/src/components/icons/ERROR_ICON.svg index 97f8dbc..a5bc3bc 100644 --- a/src/components/icons/ERROR_ICON.svg +++ b/src/components/icons/ERROR_ICON.svg @@ -1,5 +1,5 @@ - + diff --git a/src/components/icons/FILTER_ICON.svg b/src/components/icons/FILTER_ICON.svg index f0da049..8d7b3b8 100644 --- a/src/components/icons/FILTER_ICON.svg +++ b/src/components/icons/FILTER_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/HALF_STAR_ICON.svg b/src/components/icons/HALF_STAR_ICON.svg index f54f85c..e9f0790 100644 --- a/src/components/icons/HALF_STAR_ICON.svg +++ b/src/components/icons/HALF_STAR_ICON.svg @@ -1,6 +1,6 @@ - + diff --git a/src/components/icons/HEART_ICON.svg b/src/components/icons/HEART_ICON.svg index 991f35b..49c3a79 100644 --- a/src/components/icons/HEART_ICON.svg +++ b/src/components/icons/HEART_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/HOME_ICON.svg b/src/components/icons/HOME_ICON.svg index 986816b..923ff3f 100644 --- a/src/components/icons/HOME_ICON.svg +++ b/src/components/icons/HOME_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/KAKAO_ICON.svg b/src/components/icons/KAKAO_ICON.svg index 7525000..9423ca2 100644 --- a/src/components/icons/KAKAO_ICON.svg +++ b/src/components/icons/KAKAO_ICON.svg @@ -1,6 +1,6 @@ - + diff --git a/src/components/icons/LOCK_ICON.svg b/src/components/icons/LOCK_ICON.svg index 35f7443..2822651 100644 --- a/src/components/icons/LOCK_ICON.svg +++ b/src/components/icons/LOCK_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/LOGOUT.svg b/src/components/icons/LOGOUT.svg new file mode 100644 index 0000000..1727261 --- /dev/null +++ b/src/components/icons/LOGOUT.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/components/icons/PENCIL_ICON.svg b/src/components/icons/PENCIL_ICON.svg index fea0860..f7be960 100644 --- a/src/components/icons/PENCIL_ICON.svg +++ b/src/components/icons/PENCIL_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/PICTURE_ICON.svg b/src/components/icons/PICTURE_ICON.svg index 67979bd..156e232 100644 --- a/src/components/icons/PICTURE_ICON.svg +++ b/src/components/icons/PICTURE_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/PIN_LOCATION_ICON.svg b/src/components/icons/PIN_LOCATION_ICON.svg index 6e4e2ef..dd3f82d 100644 --- a/src/components/icons/PIN_LOCATION_ICON.svg +++ b/src/components/icons/PIN_LOCATION_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/PLUS_ICON.svg b/src/components/icons/PLUS_ICON.svg index a3731c3..f816345 100644 --- a/src/components/icons/PLUS_ICON.svg +++ b/src/components/icons/PLUS_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/SCRAP_ICON.svg b/src/components/icons/SCRAP_ICON.svg index f7c0351..ccd47c7 100644 --- a/src/components/icons/SCRAP_ICON.svg +++ b/src/components/icons/SCRAP_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/SETTING_ICON.svg b/src/components/icons/SETTING_ICON.svg index be676be..508182b 100644 --- a/src/components/icons/SETTING_ICON.svg +++ b/src/components/icons/SETTING_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/SHARE_ICON.svg b/src/components/icons/SHARE_ICON.svg index c6f75e0..aad7070 100644 --- a/src/components/icons/SHARE_ICON.svg +++ b/src/components/icons/SHARE_ICON.svg @@ -1,4 +1,4 @@ - - + + diff --git a/src/components/icons/STACK_UP_SQUARE_ICON.svg b/src/components/icons/STACK_UP_SQUARE_ICON.svg index 2a15dc9..9b42c86 100644 --- a/src/components/icons/STACK_UP_SQUARE_ICON.svg +++ b/src/components/icons/STACK_UP_SQUARE_ICON.svg @@ -1,5 +1,5 @@ - - - + + + diff --git a/src/components/icons/STAR_ICON.svg b/src/components/icons/STAR_ICON.svg index 30eb54d..dff69a5 100644 --- a/src/components/icons/STAR_ICON.svg +++ b/src/components/icons/STAR_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/TRASH_ICON.svg b/src/components/icons/TRASH_ICON.svg index 47804ce..2578395 100644 --- a/src/components/icons/TRASH_ICON.svg +++ b/src/components/icons/TRASH_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/TWINKLE_CIRCLE_ICON.svg b/src/components/icons/TWINKLE_CIRCLE_ICON.svg index 49585d2..2a08f87 100644 --- a/src/components/icons/TWINKLE_CIRCLE_ICON.svg +++ b/src/components/icons/TWINKLE_CIRCLE_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/USER_ICON.svg b/src/components/icons/USER_ICON.svg index 4b04df8..faddcbd 100644 --- a/src/components/icons/USER_ICON.svg +++ b/src/components/icons/USER_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/USER_SQUARE_ICON.svg b/src/components/icons/USER_SQUARE_ICON.svg index aae3ad5..8fd9421 100644 --- a/src/components/icons/USER_SQUARE_ICON.svg +++ b/src/components/icons/USER_SQUARE_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/WARNING_TRIANGLE_ICON.svg b/src/components/icons/WARNING_TRIANGLE_ICON.svg index e8fbc9e..78e3f96 100644 --- a/src/components/icons/WARNING_TRIANGLE_ICON.svg +++ b/src/components/icons/WARNING_TRIANGLE_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/X_ICON.svg b/src/components/icons/X_ICON.svg index f5dff90..7912dc5 100644 --- a/src/components/icons/X_ICON.svg +++ b/src/components/icons/X_ICON.svg @@ -1,3 +1,3 @@ - + diff --git a/src/components/icons/index.ts b/src/components/icons/index.ts index b99c58d..ae06be5 100644 --- a/src/components/icons/index.ts +++ b/src/components/icons/index.ts @@ -23,6 +23,7 @@ export { default as HeartIcon } from "./HEART_ICON.svg"; export { default as HomeIcon } from "./HOME_ICON.svg"; export { default as KakaoIcon } from "./KAKAO_ICON.svg"; export { default as LockIcon } from "./LOCK_ICON.svg"; +export { default as LogoutIcon } from "./LOGOUT.svg"; export { default as PencilIcon } from "./PENCIL_ICON.svg"; export { default as PictureIcon } from "./PICTURE_ICON.svg"; export { default as PinLocationIcon } from "./PIN_LOCATION_ICON.svg"; diff --git a/src/config/apiEndpoints.ts b/src/config/apiEndpoints.ts index 6977ab0..537a9a4 100644 --- a/src/config/apiEndpoints.ts +++ b/src/config/apiEndpoints.ts @@ -1,53 +1,53 @@ const FIESTA_ENDPOINTS = { users: { - profile: "/users/profile", - bookmarks: "/users/bookmarks", - badges: "/users/badges", - onboarding_info: "/users/onboarding-info", - reissue: "/users/reissue", - logout: "/users/logout", - unlink: "/users/unlink", - login: "/users/oauth/login", - me: "/users/me", + profile: "users/profile", + bookmarks: "users/bookmarks", + badges: "users/badges", + onboarding_info: "users/onboarding-info", + reissue: "users/reissue", + logout: "users/logout", + unlink: "users/unlink", + login: "users/oauth/login", + me: "users/me", }, festivals: { - recommend: "/festivals/recommend", - priorities: "/festivals/priorities", - companions: "/festivals/companions", - categories: "/festivals/categories", - moods: "/festivals/moods", - mostlike: "/festivals/mostlike", - thisWeek: "/festivals/thisweek", - filter: "/festivals/filter", - base: "/festivals", - monthly: "/festivals/monthly", - daily: "/festivals/daily", - detail: (festivalId: string) => `/festivals/${festivalId}`, - trending: "/festivals/trending", - search: "/festivals/search", - bookmark: (festivalId: number) => `/festivals/${festivalId}/bookmark`, + recommend: "festivals/recommend", + priorities: "festivals/priorities", + companions: "festivals/companions", + categories: "festivals/categories", + moods: "festivals/moods", + mostlike: "festivals/mostlike", + thisWeek: "festivals/thisweek", + filter: "festivals/filter", + base: "festivals", + monthly: "festivals/monthly", + daily: "festivals/daily", + detail: (festivalId: string) => `festivals/${festivalId}`, + trending: "festivals/trending", + search: "festivals/search", + bookmark: (festivalId: number) => `festivals/${festivalId}/bookmark`, }, admin: { - festivals: "/admin/festivals", - festivalDetail: (festivalId: string) => `/admin/festivals/${festivalId}`, + festivals: "admin/festivals", + festivalDetail: (festivalId: string) => `admin/festivals/${festivalId}`, }, global: { - keywords: "/global/keywords", + keywords: "global/keywords", }, reviews: { - topKeywords: "/reviews/keywords/top", - base: "/reviews", - detail: (reviewId: string) => `/reviews/${reviewId}`, - like: (reviewId: string) => `/reviews/${reviewId}/like`, - mostlike: "/reviews/mostlike", - keywords: "/reviews/keywords", - reports: (reviewId: string) => `/reviews/${reviewId}/reports`, + topKeywords: "reviews/keywords/top", + base: "reviews", + detail: (reviewId: string) => `reviews/${reviewId}`, + like: (reviewId: string) => `reviews/${reviewId}/like`, + mostlike: "reviews/mostlike", + keywords: "reviews/keywords", + reports: (reviewId: string) => `reviews/${reviewId}/reports`, }, logs: { - userLogs: (userId: string) => `/users/${userId}/logs`, - base: "/logs", - detail: (logId: string) => `/logs/${logId}`, - keywords: "/logs/keywords", + userLogs: (userId: string) => `users/${userId}/logs`, + base: "logs", + detail: (logId: string) => `logs/${logId}`, + keywords: "logs/keywords", }, }; diff --git a/src/config/revalidateDuration.ts b/src/config/revalidateDuration.ts index 5cd8cae..c94695a 100644 --- a/src/config/revalidateDuration.ts +++ b/src/config/revalidateDuration.ts @@ -1,4 +1,5 @@ const REVALIDATE_DURATION = { + SECOND: 1, DAY: 86400, HOUR: 3600, MINUTE: 60, diff --git a/src/hooks/.keep b/src/hooks/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/src/hooks/session/useUpdateUserSession.tsx b/src/hooks/session/useUpdateUserSession.tsx deleted file mode 100644 index c8273ba..0000000 --- a/src/hooks/session/useUpdateUserSession.tsx +++ /dev/null @@ -1,33 +0,0 @@ -"use client"; -/* eslint-disable react-hooks/exhaustive-deps */ - -import { useSearchParams } from "next/navigation"; -import { useSession } from "next-auth/react"; -import { useEffect } from "react"; - -import { useUserStore } from "@/store/user"; - -const useUpdateUserSession = () => { - const searchParams = useSearchParams(); - const setUser = useUserStore((state) => state.updateUser); - const { data: session, update } = useSession(); - - const handleSessionUpdate = async () => { - try { - if (session) { - session.user.userTypeId = Number(searchParams.get("userTypeId")); - session.user.isProfileRegistered = true; - await update(session); - setUser(session.user ?? null); - } - } catch (error) { - console.error("Failed to update session:", error); - } - }; - - useEffect(() => { - handleSessionUpdate(); - }, []); -}; - -export default useUpdateUserSession; diff --git a/src/hooks/useGetSearchFestival.tsx b/src/hooks/useGetSearchFestival.tsx index 78281e0..8131e1d 100644 --- a/src/hooks/useGetSearchFestival.tsx +++ b/src/hooks/useGetSearchFestival.tsx @@ -1,5 +1,5 @@ import { keepPreviousData, useQuery } from "@tanstack/react-query"; -import debounce from "lodash/debounce"; +import { debounce } from "es-toolkit/function"; import { useEffect, useState } from "react"; import { getSearchFestival } from "@/apis/festivals/searchFestival/searchFestival"; diff --git a/src/hooks/useSearchHistory.tsx b/src/hooks/useSearchHistory.tsx index 94941b0..bd6705b 100644 --- a/src/hooks/useSearchHistory.tsx +++ b/src/hooks/useSearchHistory.tsx @@ -5,7 +5,9 @@ export const useSearchHistory = () => { const updateHistories = (query: string) => { set((prev) => { - const updatedHistories = prev.filter((history) => history !== query); + const updatedHistories = prev.filter( + (history) => history !== query && history !== "", + ); return [...updatedHistories, query]; }); }; diff --git a/src/layout/Mobile/MobileHeader/HomeHeader/HomeHeader.tsx b/src/layout/Mobile/MobileHeader/HomeHeader/HomeHeader.tsx index 5c5ac14..6535b83 100644 --- a/src/layout/Mobile/MobileHeader/HomeHeader/HomeHeader.tsx +++ b/src/layout/Mobile/MobileHeader/HomeHeader/HomeHeader.tsx @@ -1,12 +1,9 @@ import Image from "next/image"; import Link from "next/link"; -import { FC } from "react"; import { SearchIcon } from "@/components/icons"; -interface Props {} - -const HomeHeader: FC = ({}) => { +const HomeHeader = ({}) => { return (
    diff --git a/src/middleware.ts b/src/middleware.ts index 9207a89..6568adb 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -1,8 +1,8 @@ import type { NextRequest } from "next/server"; import { NextResponse } from "next/server"; -import { match } from "path-to-regexp"; import { getServerSideSession } from "./apis/auth/auth"; +import { isMatchPath } from "./utils"; const serviceReadyRoute = ["/chat", "/map", "/calander"]; const matchersForAuth = ["/mypage"]; @@ -25,7 +25,7 @@ export async function middleware(request: NextRequest) { } // * 인증이 필요한 페이지 접근 제어! - if (isMatch(request.nextUrl.pathname, matchersForAuth)) { + if (isMatchPath(request.nextUrl.pathname, matchersForAuth)) { if (!!session && !session.user.isProfileRegistered) { return NextResponse.redirect(new URL("/onboarding", request.url)); } @@ -51,11 +51,6 @@ export async function middleware(request: NextRequest) { return NextResponse.next(); } -// * 경로 일치 확인! -function isMatch(pathname: string, urls: string[]) { - return urls.some((url) => !!match(url)(pathname)); -} - export const config = { matcher: [ /* diff --git a/src/utils/generateUrlWithParams.ts b/src/utils/generateUrlWithParams.ts index ca505c4..e8183d2 100644 --- a/src/utils/generateUrlWithParams.ts +++ b/src/utils/generateUrlWithParams.ts @@ -7,7 +7,7 @@ export function generateUrlWithParams( params?: object, ): string { if (!params || isEmpty(params)) { - return baseURL; + return `${baseURL}`; } const queryString = generateQueryString(params); diff --git a/src/utils/isMatchPath.ts b/src/utils/isMatchPath.ts index 1f66952..7c1f04c 100644 --- a/src/utils/isMatchPath.ts +++ b/src/utils/isMatchPath.ts @@ -1,4 +1,2 @@ -import { match } from "path-to-regexp"; - export const isMatchPath = (pathname: string, urls: string[]) => - urls.some((url) => !!match(url)(pathname)); + urls.some((url) => pathname.includes(url));