야드관리 수정 #109

Merged
hyeonsu merged 6 commits from feat/dashboard into main 2025-10-20 11:55:10 +09:00
1 changed files with 42 additions and 3 deletions
Showing only changes of commit cd893c2fa3 - Show all commits

View File

@ -7,7 +7,8 @@ import { yardLayoutApi } from "@/lib/api/yardLayoutApi";
import dynamic from "next/dynamic";
import { YardLayout, YardPlacement } from "./types";
import { Alert, AlertDescription } from "@/components/ui/alert";
import { AlertCircle } from "lucide-react";
import { AlertCircle, CheckCircle } from "lucide-react";
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from "@/components/ui/dialog";
const Yard3DCanvas = dynamic(() => import("./Yard3DCanvas"), {
ssr: false,
@ -39,6 +40,11 @@ export default function YardEditor({ layout, onBack }: YardEditorProps) {
const [error, setError] = useState<string | null>(null);
const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false); // 미저장 변경사항 추적
const [nextPlacementId, setNextPlacementId] = useState(-1); // 임시 ID (음수 사용)
const [saveResultDialog, setSaveResultDialog] = useState<{
open: boolean;
success: boolean;
message: string;
}>({ open: false, success: false, message: "" });
// 배치 목록 로드
useEffect(() => {
@ -208,11 +214,19 @@ export default function YardEditor({ layout, onBack }: YardEditorProps) {
setHasUnsavedChanges(false);
setSelectedPlacement(null);
setShowConfigPanel(false);
alert("저장되었습니다");
setSaveResultDialog({
open: true,
success: true,
message: "모든 변경사항이 성공적으로 저장되었습니다.",
});
}
} catch (error) {
console.error("저장 실패:", error);
alert("저장에 실패했습니다");
setSaveResultDialog({
open: true,
success: false,
message: `저장에 실패했습니다: ${error instanceof Error ? error.message : "알 수 없는 오류"}`,
});
} finally {
setIsSaving(false);
}
@ -403,6 +417,31 @@ export default function YardEditor({ layout, onBack }: YardEditorProps) {
)}
</div>
</div>
{/* 저장 결과 Dialog */}
<Dialog open={saveResultDialog.open} onOpenChange={(open) => setSaveResultDialog((prev) => ({ ...prev, open }))}>
<DialogContent onPointerDown={(e) => e.stopPropagation()}>
<DialogHeader>
<DialogTitle className="flex items-center gap-2">
{saveResultDialog.success ? (
<>
<CheckCircle className="h-5 w-5 text-green-600" />
</>
) : (
<>
<AlertCircle className="h-5 w-5 text-red-600" />
</>
)}
</DialogTitle>
<DialogDescription className="pt-2">{saveResultDialog.message}</DialogDescription>
</DialogHeader>
<div className="flex justify-end">
<Button onClick={() => setSaveResultDialog((prev) => ({ ...prev, open: false }))}></Button>
</div>
</DialogContent>
</Dialog>
</div>
);
}