Skip to content

Commit

Permalink
chore: 코드 가독성 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
simeunseo committed Jun 23, 2024
1 parent 9596db2 commit a0c97c3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
13 changes: 7 additions & 6 deletions src/pages/selectSchedule/SelectSchedule.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import Button from 'components/atomComponents/Button';
import { DateType } from 'components/timetableComponents/types';
import Description from './components/Description';
import { useState } from 'react';

import Header from 'components/moleculesComponents/Header';
import SelectScheduleTable from './components/SelectScheduleTable';
import { Step } from './types';
import TitleComponents from 'components/moleculesComponents/TitleComponents';
import { DateType } from 'components/timetableComponents/types';
import { getAvailableTimes } from 'components/timetableComponents/utils';
import styled from 'styled-components';
import { useState } from 'react';

import Description from './components/Description';
import SelectScheduleTable from './components/SelectScheduleTable';
import { Step } from './types';

/***** api 연결 후 지울 것*****/

Expand Down
22 changes: 12 additions & 10 deletions src/pages/selectSchedule/components/SelectScheduleTable.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { ColumnStructure, TimetableStructure } from 'components/timetableComponents/types';
import { SelectedSlotType, TimetableContext } from 'components/timetableComponents/context';
import { Step, StepBtnsType, StepSlotsType } from '../types';
import { useState } from 'react';

import Button from 'components/atomComponents/Button';
import Text from 'components/atomComponents/Text';
import { SelectedSlotType, TimetableContext } from 'components/timetableComponents/context';
import Timetable from 'components/timetableComponents/Timetable';
import { ColumnStructure, TimetableStructure } from 'components/timetableComponents/types';
import styled from 'styled-components';

import PriorityCta from './selectPriority/PriorityCta';
import PriorityDropdown from './selectPriority/PriorityDropdown';
import PrioritySlots from './selectPriority/PrioritySlots';
import SelectionSlots from './selectTimeSlot/SelectionSlots';
import Text from 'components/atomComponents/Text';
import TimeSlotCta from './selectTimeSlot/TimeSlotCta';
import Timetable from 'components/timetableComponents/Timetable';
import { Step, StepBtnsType, StepSlotsType } from '../types';
import { resetPriorities } from '../utils';
import styled from 'styled-components';
import { useState } from 'react';

interface SelectScheduleTableProps extends TimetableStructure {
step: Step;
Expand All @@ -36,13 +37,14 @@ function SelectScheduleTable({
<PrioritySlots date={date} timeSlots={timeSlots} />
),
};
const stepSlot = stepSlots[step];

const isValidSelection = Object.keys(selectedSlots).length !== 0;

const stepBtns: StepBtnsType = {
selectTimeSlot: <TimeSlotCta isValidSelection={isValidSelection} setStep={setStep} />,
selectPriority: <PriorityCta />,
};
const stepBtn = stepBtns[step];

return (
<TimetableContext.Provider
Expand All @@ -54,10 +56,10 @@ function SelectScheduleTable({
}}
>
<Timetable timeSlots={timeSlots} availableDates={availableDates}>
{stepSlots[step]}
{stepSlot}
</Timetable>
{step === 'selectPriority' && <PriorityDropdown />}
{stepBtns[step]}
{stepBtn}
</TimetableContext.Provider>
);
}
Expand Down

0 comments on commit a0c97c3

Please sign in to comment.