Skip to content

Commit

Permalink
fix: ts에러 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
simeunseo committed Jun 25, 2024
1 parent 59d24bc commit a5361e9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/pages/OverallSchedule/OverallSchedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ function OverallSchedule() {
meetingId,
);

// 시간대 선택 단계가 없어질 것을 고려하여 상수값을 설정해놓음
const PREFER_TIMES = { startTime: '06:00', endTime: '24:00' };

return (
<OverallScheduleWrapper>
<Title memberCount={dataOverallSchedule?.memberCount} totalUserNames={dataOverallSchedule?.totalUserNames}/>
Expand All @@ -22,7 +25,7 @@ function OverallSchedule() {
dataTimetable &&
dataOverallSchedule && (
<OverallScheduleTable
timeSlots={getAvailableTimes(dataTimetable.preferTimes[0])}
timeSlots={getAvailableTimes(PREFER_TIMES)}
availableDates={dataTimetable.availableDates}
dataOverallSchedule={dataOverallSchedule}
/>
Expand Down
5 changes: 4 additions & 1 deletion src/pages/selectSchedule/SelectSchedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ function SelectSchedule() {
const { meetingId } = useParams();
const { data, isLoading } = useGetTimetable(meetingId);

// 시간대 선택 단계가 없어질 것을 고려하여 상수값을 설정해놓음
const PREFER_TIMES = { startTime: '06:00', endTime: '24:00' };

return (
<ScheduleStepContext.Provider value={{ scheduleStep, setScheduleStep }}>
<SelectScheduleWrapper>
Expand All @@ -38,7 +41,7 @@ function SelectSchedule() {
padding={scheduleStep === 'selectTimeSlot' ? `0 0 2.6rem` : `4.4rem 0 3.2rem 0`}
/>
<SelectScheduleTable
timeSlots={getAvailableTimes(data.preferTimes[0])}
timeSlots={getAvailableTimes(PREFER_TIMES)}
availableDates={data.availableDates}
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ function PriorityDropdown() {
temp = 0;
break;
}

setSelectedSlots((prev: SelectedSlotType) => {
const updatedSelectedSlots = Object.entries(prev).map(([key, value]) => {
const updatedSelectedSlots = Object.entries(prev).map(([_, value]) => {
if (value.priority === temp) {
return { ...value, priority: 0 };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const useSlotSeletion = () => {
const handleCompleteSlot = (targetSlot: string) => {
const dateOfStartSlot = startSlot?.substring(0, startSlot.lastIndexOf('/'));
const dateOfTargetSlot = targetSlot.substring(0, targetSlot.lastIndexOf('/'))
if (dateOfStartSlot === dateOfTargetSlot){
if (startSlot && dateOfStartSlot === dateOfTargetSlot){
const newSelectedSlot = {
date:dateOfStartSlot,
startSlot:startSlot?.substring(startSlot.lastIndexOf('/')+1),
Expand All @@ -20,7 +20,9 @@ const useSlotSeletion = () => {

const keys = Object.keys(selectedSlots).map(Number)
const newKey = keys.length ? Math.max(...keys) + 1 : 0;
setSelectedSlots({...selectedSlots, [newKey]:newSelectedSlot})
const newSelectedSlots = {...selectedSlots};
newSelectedSlots[newKey] = newSelectedSlot;
setSelectedSlots(newSelectedSlots)
}
setStartSlot(undefined);
}
Expand Down
8 changes: 4 additions & 4 deletions src/pages/selectSchedule/contexts/useSelectContext.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createContext, useContext } from 'react';
import { Dispatch, SetStateAction, createContext, useContext } from 'react';

export interface SelectSlotType {
date: string;
startSlot?: string;
startSlot: string;
endSlot: string;
priority: number;
}
Expand All @@ -13,9 +13,9 @@ export interface SelectedSlotType {

interface SelectContextType {
startSlot: string | undefined;
setStartSlot: (startSlot?: string) => void;
setStartSlot: Dispatch<SetStateAction<SelectContextType['startSlot']>>;
selectedSlots: SelectedSlotType;
setSelectedSlots: (selectedSlots: SelectedSlotType) => void;
setSelectedSlots: Dispatch<SetStateAction<SelectedSlotType>>;
}

export const SelectContext = createContext<SelectContextType>({
Expand Down
2 changes: 1 addition & 1 deletion src/pages/selectSchedule/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SelectedSlotType } from 'components/timetableComponents/context';
import { addMinutes } from 'components/timetableComponents/utils';

import { SelectedSlotType } from './contexts/useSelectContext';
import { TitlesType } from './types';

export const DURATION = {
Expand Down

0 comments on commit a5361e9

Please sign in to comment.