Skip to content

Commit

Permalink
✨ 라우팅 및 컴포넌트 위치 조정
Browse files Browse the repository at this point in the history
  • Loading branch information
oaoong committed Nov 29, 2023
1 parent 4438059 commit be291ba
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 23 deletions.
5 changes: 3 additions & 2 deletions src/app/(root)/(routes)/cards/new/hooks/useCardUploadForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useForm } from 'react-hook-form'
import { zodResolver } from '@hookform/resolvers/zod'
import { useRouter } from 'next/navigation'
import { z } from 'zod'
import AppPath from '@/config/appPath'
import { AppValidation } from '@/config/appValidation'
import { useToast } from '@/hooks/useToast'
import { postCard } from '@/services/card/card'
Expand Down Expand Up @@ -49,12 +50,12 @@ export const useCardUploadForm = () => {
setIsSubmitting(() => true)

try {
await postCard(data)
const res = await postCard(data)
toast({
title: 'Success',
description: '게시글을 업로드했습니다.',
})
router.back()
router.push(AppPath.card(res.data.cardInfo.cardId), { scroll: false })
} catch (error: any) {
toast({
variant: 'destructive',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type ChatProps = {
const ChatList = forwardRef<HTMLDivElement, ChatListProps>(
({ messages, currentUserId }, ref) => {
return (
<ul className="flex flex-col w-full h-full gap-1">
<ul className="flex flex-col w-full h-full gap-1 ">
{messages.map((message: Message) => {
return (
<Chat
Expand Down
3 changes: 2 additions & 1 deletion src/app/(root)/(routes)/chatrooms/[chatRoomId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const ChatPage = async ({ params }: ChatPageProps) => {
).cardInfo.cardId

return (
<main className="relative flex flex-col items-center w-full gap-10 h-page pb-chat_input">
<main className="relative flex flex-col items-center w-full h-page pb-chat_input">
<header className="flex flex-row items-center w-full px-4">
<PageTitle title="채팅방" />
{!isCompleteRequested && (
Expand All @@ -100,6 +100,7 @@ const ChatPage = async ({ params }: ChatPageProps) => {
completeRequestData={completeRequestInfo}
/>
)}
<div className="w-full h-0 my-5 border border-b-0 opacity-50 border-background-secondary-color" />
<ChatRoomTemplate
currentUser={initialUserInfo}
fireStoreId={initialChatRoom.fireStoreChatRoomId}
Expand Down
2 changes: 1 addition & 1 deletion src/components/domain/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const Header = async () => {
return (
<header className="absolute top-0 left-0 z-10 grid items-center justify-between w-full grid-cols-3 px-2 h-nav shadow-bottom bg-background-color">
<section className="flex items-center justify-start">
<MenuButton />
<MenuButton isLoggedIn={!!userInfo} />
</section>
<section className="flex items-center justify-center">
<Logo />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ const AvatarWithDropdown = ({ imageUrl }: { imageUrl?: string }) => {
router.push(AppPath.mypage())
}}
>
프로필
마이페이지
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => {
router.push(AppPath.newCard())
}}
>
새 물건 등록하기
</DropdownMenuItem>
<DropdownMenuItem onClick={onClickLogout}>로그아웃</DropdownMenuItem>
</DropdownMenuGroup>
Expand Down
53 changes: 36 additions & 17 deletions src/components/domain/header/components/MenuButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import {
import AppPath from '@/config/appPath'
import Assets from '@/config/assets'

const MenuButton = () => {
const MenuButton = ({ isLoggedIn }: { isLoggedIn: boolean }) => {
const router = useRouter()

return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button className="dark:bg-white" size="icon" variant={null}>
<Image src={Assets.menuIcon} alt="menu" />
<Button className="dark:bg-white" variant={null}>
<Image className="w-7 h-7" src={Assets.menuIcon} alt="menu" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent>
Expand All @@ -31,20 +32,38 @@ const MenuButton = () => {
>
전체 물건 보기
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => {
router.push(AppPath.newCard())
}}
>
상품 등록
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => {
router.push(AppPath.chatRooms())
}}
>
채팅방 조회
</DropdownMenuItem>
{isLoggedIn && (
<>
<DropdownMenuItem
onClick={() => {
router.push(AppPath.myCards())
}}
>
내 물건 목록
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => {
router.push(AppPath.myDibs())
}}
>
내 찜 목록
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => {
router.push(AppPath.myHistory())
}}
>
거래 내역 보기
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => {
router.push(AppPath.chatRooms())
}}
>
채팅 목록
</DropdownMenuItem>
</>
)}
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenu>
Expand Down

0 comments on commit be291ba

Please sign in to comment.