Merge branch 'main' into feature/screen-management
This commit is contained in:
commit
20e144af36
|
|
@ -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">
|
||||
<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={() => onOpenChange(false)}
|
||||
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>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ export const CategoryValueManager: React.FC<CategoryValueManagerProps> = ({
|
|||
|
||||
if (response.success && response.data) {
|
||||
await loadCategoryValues();
|
||||
setIsAddDialogOpen(false);
|
||||
// 모달 닫기는 CategoryValueAddDialog에서 연속 입력 체크박스로 제어
|
||||
toast({
|
||||
title: "성공",
|
||||
description: "카테고리 값이 추가되었습니다",
|
||||
|
|
|
|||
Loading…
Reference in New Issue