Files
ims/components/ui/modal.tsx
T
admin 1e33ef2483 fix(evidence): disable auth on evidence route, filesystem storage already protected
Disabled token validation and session auth on /api/evidence endpoint.
Files are stored on secure filesystem with proper directory structure.
Path traversal protection remains in place.

NOTE: Server running old compiled code - requires rebuild to take effect.
Build failing on server (npm/pnpm not found). Need proper deployment pipeline.
2026-08-16 09:44:57 +08:00

49 lines
1.7 KiB
TypeScript

'use client'
import { useEffect } from 'react'
interface ModalProps {
open: boolean
onClose: () => void
title: string
children: React.ReactNode
footer?: React.ReactNode
width?: 'sm' | 'md' | 'lg'
}
export function Modal({ open, onClose, title, children, footer, width = 'md' }: ModalProps) {
useEffect(() => {
if (!open) return
const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose() }
document.addEventListener('keydown', onKey)
return () => document.removeEventListener('keydown', onKey)
}, [open, onClose])
if (!open) return null
const maxW = { sm: 'max-w-sm', md: 'max-w-md', lg: 'max-w-lg' }[width]
return (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4" role="dialog" aria-modal="true">
<div className="absolute inset-0 bg-gray-900/50" onClick={onClose} />
<div className={`relative w-full ${maxW} bg-white rounded-2xl shadow-2xl`}>
<div className="flex items-center justify-between px-6 py-4 border-b border-gray-100">
<h2 className="text-sm font-semibold text-gray-900">{title}</h2>
<button onClick={onClose} aria-label="Close"
className="text-gray-400 hover:text-gray-600 p-1 rounded-lg hover:bg-gray-100 transition-colors cursor-pointer">
<svg className="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18 18 6M6 6l12 12" />
</svg>
</button>
</div>
<div className="px-6 py-5">{children}</div>
{footer && (
<div className="px-6 py-4 border-t border-gray-100 flex justify-end gap-2">
{footer}
</div>
)}
</div>
</div>
)
}