Skip to content

Commit

Permalink
✨ 백엔드와 기준 통일 및 불필요한 코드 정리 (#126)
Browse files Browse the repository at this point in the history
* ✨ 백엔드와 validation 기준 통일

* 🔥 사용되지 않는 코드 및 콘솔 삭제
  • Loading branch information
oaoong authored Nov 28, 2023
1 parent 51b4b39 commit 84f80f1
Show file tree
Hide file tree
Showing 33 changed files with 44 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useRouter } from 'next/navigation'
import AppPath from '@/config/appPath'
import { Environment } from '@/config/environment'
import { useToast } from '@/hooks/useToast'
import apiClient from '@/services/apiClient'
import { User } from '@/types/user'

type RouteCallbackProps = {
Expand Down
1 change: 0 additions & 1 deletion src/app/(root)/(routes)/(auth)/login/google/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ async function getGoogleAccessToken(code: string) {
const response = await getGoogleRedirect(escape(code))
return response
} catch (e) {
console.log(e)
return null
}
}
Expand Down
1 change: 0 additions & 1 deletion src/app/(root)/(routes)/(auth)/login/kakao/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ async function getKakaoAccessToken(code: string) {
const response = await getKakaoRedirect(escape(code))
return response
} catch (e) {
console.log(e)
return null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ async function getPopularCardValue() {
const data = await res
return data.data
} catch (error: any) {
console.log(error)
throw new Error(error.message)
}
}
Expand All @@ -17,7 +16,7 @@ const PopularCardSection = async () => {

return (
data && (
<section className="flex flex-col w-full gap-6">
<section className="flex flex-col w-full gap-6">
<div className="text-[24px] font-bold px-4">오늘의 인기 물건</div>
<PopularCardSlider cardData={data} />
</section>
Expand Down
22 changes: 0 additions & 22 deletions src/app/(root)/(routes)/(home)/components/TestBlock.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const MoreButton = ({ cardId, status }: MoreButtonProps) => {
if (shouldRedirect) {
router.push(shouldRedirect)
} else {
console.log(shouldRedirect, error)
toast({
title: '삭제를 실패했습니다',
duration: 2000,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { useState } from 'react'
import { useForm } from 'react-hook-form'
import { zodResolver } from '@hookform/resolvers/zod'
import { QueryClient, useQueryClient } from '@tanstack/react-query'
import Cookies from 'js-cookie'
import { useRouter } from 'next/navigation'
import AppPath from '@/config/appPath'
import { Environment } from '@/config/environment'
import { useAuth } from '@/contexts/AuthProvider'
import { useToast } from '@/hooks/useToast'
import { putCard } from '@/services/card/card'
import {
Expand Down Expand Up @@ -39,7 +35,6 @@ export const useCardModifyForm = ({
})

const [isSubmitting, setIsSubmitting] = useState(false)
const queryClient = useQueryClient()
const onSubmit = async (data: CardUploadFormValues) => {
if (isSubmitting) return
setIsSubmitting(() => true)
Expand All @@ -62,9 +57,6 @@ export const useCardModifyForm = ({
})
} finally {
setIsSubmitting(() => false)
// queryClient.invalidateQueries({
// queryKey: [cardId, 'cardInfo'],
// })
}
}

Expand Down
1 change: 0 additions & 1 deletion src/app/(root)/(routes)/cards/[cardId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const CardPage = ({ params }: CardPageProps) => {
const router = useRouter()
const { data } = useCardInfoQuery(Number(params.cardId), isLoggedIn)
const cardData = data?.data
console.log(cardData)

return (
<main className="flex-col min-h-screen bg-background-color">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { useEffect, useRef, useState } from 'react'
import ExceptionBoundary from '@/components/domain/exception-boundary'
import MaxWidthWrapper from '@/components/domain/max-width-wrapper'
import { useMyCardsQuery } from '@/hooks/api/queries/useMyCardsQuery'
import { useIntersectionObserver } from '@/hooks/useIntersectionObserver'
import { TradeStatus } from '@/types/card'
Expand Down Expand Up @@ -33,7 +32,7 @@ const MyCardListContent = () => {
const isEmpty = data?.pages[0].data.cardList.length === 0
return (
<>
<div className="h-9 flex justify-center items-center my-12">
<div className="flex items-center justify-center my-12 h-9">
<TradeStatusTabs
tradeStatus={tradeStatus}
setTradeStatus={setTradeStatus}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TradeStatus } from '@/types/card'

type TradeStatusTabsProps = {
tradeStatus: TradeStatus
setTradeStatus: (tradeStatus: TradeStatus) => void
setTradeStatus: (_tradeStatus: TradeStatus) => void
}

const TradeStatusTabs = ({
Expand Down
2 changes: 0 additions & 2 deletions src/app/(root)/(routes)/cards/new/hooks/useCardUploadForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ export const useCardUploadForm = () => {
title: 'Error',
description: '게시글을 업로드하는데 실패했습니다.',
})
console.log(error)
console.log(await error.response.json())
} finally {
setIsSubmitting(() => false)
}
Expand Down
1 change: 0 additions & 1 deletion src/app/(root)/(routes)/chatrooms/[chatRoomId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ const ChatPage = async ({ params }: ChatPageProps) => {
initialChatRoom.fromCardInfo,
initialChatRoom.toCardInfo,
]
console.log(suggestionDataArray)
const myCardId = suggestionDataArray.find(
(obj) => obj.userInfo.userId === initialUserInfo.userId,
).cardInfo.cardId
Expand Down
1 change: 0 additions & 1 deletion src/app/(root)/(routes)/dibs/components/MyDibsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const MyDibsList = ({
}: {
data: InfiniteData<GetMyDibsRes, unknown> | undefined
}) => {
console.log(data?.pages)
return (
<>
{data?.pages.map(({ data: { dibList } }: GetMyDibsRes, pageIndex) => (
Expand Down
1 change: 0 additions & 1 deletion src/app/(root)/(routes)/dibs/components/MyDibsTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import MyDibsList from './MyDibsList'
const MyDibsTemplate = () => {
const { data, fetchNextPage, isLoading, isError, isFetchingNextPage } =
useMyDibsQuery()
console.log(data)

const lastElementRef = useRef<HTMLDivElement | null>(null)
const entry = useIntersectionObserver(lastElementRef, { threshold: 1.0 })
Expand Down
2 changes: 0 additions & 2 deletions src/app/(root)/(routes)/mypage/components/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const UserInfo = ({ user }: UserInfoProps) => {
return resProfile.data
} catch (error) {
setIsProfileChanged(false)
console.log(error)
toast({
title: '프로필 이미지 변경 실패',
description: '프로필 이미지 변경에 실패했습니다.',
Expand All @@ -43,7 +42,6 @@ const UserInfo = ({ user }: UserInfoProps) => {
return res.data
} catch (error) {
setIsNicknameChanged(false)
console.log(error)
toast({
title: '닉네임 변경 실패',
description: '닉네임 변경에 실패했습니다.',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs'

type NotificationStatusTabsProps = {
setIsRead: (isRead: boolean) => void
setIsRead: (_isRead: boolean) => void
}

const NotificationStatusTabs = ({ setIsRead }: NotificationStatusTabsProps) => {
Expand All @@ -12,7 +12,7 @@ const NotificationStatusTabs = ({ setIsRead }: NotificationStatusTabsProps) => {
return (
<Tabs
defaultValue="isRead_true"
className="h-9 flex justify-center items-center my-12"
className="flex items-center justify-center my-12 h-9"
>
<TabsList>
<TabsTrigger
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import formatDistanceToNow from 'date-fns/formatDistanceToNow'
import koLocale from 'date-fns/locale/ko'
import Link from 'next/link'
import ReservedBadge from '@/components/domain/badge/reserved-badge'
import TradeAvailableBadge from '@/components/domain/badge/trade-available-badge'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { getValueByKey } from '@/utils/getValueByKey'
const SuggestionButtons = ({
handleMySuggestionUpdate,
}: {
handleMySuggestionUpdate: (isAccepted: boolean) => void
handleMySuggestionUpdate: (_isAccepted: boolean) => void
}) => (
<>
<CardFlex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs'
import { DirectionType, SuggestionType } from '@/types/suggestion'

type SuggestionStatusTabsProps = {
setSuggestionTypeState: (suggestionTypeState: SuggestionType) => void
setDirectionTypeState: (directionTypeState: DirectionType) => void
setSuggestionTypeState: (_suggestionTypeState: SuggestionType) => void
setDirectionTypeState: (_directionTypeState: DirectionType) => void
}

const SuggestionStatusTabs = ({
Expand Down
3 changes: 0 additions & 3 deletions src/components/domain/image-uploader/ImageUploader.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use client'

import React, { useState } from 'react'
import Cookies from 'js-cookie'
import { Environment } from '@/config/environment'
import { MAX_IMAGE_NUMBER } from '@/constants/image'
import { useToast } from '@/hooks/useToast'
import { postImageFile } from '@/services/images'
Expand Down Expand Up @@ -86,7 +84,6 @@ const ImageUploader = ({
isDeletable={isImageDeletable}
isThumbnail={isThumbnail}
onDeleteHandler={() => {
console.log(images)
setImages(images.filter((_, i) => i !== index))
onFilesChanged(images.filter((_, i) => i !== index))
}}
Expand Down
33 changes: 26 additions & 7 deletions src/components/domain/text-editable/TextEditable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Image from 'next/image'
import Button from '@/components/ui/button'
import Input from '@/components/ui/input'
import Assets from '@/config/assets'
import { useToast } from '@/hooks/useToast'
import { cn } from '@/utils'

type TextEditablePropsType = {
Expand All @@ -20,9 +21,9 @@ const TextEditable = ({
}: TextEditablePropsType) => {
const [isEditing, setIsEditing] = useState(false)
const [value, setValue] = useState(defaultText)
const { toast } = useToast()

useEffect(() => {
console.log('이름', defaultText)
if (!changedSuccessfully) {
setValue(() => defaultText)
}
Expand All @@ -32,6 +33,29 @@ const TextEditable = ({
setValue(event.target.value)
}

const onSubmit = () => {
if (isEditing) {
if (value.length < 2) {
toast({
title: '닉네임 변경 실패',
description: '닉네임은 2자 이상 입력해주세요.',
variant: 'destructive',
})
return
}
if (value.length > 20) {
toast({
title: '닉네임 변경 실패',
description: '닉네임은 20자까지 입력해주세요.',
variant: 'destructive',
})
return
}
onChangeHandler(value)
}
setIsEditing((prev) => !prev)
}

return (
<div className="relative flex flex-row items-center justify-center gap-1">
<Input
Expand All @@ -42,12 +66,7 @@ const TextEditable = ({
onChange={onChangeInput}
/>
<Button
onClick={() => {
if (isEditing) {
onChangeHandler(value)
}
setIsEditing((prev) => !prev)
}}
onClick={onSubmit}
variant={isEditing ? 'primary' : null}
size={isEditing ? 'sm' : 'icon_sm'}
className={cn(!isEditing && 'absolute right-0 cursor-pointer')}
Expand Down
8 changes: 4 additions & 4 deletions src/config/appValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export const AppValidation = {
z
.string()
.min(1, { message: '제목을 입력해주세요.' })
.max(50, { message: '제목은 50자 이내로 입력해주세요.' }),
.max(30, { message: '제목은 30자 이내로 입력해주세요.' }),
itemName: () =>
z
.string()
.min(1, { message: '상품명을 입력해주세요.' })
.max(50, { message: '상품명은 50자 이내로 입력해주세요.' }),
.max(30, { message: '상품명은 30자 이내로 입력해주세요.' }),
priceRange: () =>
z.enum(PRICE_RANGE_OBJS.map((range) => range.key) as [string, ...string[]]),
category: () =>
Expand All @@ -27,14 +27,14 @@ export const AppValidation = {
tradeArea: () =>
z
.string()
.max(50, { message: '지역은 50자 이내로 입력해주세요.' })
.max(30, { message: '지역은 30자 이내로 입력해주세요.' })
.nullish(),
pokeAvailable: () => z.boolean(),
content: () =>
z
.string()
.min(5, { message: '5자 이상 입력해주세요.' })
.max(500, { message: '내용은 500자 이내로 입력해주세요.' }),
.max(255, { message: '내용은 255자 이내로 입력해주세요.' }),
images: () =>
z.array(z.string()).min(1, { message: '이미지를 업로드해주세요.' }),
thumbnail: () => z.any(),
Expand Down
6 changes: 2 additions & 4 deletions src/hooks/useDibs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ const useDibs = (isMyDib: boolean, count: number) => {
setDibsCount(dibsCount - 1)
setIsDibsActive(false)
try {
const res = await deleteCardDibs(cardId)
console.log(res)
await deleteCardDibs(cardId)
} catch (error) {
setDibsCount(dibsCount + 1)
setIsDibsActive(true)
Expand All @@ -28,8 +27,7 @@ const useDibs = (isMyDib: boolean, count: number) => {
setDibsCount(dibsCount + 1)
setIsDibsActive(true)
try {
const res = await postCardDibs(cardId)
console.log(res)
await postCardDibs(cardId)
} catch (error) {
setDibsCount(dibsCount - 1)
setIsDibsActive(false)
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const reducer = (state: State, action: Action): State => {
}
}

const listeners: Array<(state: State) => void> = []
const listeners: Array<(_state: State) => void> = []

let memoryState: State = { toasts: [] }

Expand Down
1 change: 0 additions & 1 deletion src/hooks/useValidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const useValidate = () => {
})

useEffect(() => {
console.log(currentUser)
if (isError) {
// Cookies.remove(Environment.tokenName())
// setIsLoggedIn(() => false)
Expand Down
1 change: 0 additions & 1 deletion src/lib/msw/mocks/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { authHandlers } from './authHandlers'
import { cardHandlers } from './cardHandler'
import { dibsHandlers } from './dibsHandlers'
import { historyHandlers } from './historyHandlers'
import { imageHandlers } from './imageHandlers'
Expand Down
2 changes: 1 addition & 1 deletion src/lib/msw/mocks/historyHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const historyHandlers = [
break
}
}
console.log(cursorId)

const currentPage = Number(cursorId)
const PAGE_SIZE = 10
const filterdHistories = histories.filter(
Expand Down
Loading

0 comments on commit 84f80f1

Please sign in to comment.