Skip to content

Commit

Permalink
[ALL] 하루스터디 v1.2.1 배포 🎉(#713)
Browse files Browse the repository at this point in the history
[ALL] 하루스터디 v1.2.1 배포 🎉
  • Loading branch information
woo-jk authored Oct 31, 2023
2 parents 54c8252 + e0def49 commit ea1f750
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion frontend/src/api/httpInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const http = new Http(API_BASE_URL, { headers: { 'Content-Type': 'application/js
const refreshAndRefetch = async <T extends object>(response: HttpResponse<T>) => {
const {
data: { accessToken },
} = await http.post<{ accessToken: string }>('/api/auth/refresh');
} = await http.post<{ accessToken: string }>('/auth/refresh');

tokenStorage.setAccessToken(accessToken);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { styled } from 'styled-components';
import Button from '@Components/common/Button/Button';
import ParticipantCodeCopier from '@Components/lobby/ParticipantCodeCopier/ParticipantCodeCopier';

import useConfirmBeforeRouting from '@Hooks/common/useRouteBlocker';
import useConfirmBeforeRouting from '@Hooks/common/useConfirmBerforeRouting';

import { ROUTES_PATH } from '@Constants/routes';

Expand All @@ -30,7 +30,6 @@ const StudyLobbyContents = () => {

const navigateToHome = () => {
navigate(ROUTES_PATH.landing);
console.log(132);
};

const handleStartStudy = async () => {
Expand Down
17 changes: 15 additions & 2 deletions frontend/src/components/progress/StudyBoard/StudyBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import { styled } from 'styled-components';
import LoadingFallback from '@Components/common/LodingFallback/LoadingFallback';
import NotificationBoundary from '@Components/common/NotificationBoundary/NotificationBoundary';

import useConfirmBeforeRouting from '@Hooks/common/useConfirmBerforeRouting';

import color from '@Styles/color';

import { FAVICON_PATH } from '@Constants/asset';
import { ROUTES_PATH } from '@Constants/routes';

import { useModal } from '@Contexts/ModalProvider';
import { useNotification } from '@Contexts/NotificationProvider';
import { useStudyInfo } from '@Contexts/StudyProgressProvider';

Expand All @@ -32,17 +35,20 @@ const StudyBoard = () => {
const navigate = useNavigate();
const { studyId, name, studyStep, progressStep } = useStudyInfo();
const { send } = useNotification();
const { closeModal } = useModal();

useEffect(() => {
closeModal();

if (studyStep === 'waiting') {
send({ message: '스터디가 아직 시작되지 않았습니다.\n스터디 대기방으로 이동합니다.' });
navigate(`${ROUTES_PATH.lobby}/${studyId}`, { state: { studyName: name } });
navigate(`${ROUTES_PATH.lobby}/${studyId}`, { state: { studyName: name, block: false } });
return;
}

if (studyStep === 'done') {
send({ message: '스터디가 종료되었습니다.\n스터디 기록 페이지로 이동합니다.' });
navigate(`${ROUTES_PATH.record}/${studyId}`);
navigate(`${ROUTES_PATH.record}/${studyId}`, { state: { block: false } });
return;
}

Expand All @@ -52,6 +58,13 @@ const StudyBoard = () => {
return () => dom.updateFavicon(FAVICON_PATH.default);
}, [progressStep, studyStep]);

useConfirmBeforeRouting(
'정말로 진행중인 스터디를 나가시겠습니까?\n스터디를 종료할 경우, 메인페이지로 이동합니다.',
() => {
navigate(ROUTES_PATH.landing, { state: { block: false } });
},
);

return (
<Container>
<Sidebar />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,19 @@ const StudyInfoModal = ({ studyInfo }: Props) => {
const { studyId, name, totalCycle, timePerCycle, currentCycle, progressStep } = studyInfo;

const navigate = useNavigate();
const { openConfirm, closeModal } = useModal();
const { closeModal } = useModal();

const { result: studySubmitStatus } = useFetch(
async () => {
const { data } = await requestGetMemberSubmitStatus(studyId);

return data.status;
},
{ suspense: false, refetchInterval: 2000 },
{ suspense: false, refetchInterval: 2000, errorBoundary: false },
);

const handleExitStudy = () => {
closeModal();
openConfirm('정말로 진행 중인 스터디를 나가시겠습니까?', () => {
navigate(ROUTES_PATH.landing);
closeModal();
});
navigate(ROUTES_PATH.landing);
};

const getSubmitStatusText = (progressStep: Step, isSubmitted: boolean) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const useConfirmBeforeRouting = (message: string, onConfirm?: () => void) => {
if (state?.block === false) return false;

openConfirm(message, () => {
onConfirm?.();
navigate(nextLocation, { state: { block: false } });
onConfirm?.();
});

return true;
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/utils/Http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@ class Http {
}

request<T extends object = object>(url: string, config: RequestInit) {
if (!url.startsWith('http')) {
url = `${this.baseURL}${url}`;
}

config = { ...this.defaultConfig, ...this.interceptor.onRequest(config) };
config.headers = { ...this.defaultConfig.headers, ...config.headers };

try {
return fetch(`${this.baseURL}${url}`, config)
return fetch(url, config)
.then((response) => processHttpResponse<T>(response, config))
.then(this.interceptor.onResponse)
.catch(this.interceptor.onResponseError);
Expand Down

0 comments on commit ea1f750

Please sign in to comment.