Merge branch 'main' into feature/screen-management

This commit is contained in:
kjs 2026-01-13 10:25:08 +09:00
commit 20e144af36
2 changed files with 63 additions and 23 deletions

View File

@ -14,6 +14,7 @@ import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
import { Badge } from "@/components/ui/badge";
import { Checkbox } from "@/components/ui/checkbox";
import { TableCategoryValue } from "@/types/tableCategoryValue";
// 기본 색상 팔레트
@ -51,6 +52,7 @@ export const CategoryValueAddDialog: React.FC<
const [valueLabel, setValueLabel] = useState("");
const [description, setDescription] = useState("");
const [color, setColor] = useState("none");
const [continuousAdd, setContinuousAdd] = useState(false); // 연속 입력 체크박스
// 라벨에서 코드 자동 생성 (항상 고유한 코드 생성)
const generateCode = (): string => {
@ -60,6 +62,12 @@ export const CategoryValueAddDialog: React.FC<
return `CATEGORY_${timestamp}${random}`;
};
const resetForm = () => {
setValueLabel("");
setDescription("");
setColor("none");
};
const handleSubmit = () => {
if (!valueLabel.trim()) {
return;
@ -77,14 +85,28 @@ export const CategoryValueAddDialog: React.FC<
isDefault: false,
} as TableCategoryValue);
// 초기화
setValueLabel("");
setDescription("");
setColor("none");
// 연속 입력 체크되어 있으면 폼만 초기화하고 모달 유지
if (continuousAdd) {
resetForm();
} else {
// 연속 입력 아니면 모달 닫기
resetForm();
onOpenChange(false);
}
};
const handleClose = () => {
resetForm();
onOpenChange(false);
};
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<Dialog open={open} onOpenChange={(isOpen) => {
if (!isOpen) {
resetForm();
}
onOpenChange(isOpen);
}}>
<DialogContent className="max-w-[95vw] sm:max-w-[500px]">
<DialogHeader>
<DialogTitle className="text-base sm:text-lg">
@ -165,24 +187,42 @@ export const CategoryValueAddDialog: React.FC<
</div>
</div>
<DialogFooter className="gap-2 sm:gap-0">
<Button
variant="outline"
onClick={() => onOpenChange(false)}
className="h-8 flex-1 text-xs sm:h-10 sm:flex-none sm:text-sm"
>
</Button>
<Button
onClick={handleSubmit}
disabled={!valueLabel.trim()}
className="h-8 flex-1 text-xs sm:h-10 sm:flex-none sm:text-sm"
>
</Button>
<DialogFooter className="flex-col gap-3 sm:flex-row sm:gap-0">
{/* 연속 입력 체크박스 */}
<div className="flex items-center gap-2 w-full sm:w-auto sm:mr-auto">
<Checkbox
id="continuousAdd"
checked={continuousAdd}
onCheckedChange={(checked) => setContinuousAdd(checked as boolean)}
/>
<label
htmlFor="continuousAdd"
className="text-xs sm:text-sm text-muted-foreground cursor-pointer"
>
</label>
</div>
<div className="flex gap-2 w-full sm:w-auto">
<Button
type="button"
variant="outline"
onClick={handleClose}
className="h-8 flex-1 text-xs sm:h-10 sm:flex-none sm:text-sm"
>
</Button>
<Button
type="button"
onClick={handleSubmit}
disabled={!valueLabel.trim()}
className="h-8 flex-1 text-xs sm:h-10 sm:flex-none sm:text-sm"
>
</Button>
</div>
</DialogFooter>
</DialogContent>
</Dialog>
);
};

View File

@ -123,7 +123,7 @@ export const CategoryValueManager: React.FC<CategoryValueManagerProps> = ({
if (response.success && response.data) {
await loadCategoryValues();
setIsAddDialogOpen(false);
// 모달 닫기는 CategoryValueAddDialog에서 연속 입력 체크박스로 제어
toast({
title: "성공",
description: "카테고리 값이 추가되었습니다",
@ -142,7 +142,7 @@ export const CategoryValueManager: React.FC<CategoryValueManagerProps> = ({
title: "오류",
description: error.message || "카테고리 값 추가에 실패했습니다",
variant: "destructive",
});
});
}
};