Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gachi Taxi</title>
<!-- <script
<script
type="text/javascript"
src="https://dapi.kakao.com/v2/maps/sdk.js?appkey=d858f2cf89c907a66f9d4a396414f18f&libraries=services&autoload=false"
></script> -->
></script>
</head>
<body>
<div id="root"></div>
Expand Down
40 changes: 27 additions & 13 deletions src/components/chat/bottomMenu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MenuItem from './MenuItem';
import { MENUITEMS } from '@/constants';
import { useState } from 'react';
import { useEffect, useState } from 'react';
import SendAccountModal from '../modal/sendAccountModal';
import CallTaxiModal from '@/components/modal/CallTaxiModal';
import { useModal } from '@/contexts/ModalContext';
Expand All @@ -15,7 +15,8 @@ import getExitChatRoom from '@/libs/apis/getExitChatRoom';
import useSSEStore from '@/store/useSSEStore';
import useUserStore from '@/store/useUserStore';
import useChattingRoomIdStore from '@/store/useChattingRoomId';
import exitManualMatchingRoom from '@/libs/apis/manual/exitManualMatchingRoom.api';
import { MessagesArray } from 'gachTaxi-types';
//import exitManualMatchingRoom from '@/libs/apis/manual/exitManualMatchingRoom.api';

const BottomMenu = ({
onSendAccount,
Expand All @@ -35,13 +36,26 @@ const BottomMenu = ({
const { user } = useUserStore();
const { setChattingRoomId } = useChattingRoomIdStore();
const accountNumber = user?.accountNumber || '계좌번호 없음';
const { reset } = useTimerStore.getState();
console.log(user?.userId);
console.log(isOwner);

messages.forEach((eventMessage) => {
if (eventMessage.message.topic === 'match_room_created') {
const userId = localStorage.getItem('userId');
setIsOwner(userId === String(eventMessage.message.roomMasterId));
useEffect(() => {
if (messages) {
const eventMessage: MessagesArray | undefined = messages.find(
(event) => event.message.topic === 'match_room_created',
);

if (
eventMessage &&
eventMessage.message.topic === 'match_room_created' &&
user
) {
console.log(eventMessage);
setIsOwner(user.userId === eventMessage.message.roomMasterId);
}
}
});
}, [messages, user]);

const handleSendClick = () => {
if (!user?.accountNumber) {
Expand All @@ -57,16 +71,16 @@ const BottomMenu = ({

const handleExitClick = async () => {
try {
const { reset } = useTimerStore.getState();
const [res, closeRes, closeManual] = await Promise.all([
const [res1, res2] = await Promise.all([
getExitChatRoom(roomId),
getCloseMatching(roomId),
exitManualMatchingRoom(roomId),
// exitManualMatchingRoom(roomId),
]);
if (
res.chatExit.code === 200 &&
closeRes.matchingExit.code === 200 &&
closeManual.code === 200
res1.code >= 200 &&
res1.code < 300 &&
res2.code >= 200 &&
res2.code < 300
) {
closeModal();
reset();
Expand Down
2 changes: 2 additions & 0 deletions src/components/commons/BackButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const BackButton = ({ usedPage }: BackButtonProps) => {
const handleBack = () => {
if (usedPage === 'signUpPage') {
navigate('/');
} else if (usedPage === 'chat') {
navigate('/home');
} else {
navigate(-1);
}
Expand Down
5 changes: 1 addition & 4 deletions src/libs/apis/getCloseMatching.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ export const getCloseMatching = async (roomId: number) => {
const res = await client.post(`/api/matching/auto/cancel`, {
roomId,
});
console.log(res);
return {
matchingExit: res.data,
};
return res.data;
} catch (error) {
throw new Error(`Error in handleExitMatch: ${error}`);
}
Expand Down
6 changes: 2 additions & 4 deletions src/libs/apis/getExitChatRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import client from './clients';

const getExitChatRoom = async (roomId: number) => {
try {
const chatExitResponse = await client.delete(`/api/chat/${roomId}`);
return {
chatExit: chatExitResponse.data,
};
const res = await client.delete(`/api/chat/${roomId}`);
return res.data;
} catch (error) {
throw new Error(`Error get handleExitChatRoom: ${error}`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const ChatPage = () => {
return (
<section className="relative flex-1 w-full flex flex-col h-full max-h-1vh">
<div className="sticky top-0 left-0 p-horizontal bg-darkBlack">
<BackButton />
<BackButton usedPage="chat" />
<div className="flex h-[48px] items-center">
<h1 className="font-bold text-header">채팅방</h1>
<span className="text-captionHeader text-textDarkGray mt-[4px] ml-[3%]">
Expand Down