Skip to content

Commit

Permalink
๐Ÿ”ง Fix : ์ฑ„ํŒ… ๋ฐ ๋ฒ„๊ทธ ๊ฐœ์„ 
Browse files Browse the repository at this point in the history
๐Ÿ”ง Fix : ์ฑ„ํŒ… ๋ฐ ๋ฒ„๊ทธ ๊ฐœ์„ 
  • Loading branch information
eunjju2 authored Dec 9, 2024
2 parents 159608c + fe4e35c commit 6333632
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 37 deletions.
7 changes: 2 additions & 5 deletions src/pages/ChatListPage/components/ChatCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ const ChatCard = (props: ChatCardProps) => {
>
<div className='flex w-full flex-col gap-[10px]'>
<div className='flex items-center justify-between'>
<button
type='button'
className='flex items-center gap-1 text-sm font-medium'
>
<div className='flex items-center gap-1 text-sm font-medium'>
{userName} <GrNext className='text-xs' />
</button>
</div>
<span className='text-xs text-subfont'>
{getDateFunction(chat.updatedAt)}
</span>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ChatListPage/hooks/useGetChatList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const useGetChatList = () => {
role === 'ROLE_USER' ? getChatListMember : getChatListBusiness;
const { data, isLoading, isError } = useQuery<
ChatListMember[] | ChatListBusiness[]
>({ queryKey, queryFn });
>({ queryKey, queryFn, refetchOnWindowFocus: true });

return { data: data ?? [], isLoading, isError };
};
Expand Down
1 change: 0 additions & 1 deletion src/pages/ChatListPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import useGetChatList from './hooks/useGetChatList';

const ChatListPage = () => {
const { data } = useGetChatList();

return (
<>
<MainLayout headerType='both'>
Expand Down
13 changes: 8 additions & 5 deletions src/pages/ChatPage/components/MessageContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,25 @@ const MessageContainer = (props: MessageContainerProps) => {
<>
{messages &&
messages.length > 0 &&
Object.entries(groupedMessages).map(([date, dateMessages]) => (
Object.entries(groupedMessages).map(([date, dateMessages], index) => (
<div
key={date}
// eslint-disable-next-line react/no-array-index-key
key={index}
className='mb-4 mt-8 flex w-custom flex-col items-center justify-end gap-5'
>
<div className='text-xs text-subfont underline'>{date}</div>

{dateMessages.map((message) =>
{dateMessages.map((message, idx) =>
message.sender === user ? (
<SendMessage
key={message.timestamp}
// eslint-disable-next-line react/no-array-index-key
key={idx}
message={message}
/>
) : (
<ReceiveMessage
key={message.timestamp}
// eslint-disable-next-line react/no-array-index-key
key={idx}
message={message}
/>
),
Expand Down
7 changes: 1 addition & 6 deletions src/pages/ChatPage/components/ReceiveMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ const ReceiveMessage = (props: ReceiveMessageProps) => {
<div className='max-w-60 rounded-t-xl rounded-br-xl bg-[#EEEEEE] px-3 py-2 text-sm'>
{message.content}
</div>
<div>
{!message.isRead && (
<p className='text-start text-xs text-primary'>1</p>
)}
<p className='text-xs text-subfont'>{formattedTime}</p>
</div>
<p className='text-xs text-subfont'>{formattedTime}</p>
</div>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ChatPage/components/SendMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const SendMessage = (props: SendMessageProps) => {
<div className='flex w-custom justify-end'>
<div className='flex items-end gap-2'>
<div>
{!message.isRead && (
{/* {!message.isRead && (
<p className='text-end text-xs text-primary'>1</p>
)}
)} */}
<p className='text-xs text-subfont'>{formattedTime}</p>
</div>
<div className='max-w-60 rounded-t-xl rounded-bl-xl bg-primary px-3 py-2 text-sm text-white'>
Expand Down
12 changes: 3 additions & 9 deletions src/pages/ChatPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { getRole } from '@utils/auth';
import { getUserData } from '@apis/member';
import { getBusinessData } from '@apis/business';
import { getDatetoLocalDate } from '@utils/formatTime';
import { toast } from 'react-toastify';
import MessageInput from './components/MessageInput';
import MessageContainer from './components/MessageContainer';

Expand Down Expand Up @@ -52,34 +53,29 @@ const ChatPage = () => {
const client = new Client({
brokerURL: WS_URL,
webSocketFactory: () => new SockJS(WS_URL),
debug: (str) => console.log(str),
reconnectDelay: 5000, // ์ž๋™ ์žฌ์—ฐ๊ฒฐ
});

// ๊ตฌ๋…
client.onConnect = () => {
console.log('Connected');

client.subscribe(`/sub/chat/${roomId}`, (message: IMessage) => {
try {
const newMessage = JSON.parse(message.body);
setMessages((prevMessages) => [...prevMessages, newMessage]);
console.log('์™„๋ฃŒ');
} catch (error) {
console.error('์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค:', error);
toast.error('์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.');
}
});
};

client.activate();
setStompClient(client);
} catch (err) {
console.error(err);
toast.error('์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.');
}
};

const disConnect = () => {
console.log('์—ฐ๊ฒฐ๋Š๊ธฐ');
// ์—ฐ๊ฒฐ ๋Š๊ธฐ
if (stompClient === null) {
return;
Expand All @@ -101,8 +97,6 @@ const ChatPage = () => {
destination: '/pub/sendMessage',
body: JSON.stringify(chatMessage),
});
console.log(chatMessage);
console.log(messages);
}
};

Expand Down
1 change: 0 additions & 1 deletion src/pages/ModifySpace/components/RoomModify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ const RoomModify = ({ room, updateRoomData, completeAdd }: RoomFormProps) => {
).then((roomImageS3URL) => uploadImageToS3(roomImageS3URL, file!)),
),
);
console.log(room.roomName);
} else {
// ๋ฃธ ์ˆ˜์ •
await putRoom({
Expand Down
4 changes: 0 additions & 4 deletions src/pages/ModifySpace/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ const ModifySpace = () => {
const { workplaceId } = useParams() as { workplaceId: string };
const { data: info } = useGetWorkPlaceInfo(Number(workplaceId));
const { data: roomInfo } = useGetRoomListInfo(Number(workplaceId));
console.log(info);
console.log(roomInfo);

// ๊ณต๊ฐ„ ๋“ฑ๋ก + ๋ฃธ ํผ ์ƒํƒœ๊ด€๋ฆฌ
const [spaceFormData, setSpaceFormData] = useState<Space>({
Expand All @@ -31,8 +29,6 @@ const ModifySpace = () => {
rooms: [],
});

console.log(spaceFormData);

useEffect(() => {
if (info && roomInfo) {
const [basic, ...detailParts] = info.workplaceAddress.split(',');
Expand Down
5 changes: 3 additions & 2 deletions src/pages/SearchResult/components/ResultBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const ResultBar = () => {
return newTimeArray;
};

const formattedTime = setTimeArray(searchTime).join(' ~ ');
const formattedTime =
searchTime.length > 0 ? setTimeArray(searchTime).join(' ~ ') : '์‹œ๊ฐ„ ์„ ํƒ';

return (
<div className='mx-auto mt-4 flex w-custom justify-center gap-1 rounded-full py-[18px] text-sm shadow-custom'>
Expand All @@ -27,7 +28,7 @@ const ResultBar = () => {
className='w-16 overflow-hidden text-ellipsis whitespace-nowrap border-r-2 border-subfont pr-1 text-center'
onClick={() => navigate('/search', { state: true })}
>
{searchPlace}
{searchPlace.length > 0 ? searchPlace : '์žฅ์†Œ ์„ ํƒ'}
</button>
<button
type='button'
Expand Down
12 changes: 12 additions & 0 deletions src/pages/SearchResult/hooks/useGetSearchStudyRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@ import { useQuery } from '@tanstack/react-query';
import { SearchStudyRoom, SearchStudyRoomData } from '@typings/types';

export const useGetSearchStudyRoom = (searchStudyRoom: SearchStudyRoom) => {
const { address, startDateTime, endDateTime, reservationCapacity } =
searchStudyRoom;
const isValidDateTime = (dateTime: string | undefined) =>
!!dateTime && !dateTime.includes('undefined');

const isQueryEnabled =
!!address &&
reservationCapacity > 0 &&
isValidDateTime(startDateTime) &&
isValidDateTime(endDateTime);

const { data, isLoading, isError } = useQuery<SearchStudyRoomData[]>({
queryKey: ['searchStudyRoom', searchStudyRoom.address],
queryFn: () => postSearchStudyRoom(searchStudyRoom),
enabled: isQueryEnabled,
});

return { data: (data ?? []) as SearchStudyRoomData[], isLoading, isError };
Expand Down
1 change: 0 additions & 1 deletion src/pages/WriteReviewPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const WriteReviewPage = () => {
const location = useLocation();
const reservationInfo: WriteReviewProps = { ...location.state };
const { reservationId, workPlaceName } = reservationInfo;
console.log(reservationId);

return (
<MainLayout>
Expand Down

0 comments on commit 6333632

Please sign in to comment.