-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Next.js 14 app router 폴더 구조 개선화 작업 (#44)
* [fix]: yarn -> pnpm settings * [fix]: react-query ssr logic apply * [fix]: yarn -> pnpm 구성하면서 husky 수정 * [feat]: next.js metadata export warning message off * [fix]: 루트 폴더를 app 폴더로 수정 * [fix]: husky * [fix]: 쿠키값 서버사이드에서 가져오게 변경 및 기타 파일 패스수정 * [fix]: 메타데이터 설정 변경 * [refact]: Chat 페이지 폴더구조 최적화 * Revert [fix]: 루트 폴더를 app 폴더로 수정 This reverts commit 115e3fe * [fix]: 사용하지않는 컴포넌트 제거
- Loading branch information
Showing
91 changed files
with
6,031 additions
and
6,539 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/sh | ||
#!/usr/bin/env sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn lint-staged | ||
pnpm lint-staged |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/components/Chat/ChatRoom/ChatMessage.tsx → app/chat/[id]/_components/chat-message.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
'use client'; | ||
import { CameraIcon, UploadIcon } from '@/components/ui/icons/icon'; | ||
import ArrowLeftTailIcon from '@/components/ui/icons/icon/ArrowLeftTail'; | ||
import DotsVerticalIcon from '@/components/ui/icons/icon/DotsVertical'; | ||
import { useAuthStore } from '@/stores/useAuthStore'; | ||
import { useRouter } from 'next/navigation'; | ||
import { useEffect, useRef, useState } from 'react'; | ||
import { useChat } from '../_hooks/use-chat'; | ||
import ChatMessage from './chat-message'; | ||
import styles from './chat-room.module.scss'; | ||
|
||
interface ChatRoomProps { | ||
chatRoomId: string; | ||
storeName: string; | ||
} | ||
|
||
const ChatRoom = ({ chatRoomId, storeName }: ChatRoomProps) => { | ||
const senderUuid = useAuthStore((state) => state.uuid); | ||
const { push } = useRouter(); | ||
|
||
const [chatMessageContent, setChatMessageContent] = useState(''); | ||
|
||
const messageEndRef = useRef<HTMLDivElement>(null); | ||
const textareaRef = useRef<HTMLTextAreaElement>(null); | ||
|
||
const { messages, sendMessage } = useChat(chatRoomId); | ||
|
||
const chatMessageType = 'TEXT'; | ||
|
||
const adjustHeight = () => { | ||
if (textareaRef.current) { | ||
const scrollHeight = textareaRef.current.scrollHeight; | ||
const lineHeight = 29; // leading-[29px]와 일치 | ||
const maxHeight = lineHeight * 2; // 최대 2줄 | ||
textareaRef.current.style.height = `${Math.min(scrollHeight, maxHeight)}px`; | ||
} | ||
}; | ||
|
||
const handleSocketMessage = () => { | ||
sendMessage({ | ||
chatRoomId, | ||
user: senderUuid, | ||
chatMessageType, | ||
chatMessageContent, | ||
}); | ||
setChatMessageContent(''); | ||
}; | ||
|
||
useEffect(() => { | ||
if (textareaRef.current) { | ||
adjustHeight(); | ||
} | ||
if (messageEndRef.current) { | ||
messageEndRef.current.scrollIntoView({ behavior: 'smooth' }); | ||
} | ||
}, [messages]); | ||
|
||
return ( | ||
<> | ||
<div className={styles.ChatRoomHeader}> | ||
<ArrowLeftTailIcon | ||
onClick={() => push('/chat-list')} | ||
width={24} | ||
height={24} | ||
/> | ||
<div className={styles.ChatRoomTitle}> {storeName} </div> | ||
<DotsVerticalIcon width={24} height={24} /> | ||
</div> | ||
<div className={styles.ChatRoomWrapper}> | ||
{messages.map((message) => ( | ||
<ChatMessage | ||
key={message.chatMessageId} | ||
isSender={message.user.uuid === senderUuid} | ||
message={message.chatMessageContent} | ||
// time={message.createdAt} | ||
// imageUrl={message.imageUrl} | ||
/> | ||
))} | ||
<div ref={messageEndRef} /> | ||
</div> | ||
|
||
<div className={styles.ChatInputWrapper}> | ||
<CameraIcon className={styles.CameraIcon} width={24} height={24} /> | ||
<div className={styles.ChatInputContent}> | ||
<textarea | ||
ref={textareaRef} | ||
rows={1} | ||
className={styles.ChatInput} | ||
placeholder="메시지를 입력하세요" | ||
onChange={(e) => setChatMessageContent(e.target.value)} | ||
/> | ||
<UploadIcon | ||
onClick={handleSocketMessage} | ||
className={styles.UploadIcon} | ||
width={20} | ||
height={20} | ||
/> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default ChatRoom; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import ChatRoom from './_components/chat-room'; | ||
|
||
interface ChatPageProps { | ||
params: { | ||
id: string; | ||
}; | ||
searchParams: { | ||
storeName: string; | ||
}; | ||
} | ||
|
||
const ChatPage = ({ params, searchParams }: ChatPageProps) => { | ||
return <ChatRoom chatRoomId={params.id} storeName={searchParams.storeName} />; | ||
}; | ||
|
||
export default ChatPage; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use client'; | ||
import { useChatRooms } from '@/hooks/api/useChat'; | ||
import { useAuthStore } from '@/stores/useAuthStore'; | ||
import { useState } from 'react'; | ||
import styles from './chat-container.module.scss'; | ||
import ChatListEdit from './chat-list-edit/chat-list-edit'; | ||
import ChatList from './chat-list/chat-list'; | ||
|
||
const ChatContainer = () => { | ||
const [isEdit, setIsEdit] = useState(false); | ||
const token = useAuthStore((state) => state.accessToken); | ||
const { data: chatRoomsData } = useChatRooms(token ?? ''); | ||
|
||
return ( | ||
<div className={styles.ChatRoomsWrapper}> | ||
{isEdit ? ( | ||
<ChatListEdit chatRoomsData={chatRoomsData} setIsEdit={setIsEdit} /> | ||
) : ( | ||
<ChatList chatRoomsData={chatRoomsData} setIsEdit={setIsEdit} /> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ChatContainer; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import ChatContainer from './_components/chat-container'; | ||
|
||
export default function ChatsPage() { | ||
return <ChatContainer />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { | ||
QueryClient, | ||
defaultShouldDehydrateQuery, | ||
isServer, | ||
} from '@tanstack/react-query'; | ||
|
||
function makeQueryClient() { | ||
return new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
staleTime: 60 * 1000, | ||
refetchOnMount: false, | ||
refetchOnWindowFocus: false, | ||
}, | ||
dehydrate: { | ||
shouldDehydrateQuery: (query) => | ||
defaultShouldDehydrateQuery(query) || | ||
query.state.status === 'pending', | ||
}, | ||
}, | ||
}); | ||
} | ||
|
||
let browserQueryClient: QueryClient | undefined = undefined; | ||
|
||
export function getQueryClient() { | ||
if (isServer) { | ||
return makeQueryClient(); | ||
} else { | ||
if (!browserQueryClient) browserQueryClient = makeQueryClient(); | ||
return browserQueryClient; | ||
} | ||
} |
Oops, something went wrong.