Skip to content

Commit a66c548

Browse files
authored
Merge pull request #267 from boostcampwm-2024/dev-fe
[MERGE] dev-fe to prod-fe
2 parents 0d451c8 + a58b3b5 commit a66c548

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+866
-306
lines changed

frontend/src/App.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
22
import { ThemeProvider } from 'styled-components';
33
import { theme } from './styles/theme';
4-
import { MainPage, ClientPage, HostPage } from './pages';
4+
import { ClientPage, ErrorPage, HostPage, MainPage, ReplayPage } from './pages';
55
import { QueryClientProvider } from '@tanstack/react-query';
66
import { queryClient } from '@apis/index';
77
import withUserId from '@hocs/withUserId';
8-
import ReplayPage from '@pages/ReplayPage';
98

109
function AppComponent() {
1110
return (
@@ -19,12 +18,10 @@ function AppComponent() {
1918
>
2019
<Routes>
2120
<Route path="/" element={<MainPage />} />
22-
<Route path="/live" element={<ClientPage />} />
2321
<Route path="/live/:id" element={<ClientPage />} />
24-
<Route path="/replay" element={<ReplayPage />} />
2522
<Route path="/replay/:id" element={<ReplayPage />} />
2623
<Route path="/host" element={<HostPage />} />
27-
<Route path="/host/:id" element={<HostPage />} />
24+
<Route path="*" element={<ErrorPage />} />
2825
</Routes>
2926
</Router>
3027
</ThemeProvider>

frontend/src/apis/checkLiveExist.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { AxiosResponse } from 'axios';
2+
import { fetchInstance } from '.';
3+
import { LiveExistenceResponse } from '@type/live';
4+
5+
export const checkLiveExist = async ({ liveId }: { liveId: string }): Promise<LiveExistenceResponse> => {
6+
const response: AxiosResponse<LiveExistenceResponse> = await fetchInstance().get('/streams/existence', {
7+
params: {
8+
sessionKey: liveId
9+
}
10+
});
11+
12+
return response.data;
13+
};

frontend/src/apis/checkReplayExist.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { AxiosResponse } from 'axios';
2+
import { fetchInstance } from '.';
3+
import { ReplayExistenceResponse } from '@type/replay';
4+
5+
export const checkReplayExist = async ({ videoId }: { videoId: string }): Promise<ReplayExistenceResponse> => {
6+
const response: AxiosResponse<ReplayExistenceResponse> = await fetchInstance().get('/replay/existence', {
7+
params: {
8+
videoId
9+
}
10+
});
11+
12+
return response.data;
13+
};

frontend/src/apis/fetchLive.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import { AxiosResponse } from 'axios';
22
import { fetchInstance } from '.';
3-
import { ClientLive } from '@type/live';
3+
import { ClientLiveResponse } from '@type/live';
44

5-
type ClientLiveResponse = {
6-
info: ClientLive;
7-
};
8-
9-
export const fetchLive = async ({ liveId }: { liveId: string }): Promise<ClientLive> => {
10-
const response: AxiosResponse<ClientLiveResponse> = await fetchInstance().get('/streams/live', {
11-
params: {
12-
liveId
5+
export const fetchLive = async ({ liveId }: { liveId: string }): Promise<ClientLiveResponse> => {
6+
try {
7+
const response: AxiosResponse = await fetchInstance().get('/streams/live', {
8+
params: { liveId }
9+
});
10+
return response.data;
11+
} catch (error: any) {
12+
if (error.response && error.response.status === 400) {
13+
console.log('error', error);
14+
throw error;
1315
}
14-
});
15-
16-
return response.data.info;
16+
throw error;
17+
}
1718
};

frontend/src/apis/fetchReplay.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import { AxiosResponse } from 'axios';
22
import { fetchInstance } from '.';
3-
import { ReplayStream } from '@type/replay';
3+
import { ClientReplayResponse } from '@type/replay';
44

5-
type ReplayStreamResponse = {
6-
info: ReplayStream;
7-
};
8-
9-
export const fetchReplay = async ({ videoId }: { videoId: string }): Promise<ReplayStream> => {
10-
const response: AxiosResponse<ReplayStreamResponse> = await fetchInstance().get('/replay/video', {
11-
params: {
12-
videoId
5+
export const fetchReplay = async ({ videoId }: { videoId: string }): Promise<ClientReplayResponse> => {
6+
try {
7+
const response: AxiosResponse = await fetchInstance().get('/replay/video', {
8+
params: {
9+
videoId
10+
}
11+
});
12+
return response.data;
13+
} catch (error: any) {
14+
if (error.response && error.response.status === 400) {
15+
console.log('error', error);
16+
throw error;
1317
}
14-
});
15-
16-
return response.data.info;
18+
throw error;
19+
}
1720
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { useQuery } from '@tanstack/react-query';
2+
3+
import { checkLiveExist } from '@apis/checkLiveExist';
4+
import { LiveExistenceResponse } from '@type/live';
5+
6+
export const useCheckLiveExist = ({ liveId }: { liveId: string }) => {
7+
return useQuery<LiveExistenceResponse, Error>({
8+
queryKey: ['checkLiveExist'],
9+
queryFn: () => checkLiveExist({ liveId }),
10+
refetchOnWindowFocus: false,
11+
initialData: { existed: true }
12+
});
13+
};
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { useQuery } from '@tanstack/react-query';
2-
32
import { fetchLive } from '@apis/fetchLive';
4-
import { ClientLive } from '@type/live';
3+
import { ClientLive, ClientLiveResponse } from '@type/live';
54

65
export const useClientLive = ({ liveId }: { liveId: string }) => {
7-
return useQuery<ClientLive, Error>({
6+
return useQuery<ClientLiveResponse, Error>({
87
queryKey: ['clientLive'],
9-
queryFn: () => fetchLive({ liveId: liveId }),
10-
refetchOnWindowFocus: false
8+
queryFn: () => fetchLive({ liveId }),
9+
refetchOnWindowFocus: false,
10+
initialData: { info: {} as ClientLive },
11+
throwOnError: true,
12+
retry: 0,
1113
});
1214
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { useQuery } from '@tanstack/react-query';
2+
3+
import { checkReplayExist } from '@apis/checkReplayExist';
4+
import { ReplayExistenceResponse } from '@type/replay';
5+
6+
export const useCheckReplayExist = ({ videoId }: { videoId: string }) => {
7+
return useQuery<ReplayExistenceResponse, Error>({
8+
queryKey: ['checkReplayExist'],
9+
queryFn: () => checkReplayExist({ videoId }),
10+
refetchOnWindowFocus: false,
11+
initialData: { existed: true }
12+
});
13+
};
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import { useQuery } from '@tanstack/react-query';
22

33
import { fetchReplay } from '@apis/fetchReplay';
4-
import { ReplayStream } from '@type/replay';
4+
import { ClientReplayResponse, ReplayStream } from '@type/replay';
55

66
export const useClientReplay = ({ videoId }: { videoId: string }) => {
7-
return useQuery<ReplayStream, Error>({
7+
return useQuery<ClientReplayResponse, Error>({
88
queryKey: ['clientReplay'],
9-
queryFn: () => fetchReplay({ videoId: videoId }),
10-
refetchOnWindowFocus: false
9+
queryFn: () => fetchReplay({ videoId }),
10+
refetchOnWindowFocus: false,
11+
initialData: { info: {} as ReplayStream },
12+
throwOnError: true,
13+
retry: 0
1114
});
1215
};
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

frontend/src/components/chat/ChatInput.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import SpeakerIcon from '@assets/icons/speaker.svg';
55
import SendIcon from '@assets/icons/send.svg';
66
import { useRef, useEffect, useState, ChangeEvent, KeyboardEvent, memo } from 'react';
77
import { CHATTING_SOCKET_SEND_EVENT, CHATTING_TYPES } from '@constants/chat';
8-
import { ChattingTypes } from '@type/chat';
8+
import { ChattingSendTypes } from '@type/chat';
99
import { getStoredId } from '@utils/id';
1010
import { UserType } from '@type/user';
1111

@@ -20,7 +20,7 @@ const INITIAL_TEXTAREA_HEIGHT = 20;
2020
export const ChatInput = ({ worker, userType, roomId }: ChatInputProps) => {
2121
const [hasInput, setHasInput] = useState(false);
2222
const [isFocused, setIsFocused] = useState(false);
23-
const [msgType, setMsgType] = useState<ChattingTypes>(CHATTING_TYPES.NORMAL);
23+
const [msgType, setMsgType] = useState<ChattingSendTypes>(CHATTING_TYPES.NORMAL);
2424
const [message, setMessage] = useState('');
2525
const textareaRef = useRef<HTMLTextAreaElement | null>(null);
2626

0 commit comments

Comments
 (0)