diff --git a/frontend/src/pages/pc/admin/schedules/ScheduleForm.jsx b/frontend/src/pages/pc/admin/schedules/ScheduleForm.jsx index 35ea97e..4672aee 100644 --- a/frontend/src/pages/pc/admin/schedules/ScheduleForm.jsx +++ b/frontend/src/pages/pc/admin/schedules/ScheduleForm.jsx @@ -46,12 +46,14 @@ function ScheduleForm() { queryFn: categoriesApi.getCategories, staleTime: 10 * 60 * 1000, }); - const { data: members = [] } = useQuery({ + const { data: allMembers = [] } = useQuery({ queryKey: ['members'], queryFn: getMembers, staleTime: 10 * 60 * 1000, }); + // 현재 활동 멤버만 (탈퇴 멤버 제외) + const members = useMemo(() => allMembers.filter((m) => !m.is_former), [allMembers]); const categories = useMemo( () => allCategories.filter((c) => SHARED_CATEGORIES.includes(c.name)), [allCategories] @@ -101,7 +103,23 @@ function ScheduleForm() { })); const setPrecision = (month) => - setFormData((p) => ({ ...p, datePrecision: month ? 'month' : 'day', time: month ? '' : p.time })); + setFormData((p) => { + if (!month) return { ...p, datePrecision: 'day' }; + // 월 모드: 날짜가 비었으면 이번 달 1일로 기본값 + const hasMonthDate = /^\d{4}-\d{2}-01$/.test(p.date); + const now = new Date(); + const date = hasMonthDate + ? p.date + : `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-01`; + return { ...p, datePrecision: 'month', time: '', date }; + }); + + // 연/월 드롭다운용 + const yearNow = new Date().getFullYear(); + const YEAR_OPTIONS = [yearNow - 1, yearNow, yearNow + 1, yearNow + 2]; + const [selYear, selMonth] = (formData.date || '').split('-'); + const setMonthDate = (year, monthNum) => + setFormData((p) => ({ ...p, date: `${year}-${String(monthNum).padStart(2, '0')}-01` })); const handleSubmit = async (e) => { e.preventDefault(); @@ -240,13 +258,13 @@ function ScheduleForm() { @@ -255,27 +273,49 @@ function ScheduleForm() { {/* 날짜 + 시간 */}
-
- - setFormData({ ...formData, date })} - minYear={2017} - /> - {isMonthPrecision && ( -

선택한 날짜의 "월"만 사용됩니다 (일자는 무시)

- )} -
- {!isMonthPrecision && ( + {isMonthPrecision ? ( + // 날짜 미정: 연 + 월 드롭다운
- - setFormData({ ...formData, time })} - /> + +
+ + +
+ ) : ( + <> +
+ + setFormData({ ...formData, date })} + minYear={2017} + /> +
+
+ + setFormData({ ...formData, time })} + /> +
+ )}