Skip to content

Commit

Permalink
Merge pull request #418 from boostcampwm2023/Fix/FE/#405
Browse files Browse the repository at this point in the history
Fix/FE/#405: timeout 설정 및 사이트 바로가기
  • Loading branch information
Capoomaru authored Dec 12, 2023
2 parents 6805862 + 6732067 commit 5827d7c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 6 deletions.
9 changes: 7 additions & 2 deletions frontend/src/apis/fetchThemeTimeTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ import userInstance from '@config/userInstance';
import { Value } from 'react-calendar/dist/cjs/shared/types';

const fetchThemeTimeTable = async (themeId: number, date: Value) => {
return (await userInstance({ method: 'get', url: `/themes/${themeId}/timetable?date=${date}` }))
.data;
return (
await userInstance({
method: 'get',
url: `/themes/${themeId}/timetable?date=${date}`,
timeout: 5000,
})
).data;
};

export default fetchThemeTimeTable;
1 change: 0 additions & 1 deletion frontend/src/hooks/useTimeTableQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const useTimeTableQuery = (themeId: number, date: Value) => {
const { data, isSuccess, isLoading, isError } = useQuery<TimeTable[]>({
queryKey: [QUERY_MANAGEMENT['themeTimeTable'].key, themeId, date],
queryFn: () => QUERY_MANAGEMENT['themeTimeTable'].fn(themeId, date),
retryDelay: 5000,
});

return { data, isSuccess, isLoading, isError };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const RoomInfoPanel = memo(function RoomInfoPanel({ settingMode, changeRoom }: P
recruitmentCompleted,
appointmentCompleted,
themeId,
website,
} = roomInfo as RoomInfo;

const handleSettingButton = () => {
Expand Down Expand Up @@ -93,7 +94,7 @@ const RoomInfoPanel = memo(function RoomInfoPanel({ settingMode, changeRoom }: P
</RoomInfoContent>
</RoomInfoWrapper>
</RoomInfoTopContainer>
<TimeTable themeId={themeId} />
<TimeTable themeId={themeId} website={website} />
</Layout>
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import { FaArrowsRotate } from 'react-icons/fa6';
import { keyframes } from '@emotion/react';
import { getStringByDate } from '@utils/dateUtil';

const TimeTable = ({ themeId }: { themeId: number }) => {
interface Props {
themeId: number;
website: string;
}

const TimeTable = ({ themeId, website }: Props) => {
const today = new Date();
const [date, setDate] = useState<Value>(today);
const { data, isLoading } = useTimeTableQuery(themeId, date);
Expand Down Expand Up @@ -65,6 +70,9 @@ const TimeTable = ({ themeId }: { themeId: number }) => {
시간표를 불러올 수 없습니다.
</InfoText>
)}
<WebsiteLink href={website} target="_blank">
예약 사이트 바로가기
</WebsiteLink>
</>
)}
</Container>
Expand Down Expand Up @@ -126,3 +134,11 @@ const InfoText = styled.div([
line-height: 2.5rem;
`,
]);

const WebsiteLink = styled.a([
tw`font-pretendard text-white text-l border border-white border-solid py-3 px-4 rounded-[1rem]`,
css`
text-decoration: none;
cursor: pointer;
`,
]);
1 change: 1 addition & 0 deletions frontend/src/pages/ChatRoom/mock/mockRoomInfoData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export const mockRoomInfo: RoomInfo = {
currentMembers: 5,
recruitmentCompleted: false,
appointmentCompleted: true,
website: 'https://www.naver.com',
};
1 change: 1 addition & 0 deletions frontend/src/types/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface RoomInfo {
currentMembers: number;
recruitmentCompleted: boolean;
appointmentCompleted: boolean;
website: string;
}

export type ChangeRoomData = {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utils/pickRandomNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const START_INDEX = 0;
*/
const pickRandomNumber = (n: number, k: number): Array<number> => {
if (k > n) {
throw new Error('asd');
throw new Error('k는 n보다 클 수 없습니다.');
}

const numbersArray = Array.from({ length: n }, (_, index) => index + 1).sort(
Expand Down

0 comments on commit 5827d7c

Please sign in to comment.