'use client'; import { useState } from 'react'; import { useTranslation } from '@/lib/i18n'; import { notificationApi } from '@/lib/api'; export default function AdminNotificationsPage() { const { t } = useTranslation(); // Form state const [title, setTitle] = useState(''); const [message, setMessage] = useState(''); const [link, setLink] = useState(''); const [sending, setSending] = useState(false); const [result, setResult] = useState<{ success: boolean; message: string } | null>(null); const handleSendToAll = async (e: React.FormEvent) => { e.preventDefault(); if (!title.trim() || !message.trim()) { setResult({ success: false, message: '제목과 내용을 입력해주세요.' }); return; } setSending(true); setResult(null); try { const response = await notificationApi.adminSendToAll( title.trim(), message.trim(), link.trim() || undefined ); setResult({ success: true, message: response.message }); setTitle(''); setMessage(''); setLink(''); } catch (error) { console.error('Failed to send notification:', error); setResult({ success: false, message: '알림 발송에 실패했습니다.' }); } finally { setSending(false); } }; return (
{/* Header */}

알림 관리

전체 사용자에게 알림을 보낼 수 있습니다.

{/* Send Notification Form */}

전체 알림 발송

{/* Title */}
setTitle(e.target.value)} className="w-full border border-gray-300 rounded-lg px-4 py-2 focus:ring-2 focus:ring-primary-500 focus:border-primary-500" placeholder="알림 제목" maxLength={200} disabled={sending} />
{/* Message */}