import { useEffect, useRef, useState } from "react"; import { toast } from "sonner"; import CopyButton from "@/components/common/CopyButton"; import type { DeviceSummary } from "../types"; interface DeviceSlidePanelProps { isOpen: boolean; onClose: () => void; device: DeviceSummary | null; } export default function DeviceSlidePanel({ isOpen, onClose, device, }: DeviceSlidePanelProps) { const [showDeleteConfirm, setShowDeleteConfirm] = useState(false); const bodyRef = useRef(null); // 패널 열릴 때 스크롤 최상단 리셋 useEffect(() => { if (isOpen) { bodyRef.current?.scrollTo(0, 0); } }, [isOpen, device]); // ESC 닫기 useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (e.key === "Escape" && isOpen) onClose(); }; document.addEventListener("keydown", handleKeyDown); return () => document.removeEventListener("keydown", handleKeyDown); }, [isOpen, onClose]); // body 스크롤 잠금 useEffect(() => { if (isOpen) { document.body.style.overflow = "hidden"; } else { document.body.style.overflow = ""; } return () => { document.body.style.overflow = ""; }; }, [isOpen]); // 플랫폼 아이콘 렌더링 const renderPlatformIcon = () => { if (!device) return null; if (device.platform === "iOS") { return (
); } return (
android
); }; // 수신 동의 박스 const ConsentBox = ({ label, consented, }: { label: string; consented: boolean; }) => (
{consented ? "check_circle" : "cancel"} {label}
{consented ? "동의" : "미동의"}
); return ( <> {/* 오버레이 */}
{/* 패널 */} {/* 삭제 확인 모달 */} {showDeleteConfirm && device && (
setShowDeleteConfirm(false)} />
warning

기기 삭제

선택한 기기를 삭제하시겠습니까?

info 삭제된 기기는 복구할 수 없습니다.
info 해당 기기로의 푸시 발송이 즉시 중단됩니다.
)} ); }