"use client"; import { useState } from "react"; import { toast } from "sonner"; import { Save, X, ChevronUp, ChevronDown } from "lucide-react"; import { motion, AnimatePresence } from "framer-motion"; import classNames from "classnames"; import { Page } from "@/types"; import { api } from "@/lib/api"; import { Button } from "@/components/ui/button"; import Loading from "@/components/loading"; interface SaveChangesPopupProps { isOpen: boolean; onClose: () => void; onSave: () => Promise; hasUnsavedChanges: boolean; pages: Page[]; project?: any; } export const SaveChangesPopup = ({ isOpen, onClose, onSave, hasUnsavedChanges, pages, project, }: SaveChangesPopupProps) => { const [isSaving, setIsSaving] = useState(false); const [isCollapsed, setIsCollapsed] = useState(false); const handleSave = async () => { if (!project || !hasUnsavedChanges) return; setIsSaving(true); try { await onSave(); toast.success("Changes saved successfully!"); onClose(); } catch (error: any) { toast.error(error.message || "Failed to save changes"); } finally { setIsSaving(false); } }; if (!hasUnsavedChanges || !isOpen) return null; return ( {isCollapsed ? ( // Collapsed state
Unsaved Changes
) : ( // Expanded state

Unsaved Changes

You have unsaved changes in your project. Save them to preserve your work.

)}
); };