Skip to content

Commit a0a79f6

Browse files
authored
Merge branch 'dev' into feat/OD-201
2 parents 2b5d4ba + ddc77ee commit a0a79f6

25 files changed

Lines changed: 166 additions & 163 deletions

File tree

src/App.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import { BrowserRouter, Route, Routes, Navigate } from 'react-router-dom';
33

44
import Home from '@pages/Home';
@@ -28,9 +28,35 @@ import ChatRoom from '@pages/Chats/ChatRoom';
2828
import MatchingRoom from '@pages/Chats/MatchingRoom';
2929

3030
import NotFound from '@pages/NotFound';
31+
import { getUserInfoApi } from '@apis/user';
32+
import { getCurrentUserId } from '@utils/getCurrentUserId';
33+
import Loading from '@components/Loading';
3134

3235
const ProtectedRoute = ({ children }: { children: JSX.Element }) => {
33-
const isAuthenticated = Boolean(localStorage.getItem('new_jwt_token'));
36+
const [isAuthenticated, setIsAuthenticated] = useState<boolean | null>(null);
37+
38+
useEffect(() => {
39+
const checkAuth = async () => {
40+
try {
41+
const currentUserId = getCurrentUserId();
42+
if (!currentUserId) {
43+
setIsAuthenticated(false);
44+
return;
45+
}
46+
47+
const response = await getUserInfoApi(currentUserId);
48+
setIsAuthenticated(response.isSuccess);
49+
} catch (error) {
50+
setIsAuthenticated(false);
51+
}
52+
};
53+
checkAuth();
54+
}, []);
55+
56+
if (isAuthenticated === null) {
57+
return <Loading />;
58+
}
59+
3460
return isAuthenticated ? children : <Navigate to="/login" />;
3561
};
3662

src/apis/matching/dto.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type { BaseSuccessResponse } from '@apis/core/dto';
2-
31
type RequestStatusEnum = 'accepted' | 'rejected' | 'pending';
42

53
// 매칭 요청
@@ -10,16 +8,6 @@ export interface CreateMatchingRequest {
108
message: string;
119
}
1210

13-
// response
14-
export type CreateMatchingResponse = BaseSuccessResponse<CreateMatchingData>;
15-
16-
export interface CreateMatchingData {
17-
id: number; // matchingId
18-
chatRoomId: number;
19-
requesterId: number;
20-
targetId: number;
21-
}
22-
2311
// 최근 매칭 조회 (채팅방 리스트에서)
2412
export interface LatestMatchingData {
2513
id?: number;
@@ -56,20 +44,3 @@ export interface PostImageDto {
5644
url: string;
5745
orderNum: number;
5846
}
59-
60-
// 매칭 요청 수락 및 거절
61-
// request
62-
export interface ModifyMatchingStatusRequest {
63-
requestStatus: 'accept' | 'reject';
64-
}
65-
66-
// response
67-
export type ModifyMatchingStatusResponse = BaseSuccessResponse<ModifyMatchingStatusData>;
68-
69-
export interface ModifyMatchingStatusData {
70-
id: number; // matchingId
71-
requesterId: number;
72-
targetId: number;
73-
requestStatus: string;
74-
chatRoomId: number;
75-
}

src/apis/matching/index.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/pages/Account/AccountCancel/styles.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,30 @@ export const SubTitle = styled.h3`
1616
margin-bottom: 0.625rem;
1717
text-align: center;
1818
text-align: left;
19-
margin-top: 10px;
19+
margin-top: 0.625rem;
2020
padding: 1.25rem;
2121
`;
2222

2323
export const Text = styled.p`
2424
font-size: 0.875rem;
25-
margin-bottom: 5px;
25+
margin-bottom: 0.3125rem;
2626
text-align: left;
27-
margin-top: 10px;
27+
margin-top: 0.625rem;
2828
padding: 0rem 1.25rem;
2929
`;
3030

3131
export const InfoBox = styled.div`
3232
background: ${({ theme }) => theme.colors.background.secondary};
33-
padding: 70px;
34-
margin-top: 10px;
35-
border-radius: 10px;
36-
margin: 10px 20px 1.25rem 20px;
33+
padding: 4.375rem;
34+
margin-top: 0.625rem;
35+
border-radius: 0.625rem;
36+
margin: 0.625rem 1.25rem 1.25rem 1.25rem;
3737
`;
3838

3939
export const InfoItem = styled.p`
4040
font-size: 0.875rem;
4141
margin-bottom: 0.625rem;
42-
padding: 2px 10px;
42+
padding: 0.125rem 0.625rem;
4343
display: flex;
4444
justify-content: center;
4545
align-items: center;
@@ -51,7 +51,7 @@ export const CheckboxWrapper = styled.div`
5151
display: flex;
5252
align-items: center;
5353
margin-bottom: 1.25rem;
54-
padding: 0rem 15px;
54+
padding: 0rem 0.9375rem;
5555
5656
input[type='checkbox'] {
5757
margin-right: 0.625rem;

src/pages/Account/AccountEdit/styles.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { styled } from 'styled-components';
22

33
export const ProfileEditContainer = styled.div`
4-
max-width: 512px;
4+
max-width: 32rem;
55
display: flex;
66
flex-direction: column;
77
position: relative;
@@ -11,7 +11,7 @@ export const Section = styled.div`
1111
margin-top: 1.875rem;
1212
margin-bottom: 1.875rem;
1313
width: 100%;
14-
padding: 0px 30px;
14+
padding: 0rem 1.875rem;
1515
`;
1616

1717
export const SectionTitle = styled.div`
@@ -62,7 +62,7 @@ export const SnsConnection = styled.div`
6262
export const MemberInfo = styled.div`
6363
display: flex;
6464
flex-direction: column;
65-
margin-top: 35px;
65+
margin-top: 2.1875rem;
6666
width: 100%;
6767
`;
6868

@@ -71,7 +71,7 @@ export const MemberInfoRow = styled.div`
7171
align-items: center;
7272
justify-content: flex-start;
7373
margin-bottom: 0.625rem;
74-
margin-top: 10px;
74+
margin-top: 0.625rem;
7575
`;
7676

7777
export const Label = styled.div`

src/pages/Account/AccountSetting/styles.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,16 @@ export const List = styled.ul`
5656
padding: 0;
5757
margin: 0;
5858
list-style: none;
59-
border-top: 0px solid ${({ theme }) => theme.colors.background.divider};
59+
border-top: 0rem solid ${({ theme }) => theme.colors.background.divider};
6060
position: absolute;
61-
bottom: 20px;
61+
bottom: 1.25rem;
6262
`;
6363

6464
export const ListItem = styled.li`
6565
display: flex;
6666
align-items: center;
6767
padding: 15px 10px;
68+
6869
border-bottom: 0px solid ${({ theme }) => theme.colors.background.divider};
6970
cursor: pointer;
7071

src/pages/Chats/MatchingRoom/Card/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const Card: React.FC<CardProps> = ({ requester }) => {
3030
</ProfileImgBox>
3131
<ProfileInfo>
3232
<StyledText
33-
$textTheme={{ style: 'body1-medium' }}
33+
$textTheme={{ style: 'body2-medium' }}
3434
color={theme.colors.text.primary}
3535
onClick={handleUserClick}
3636
>
@@ -39,7 +39,7 @@ const Card: React.FC<CardProps> = ({ requester }) => {
3939
<div className="row-flex">
4040
{requester.representativePost.styleTags.map((tag, index) => (
4141
<div className="row-flex" key={tag}>
42-
<StyledText $textTheme={{ style: 'caption2-regular' }} color={theme.colors.gray[200]}>
42+
<StyledText $textTheme={{ style: 'caption2-regular' }} color={theme.colors.gray[600]}>
4343
{tag}
4444
</StyledText>
4545
{index < requester.representativePost.styleTags.length - 1 && (

src/pages/Chats/MatchingRoom/MatchingMessage/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import dayjs from 'dayjs';
22

33
import RcvdMessage from '@pages/Chats/RcvdMessage';
44

5+
import defaultProfile from '@assets/default/defaultProfile.svg';
6+
57
import type { MatchingData } from '@apis/matching/dto';
68
import type { RcvdMessageProps } from '@pages/Chats/RcvdMessage/dto';
79

@@ -14,7 +16,7 @@ const MatchingMessage: React.FC<MatchingData> = ({ id, message, createdAt, chatR
1416

1517
const firstMessageProps: RcvdMessageProps = {
1618
fromUserNickname: '오딩이',
17-
profilePictureUrl: '',
19+
profilePictureUrl: defaultProfile,
1820
content: '얘가 너 소개받고 싶대',
1921
isSenderChanged: false,
2022
isProfileImageVisible: true,
@@ -24,7 +26,7 @@ const MatchingMessage: React.FC<MatchingData> = ({ id, message, createdAt, chatR
2426

2527
const matchingMessageProps: RcvdMessageProps = {
2628
fromUserNickname: '오딩이',
27-
profilePictureUrl: '',
29+
profilePictureUrl: defaultProfile,
2830
content: message,
2931
isSenderChanged: false,
3032
isProfileImageVisible: false,

src/pages/Chats/MatchingRoom/NoMatchingMessage/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import dayjs from 'dayjs';
22

33
import RcvdMessage from '@pages/Chats/RcvdMessage';
44

5+
import defaultProfile from '@assets/default/defaultProfile.svg';
6+
57
import type { RcvdMessageProps } from '@pages/Chats/RcvdMessage/dto';
68

79
const NoMatchingMessage: React.FC = () => {
810
const formattedTime = dayjs(new Date()).format('HH:mm');
911

1012
const messageProps: RcvdMessageProps = {
1113
fromUserNickname: '오딩이',
12-
profilePictureUrl: '',
14+
profilePictureUrl: defaultProfile,
1315
content: '매칭이 들어오면 오딩이가 알려줄게!',
1416
isSenderChanged: true,
1517
isProfileImageVisible: true,

src/pages/Chats/MatchingRoom/ResponseMessage/index.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
import { useNavigate } from 'react-router-dom';
22

3+
import { useRecoilState } from 'recoil';
4+
5+
import theme from '@styles/theme';
6+
7+
import { RequesterDto } from '@apis/matching/dto';
38
import { useSocket } from '@context/SocketProvider';
9+
import { OtherUserAtom } from '@recoil/util/OtherUser';
10+
11+
import { StyledText } from '@components/Text/StyledText';
412

513
import { ResponseButton, ResponseContainer } from './styles';
614

715
export interface ResponseMessageProps {
816
matchingId: number;
917
chatRoomId: number;
18+
requester: Omit<RequesterDto, 'RepresentativePostDto'>;
1019
requestStatus: 'accepted' | 'rejected' | 'pending';
1120
}
1221

13-
const ResponseMessage: React.FC<ResponseMessageProps> = ({ matchingId, chatRoomId, requestStatus }) => {
22+
const ResponseMessage: React.FC<ResponseMessageProps> = ({ matchingId, chatRoomId, requester, requestStatus }) => {
1423
const socket = useSocket('matching');
1524
const isPending = requestStatus === 'pending';
1625
const nav = useNavigate();
26+
const [, setOtherUser] = useRecoilState(OtherUserAtom);
1727

1828
const handlebuttonClick = (status: 'accept' | 'reject') => {
1929
if (requestStatus !== 'pending') return;
2030
if (socket) {
2131
socket.emit('patchMatching', { id: matchingId, requestStatus: status });
2232
if (status === 'accept') {
33+
setOtherUser(requester);
2334
nav(`/chats/${chatRoomId}`);
2435
}
2536
}
@@ -29,12 +40,16 @@ const ResponseMessage: React.FC<ResponseMessageProps> = ({ matchingId, chatRoomI
2940
<ResponseContainer>
3041
{(requestStatus === 'pending' || requestStatus === 'rejected') && (
3142
<ResponseButton $isPending={isPending} onClick={() => handlebuttonClick('reject')}>
32-
거절
43+
<StyledText $textTheme={{ style: 'body2-regular' }} color={theme.colors.text.primary}>
44+
거절
45+
</StyledText>
3346
</ResponseButton>
3447
)}
3548
{(requestStatus === 'pending' || requestStatus === 'accepted') && (
3649
<ResponseButton $isPending={isPending} onClick={() => handlebuttonClick('accept')}>
37-
수락
50+
<StyledText $textTheme={{ style: 'body2-regular' }} color={theme.colors.text.primary}>
51+
수락
52+
</StyledText>
3853
</ResponseButton>
3954
)}
4055
</ResponseContainer>

0 commit comments

Comments
 (0)