feat(admin-schedule): 일정 추가 카테고리 선택에서 생일·기념일 제외
생일/기념일은 멤버 생일·데뷔일에서 자동 계산되는 카테고리라 수동 추가 대상이 아님. 카테고리 선택 목록과 기본 선택값에서 제외. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
680ea46cd5
commit
ad20149c88
1 changed files with 12 additions and 11 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect, useMemo } from "react";
|
||||||
import { useNavigate, Link } from "react-router-dom";
|
import { useNavigate, Link } from "react-router-dom";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { motion, AnimatePresence } from "framer-motion";
|
import { motion, AnimatePresence } from "framer-motion";
|
||||||
|
|
@ -49,19 +49,20 @@ function ScheduleFormPage() {
|
||||||
queryFn: categoriesApi.getCategories,
|
queryFn: categoriesApi.getCategories,
|
||||||
enabled: isAuthenticated,
|
enabled: isAuthenticated,
|
||||||
staleTime: 10 * 60 * 1000,
|
staleTime: 10 * 60 * 1000,
|
||||||
onSuccess: (data) => {
|
|
||||||
if (data.length > 0 && !selectedCategory) {
|
|
||||||
setSelectedCategory(data[0].id);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 카테고리 로드 시 기본값 설정
|
// 자동 생성/계산 전용 카테고리는 수동 추가 폼에서 제외 (생일·기념일)
|
||||||
|
const selectableCategories = useMemo(
|
||||||
|
() => categories.filter((c) => c.name !== '생일' && c.name !== '기념일'),
|
||||||
|
[categories]
|
||||||
|
);
|
||||||
|
|
||||||
|
// 카테고리 로드 시 기본값 설정 (선택 가능한 카테고리 기준)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (categories.length > 0 && !selectedCategory) {
|
if (selectableCategories.length > 0 && !selectedCategory) {
|
||||||
setSelectedCategory(categories[0].id);
|
setSelectedCategory(selectableCategories[0].id);
|
||||||
}
|
}
|
||||||
}, [categories, selectedCategory]);
|
}, [selectableCategories, selectedCategory]);
|
||||||
|
|
||||||
// 카테고리에 따른 폼 렌더링
|
// 카테고리에 따른 폼 렌더링
|
||||||
const renderForm = () => {
|
const renderForm = () => {
|
||||||
|
|
@ -150,7 +151,7 @@ function ScheduleFormPage() {
|
||||||
{/* 카테고리 선택 */}
|
{/* 카테고리 선택 */}
|
||||||
<motion.div variants={itemVariants} className="mb-6">
|
<motion.div variants={itemVariants} className="mb-6">
|
||||||
<CategorySelector
|
<CategorySelector
|
||||||
categories={categories}
|
categories={selectableCategories}
|
||||||
selectedId={selectedCategory}
|
selectedId={selectedCategory}
|
||||||
onChange={(id) => {
|
onChange={(id) => {
|
||||||
setSelectedCategory(id);
|
setSelectedCategory(id);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue