import React, { useState } from 'react'; import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'; import { Head, useForm, router } from '@inertiajs/react'; import { PageProps } from '@/types'; import { swal } from '@/lib/swal'; interface NotificationLog { id: number; title: string; body: string; target_type: string; target_user?: { first_name: string, last_name: string, email: string }; sender?: { first_name: string, last_name: string }; status: string; created_at: string; } interface NotificationsProps extends PageProps { logs: { data: NotificationLog[]; links: any[]; meta: { current_page: number; last_page: number; total: number; per_page: number }; }; users: { id: number, first_name: string, last_name: string, email: string }[]; } export default function NotificationsIndex({ logs, users }: NotificationsProps) { const { data, setData, post, processing, reset, errors } = useForm<{ title: string; body: string; image_url: string; deep_link: string; target_type: string; target_user_id: string; }>({ title: '', body: '', image_url: '', deep_link: '', target_type: 'all', target_user_id: '', }); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); post(route('notifications.store'), { onSuccess: () => { reset(); swal.success('Dispatched', 'Notification has been sent to devices.'); }, }); }; return (

Notification Center

Broadcast messages and alerts to Android devices

{/* Composer Form */}

Compose Broadcast

New FCM Message

setData('title', e.target.value)} placeholder="e.g. Flash Sale Alert!" className={`input-field ${errors.title ? 'is-error' : ''}`} /> {errors.title &&

{errors.title}

}