-
Notifications
You must be signed in to change notification settings - Fork 1
fix: 일정 변경사항 Task를 줄입니다. #315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Songhyejeong
wants to merge
9
commits into
develop
Choose a base branch
from
chore/preSeat-2026-1-change-period
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c4214ab
chore: 정정기간 preSeat 데이터 준비
Songhyejeong 691c354
fix: 신입생 수강 신청 날짜로 실시간 오픈 날짜 변경
Songhyejeong 42992ca
feat: 서비스 운영에 필요한 변경사항 최소화 하는 훅 구현
Songhyejeong 7cea750
fix: useAcademic 애매한 훅 네이밍 수정
Songhyejeong 936c99a
fix: 캐시 스펠링 수정
Songhyejeong 223bebd
fix: 최상위 객체만 import하도록 수정 및 구조 분해 할당 적용
Songhyejeong 13ed235
refactor: basket 데이터로 import 하도록 수정
Songhyejeong b4893df
refactor: 훅 분리 및가독성 향상
Songhyejeong f0e4dc0
reactor: preseat 주석 정보 수정
Songhyejeong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { useQuery } from '@tanstack/react-query'; | ||
| import { fetchBasketOpenDate, fetchCurrentPeriod, fetchPreSeatOpenDate } from '../lib/manageSchedule'; | ||
|
|
||
| export function useCurrentPeriod() { | ||
| return useQuery({ | ||
| queryKey: ['currentPeriod'], | ||
| queryFn: fetchCurrentPeriod, | ||
| staleTime: Infinity, | ||
| }); | ||
| } | ||
|
|
||
| export function usePreSeatOpenDate() { | ||
| return useQuery({ | ||
| queryKey: ['preSeatOpenDate'], | ||
| queryFn: fetchPreSeatOpenDate, | ||
| staleTime: Infinity, | ||
| }); | ||
| } | ||
|
|
||
| export function useBasketOpenDate() { | ||
| return useQuery({ | ||
| queryKey: ['basketOpenDate'], | ||
| queryFn: fetchBasketOpenDate, | ||
| staleTime: Infinity, | ||
| }); | ||
| } |
37 changes: 37 additions & 0 deletions
37
packages/client/src/entities/schedule/lib/getMainPageActionsMode.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { ServiceMode, ServicePeriod } from './manageSchedule'; | ||
|
|
||
| interface MainAction { | ||
| label: string; | ||
| link: string; | ||
| } | ||
|
|
||
| /** | ||
| * 메인 페이지에서 보여지는 액션 버튼의 모드를 반환하는 함수입니다. | ||
| * 각 수강 신청 기간에 따라 다른 액션 버튼이 메인 페이지에 표시됩니다. | ||
| * @param mode | ||
| * @returns | ||
| */ | ||
| export const getMainPageActionsMode = (mode: ServicePeriod['mode']): MainAction[] => { | ||
| switch (mode) { | ||
| case ServiceMode.WISHLIST: | ||
| return [ | ||
| { label: '관심과목 담기', link: '/wishlist' }, | ||
| { label: '수강 신청 연습하기', link: '/simulation' }, | ||
| ]; | ||
|
|
||
| case ServiceMode.REGISTRATION_SENIOR: | ||
| case ServiceMode.REGISTRATION_ALL: | ||
| case ServiceMode.REGISTRATION_FRESHMAN: | ||
| case ServiceMode.CORRECTION: | ||
| return [ | ||
| { label: '실시간 여석 확인하기', link: '/live' }, | ||
| { label: '수강 신청 연습하기', link: '/simulation' }, | ||
| ]; | ||
|
|
||
| default: | ||
| return [ | ||
| { label: '전체 학년 여석 확인하기', link: '/live' }, | ||
| { label: '수강 신청 연습하기', link: '/simulation' }, | ||
| ]; | ||
| } | ||
| }; |
89 changes: 89 additions & 0 deletions
89
packages/client/src/entities/schedule/lib/manageSchedule.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| export enum ServiceMode { | ||
| WISHLIST = 'wishlist', | ||
| REGISTRATION_SENIOR = 'registration-senior', | ||
| REGISTRATION_ALL = 'registration-all', | ||
| REGISTRATION_FRESHMAN = 'registration-freshman', | ||
| CORRECTION = 'correction', | ||
| } | ||
|
|
||
| export interface ServicePeriod { | ||
| start: string; | ||
| end: string; | ||
| mode: ServiceMode; | ||
| description: string; | ||
| } | ||
|
|
||
| /** | ||
| * periods: 수강 신청과 관련된 각 기간의 시작과 끝, 그리고 해당 기간의 모드와 설명 | ||
| * displayPeriod: 메인 배너의 수강 신청 기간 | ||
| * CURRENT_PERIOD의 start, end 필드는 매 학기 일정이 나오면 업데이트 되어야합니다. | ||
| */ | ||
| export interface AcademicSchedule { | ||
| periods: ServicePeriod[]; | ||
|
|
||
| displayPeriod: { | ||
| displayPeriodName?: string; // '수강 신청 기간' or '수강 정정 기간'' | ||
| start: string; // '02월 10일(화)' | ||
| end: string; // '02월 13일(금)' | ||
| }; | ||
| } | ||
|
|
||
| export const CURRENT_PERIOD: AcademicSchedule = { | ||
| periods: [ | ||
| { | ||
| start: '2026-01-27T10:00:00', | ||
| end: '2026-02-09T16:59:59', | ||
| mode: ServiceMode.WISHLIST, | ||
| description: '관심과목 담기 기간', | ||
| }, | ||
| { | ||
| start: '2026-02-10T10:00:00', | ||
| end: '2026-02-12T16:59:59', | ||
| mode: ServiceMode.REGISTRATION_SENIOR, | ||
| description: '4~1학년 수강신청 기간', | ||
| }, | ||
| { | ||
| start: '2026-02-13T10:00:00', | ||
| end: '2026-02-26T16:59:59', | ||
| mode: ServiceMode.REGISTRATION_ALL, | ||
| description: '전체학년 수강신청 기간', | ||
| }, | ||
| { | ||
| start: '2026-02-27T10:00:00', | ||
| end: '2026-02-27T16:59:59', | ||
| mode: ServiceMode.REGISTRATION_FRESHMAN, | ||
| description: '신입생 수강신청 기간', | ||
| }, | ||
| { | ||
| start: '2026-03-04T10:00:00', | ||
| end: '2026-03-09T16:59:59', | ||
| mode: ServiceMode.CORRECTION, | ||
| description: '수강정정 기간', | ||
| }, | ||
| ], | ||
|
|
||
| displayPeriod: { | ||
| displayPeriodName: '수강정정 기간', | ||
| start: '03월 04일(수)', | ||
| end: '03월 09일(월)', | ||
| }, | ||
| }; | ||
|
|
||
| //preSeat 데이터 업데이트 시 preSeatOpenDate를 변경해주어야합니다. | ||
| export const PRESEAT_OPEN_DATE = new Date('2026-03-09T00:00:00'); | ||
|
|
||
| // basket 데이터 업데이트 시 basketOpenDate를 변경해주어야합니다. | ||
| export const BASKET_OPEN_DATE = new Date('2026-01-31T00:00:00'); | ||
|
|
||
| // API 연결 확장성을 위해 fetchCurrentPeriod, fetchPreSeatOpenDate, fetchBasketOpenDate 함수를 만들어두었습니다. | ||
| export const fetchCurrentPeriod = async (): Promise<AcademicSchedule> => { | ||
| return CURRENT_PERIOD; | ||
| }; | ||
|
|
||
| export const fetchPreSeatOpenDate = async (): Promise<Date> => { | ||
| return PRESEAT_OPEN_DATE; | ||
| }; | ||
|
|
||
| export const fetchBasketOpenDate = async (): Promise<Date> => { | ||
| return BASKET_OPEN_DATE; | ||
| }; | ||
31 changes: 31 additions & 0 deletions
31
packages/client/src/entities/schedule/model/useManagePeriod.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { useBasketOpenDate } from '../api/schedule'; | ||
| import { getMainPageActionsMode } from '../lib/getMainPageActionsMode'; | ||
| import { usePreSeatInfo } from './usePreSeatInfo'; | ||
| import { useServiceMode } from './useServiceMode'; | ||
|
|
||
| /** | ||
| * | ||
| * @returns | ||
| * period: 메인 배너 수강 신청 기간 | ||
| * mainPageRouter: 메인 페이지 라우터 정보 | ||
| * preSeat: 전체 여석 오픈, 클로즈 여부 및 시간 | ||
| * basket: 관심 과목 오픈 날짜 | ||
| */ | ||
| export function useManagePeriod() { | ||
| const { serviceMode, registrationDisplayPeriod } = useServiceMode(); | ||
| const preSeat = usePreSeatInfo(); | ||
| const { data: basketOpenDate } = useBasketOpenDate(); | ||
|
|
||
| return { | ||
| period: { | ||
| registrationDisplayPeriod, | ||
| }, | ||
| mainPageRouter: { | ||
| mainPageActionsMode: getMainPageActionsMode(serviceMode), | ||
| }, | ||
| preSeat, | ||
| basket: { | ||
| basketOpenDate, | ||
| }, | ||
| }; | ||
| } |
44 changes: 44 additions & 0 deletions
44
packages/client/src/entities/schedule/model/usePreSeatInfo.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { useCurrentPeriod, usePreSeatOpenDate } from '../api/schedule'; | ||
| import { ServiceMode, ServicePeriod } from '../lib/manageSchedule'; | ||
|
|
||
| export function usePreSeatInfo() { | ||
| const now = new Date(); | ||
| const { data: currentPeriodData } = useCurrentPeriod(); | ||
| const { data: preSeatOpenDate } = usePreSeatOpenDate(); | ||
|
|
||
| const periods = currentPeriodData?.periods ?? []; | ||
|
|
||
| const transitionPairs: [ServiceMode, ServiceMode][] = [ | ||
| [ServiceMode.REGISTRATION_SENIOR, ServiceMode.REGISTRATION_ALL], | ||
| [ServiceMode.REGISTRATION_ALL, ServiceMode.REGISTRATION_FRESHMAN], | ||
| [ServiceMode.REGISTRATION_FRESHMAN, ServiceMode.CORRECTION], | ||
| ]; | ||
|
|
||
| let shouldPreparePreSeat = false; | ||
| let livePeriodStart: string | null = null; | ||
|
|
||
| for (const [beforeMode, afterMode] of transitionPairs) { | ||
| const beforePeriod = periods.find((p: ServicePeriod) => p.mode === beforeMode); | ||
| const afterPeriod = periods.find((p: ServicePeriod) => p.mode === afterMode); | ||
|
|
||
| if (!beforePeriod || !afterPeriod) continue; | ||
|
|
||
| if ( | ||
| now > new Date(beforePeriod.end) && | ||
| now < new Date(afterPeriod.start) && | ||
| preSeatOpenDate && | ||
| preSeatOpenDate <= now | ||
| ) { | ||
| shouldPreparePreSeat = true; | ||
| livePeriodStart = afterPeriod.start; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| shouldPreparePreSeat, | ||
| preSeatCloseDate: livePeriodStart?.split('T')[0] ?? '', | ||
| preSeatCloseTime: livePeriodStart?.split('T')[1]?.slice(0, 5) ?? '', | ||
| preSeatOpenDate, | ||
| }; | ||
| } |
26 changes: 26 additions & 0 deletions
26
packages/client/src/entities/schedule/model/useServiceMode.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { useCurrentPeriod } from '../api/schedule'; | ||
| import { ServiceMode, ServicePeriod } from '../lib/manageSchedule'; | ||
|
|
||
| /** | ||
| * 전체 학년 수강 신청 기간, 신입생 수강 신청 기간, 수강 정정 기간 등 각 기간에 따른 모드를 반환하는 커스텀 훅입니다. | ||
| * @returns | ||
| */ | ||
| export const useServiceMode = () => { | ||
| const now = new Date(); | ||
| const { data: currentPeriodData } = useCurrentPeriod(); | ||
|
|
||
| const currentPeriod = | ||
| currentPeriodData?.periods.find((period: ServicePeriod) => { | ||
| const start = new Date(period.start); | ||
| const end = new Date(period.end); | ||
| return now >= start && now <= end; | ||
| }) || null; | ||
|
|
||
| const currentMode = currentPeriod?.mode || ServiceMode.WISHLIST; | ||
|
|
||
| return { | ||
| activePeriod: currentPeriod, | ||
| serviceMode: currentMode, | ||
| registrationDisplayPeriod: currentPeriodData?.displayPeriod, | ||
| }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import React from 'react'; | ||
| import { InitWishes } from '@/entities/wishes/model/useWishes.ts'; | ||
| import { WishesWithSeat } from '@/entities/subjectAggregate/model/useWishesPreSeats.ts'; | ||
| import usePreSeatGate from '@/widgets/live/preSeat/model/usePreSeatGate'; | ||
| import { useManagePeriod } from '@/entities/schedule/model/useManagePeriod'; | ||
| import { getSeatColor } from '@/shared/config/colors.ts'; | ||
| import { Flex } from '@allcll/allcll-ui'; | ||
|
|
||
|
|
@@ -13,7 +13,8 @@ interface ISubjectDetailProps { | |
| function SubjectDetail({ wishes }: ISubjectDetailProps) { | ||
| const data = wishes ?? InitWishes; | ||
| const hasPreSeats = wishes && 'seat' in wishes; | ||
| const { isPreSeatAvailable } = usePreSeatGate({ hasSeats: hasPreSeats }); | ||
| const { preSeat } = useManagePeriod(); | ||
| const isPreSeatAvailable = preSeat.shouldPreparePreSeat && Boolean(hasPreSeats); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 파일을 확인해보니, hasPreSeats 가 boolean 으로써 사용되고 있습니다.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵! 좋은 의견 감사합니다~! 수정하겠습니다. |
||
|
|
||
| const seats = hasPreSeats ? wishes.seat : -1; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
예전에 달력 업데이트 부분이 이 내용이었던 것 같아요.
이 상수 부분도, API 로 변경될 가능성이 있을 것 같아요. 직접 상수로 export 하기보다는 함수로 대신 export 해두면 좋을 것 같아요,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 파일이 APP 의 설정파일 역할을 하게 될 것 같습니다.
app 폴더로 이동해보는건 어떻게 생각하시나요?
추후 달력 기능이 업데이트 되면, 여기 두는게 좋을 수도 있을 것 같아요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵! 저도 해당 방향성으로 데이터 처럼 관리하는게 좋을 거 같습니다. 좋은 의견 감사합니다!!
앗 그러네요! 혹시.., 제가 이해한 방향성이 맞는지 모르겠어서,
특정 도메인과 연관 있다기 보다는 전체 서비스 관리와 연관성이 있어서 APP 설정 파일에 두는 것을 말씀하신 게 맞을까요?
맞다면 APP폴더에 두는 것도 좋을 것 같습니다!
다만, FSD 관점에서는 app의 파일을 하위 레이어
page,widget등에서 import하게 되는 방향성은 어색할 수 있을 것 같습니다.