Skip to content

Commit

Permalink
fix: ts 에러 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
simeunseo committed Jun 22, 2024
1 parent 013f9f1 commit 63ed971
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 86 deletions.
2 changes: 1 addition & 1 deletion src/components/timetableComponents/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type TimetableContextType = {
startSlot?: string;
setStartSlot: (startSlot?: string) => void;
selectedSlots: SelectedSlotType;
setSelectedSlots: (selectedSlots: SelectedSlotsType) => void;
setSelectedSlots: (selectedSlots: SelectedSlotType) => void;
};

export const TimetableContext = createContext<TimetableContextType>({
Expand Down
12 changes: 3 additions & 9 deletions src/pages/legacy/selectSchedule/SelectModal.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import {
formatHostScheduleScheme,
formatMemberScheduleScheme,
formatSchedulePostScheme,
} from 'pages/selectSchedule/utils';
import { formatHostScheduleScheme, formatMemberScheduleScheme } from 'pages/selectSchedule/utils';
import { hostAvailableApi, userAvailableApi } from 'utils/apis/legacy/createHostAvailableSchedule';
import { scheduleAtom, userNameAtom } from 'atoms/atom';
import { transformHostScheduleType, transformUserScheduleType } from './utils/changeApiReq';
import { useNavigate, useParams } from 'react-router';
import { useRecoilState, useRecoilValue } from 'recoil';

import { ExitIc } from 'components/Icon/icon';
import { ScheduleStates } from './types/Schedule';
import Text from 'components/atomComponents/Text';
import { isAxiosError } from 'axios';
import styled from 'styled-components/macro';
import { theme } from 'styles/theme';
import { useRecoilValue } from 'recoil';
import { useTimetableContext } from 'components/timetableComponents/context';
import { userNameAtom } from 'atoms/atom';

interface ModalProps {
setShowModal: (isModalOpen: boolean) => void;
Expand Down
67 changes: 0 additions & 67 deletions src/pages/legacy/selectSchedule/utils/changeApiReq.ts

This file was deleted.

5 changes: 1 addition & 4 deletions src/pages/selectSchedule/SelectSchedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import { useState } from 'react';
function SelectSchedule() {
const [step, setStep] = useState<Step>('selectTimeSlot');
const { meetingId } = useParams();
const { data, isLoading, isError, error } = useGetTimetable(meetingId);
if (isError) {
console.log(err);
}
const { data, isLoading } = useGetTimetable(meetingId);
interface TitlesType {
[key: string]: {
main: string;
Expand Down
15 changes: 10 additions & 5 deletions src/utils/apis/useGetTimetable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { DURATION, PLACE } from 'pages/selectSchedule/utils';

import { client } from './axios';
import { isAxiosError } from 'axios';
import { useNavigate } from 'react-router-dom';
import { useQuery } from '@tanstack/react-query';

Expand All @@ -14,8 +17,8 @@ interface TimeSlot {

interface getTimetableResponse {
data: {
duration: string;
place: string;
duration: keyof typeof DURATION;
place: keyof typeof PLACE;
placeDetail: string;
availableDates: Date[];
preferTimes: TimeSlot[];
Expand All @@ -27,7 +30,9 @@ const getTimetable = async (meetingId: string) => {
const res = await client.get<getTimetableResponse>(`/meeting/${meetingId}/schedule`);
return res.data.data;
} catch (err) {
throw new Error(err);
if (isAxiosError(err) && err.response) {
throw new Error(err.response.data.message);
}
}
};

Expand All @@ -37,10 +42,10 @@ export const useGetTimetable = (meetingId?: string) => {
navigate('/error');
throw new Error('잘못된 회의 아이디입니다.');
}
const { data, isError, error, isLoading } = useQuery({
const { data, isLoading } = useQuery({
queryKey: ['getTimetable', meetingId],
queryFn: () => getTimetable(meetingId),
});

return { data, isError, error, isLoading };
return { data, isLoading };
};

0 comments on commit 63ed971

Please sign in to comment.