import InputError from '@/components/input-error'; import LoadingButton from '@/components/loading-button'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'; import { Label } from '@/components/ui/label'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { SharedData } from '@/types/global'; import { useForm, usePage } from '@inertiajs/react'; import { ReactNode, useState } from 'react'; import { Editor } from 'richtor'; import 'richtor/styles'; interface Props { instructor: Instructor; actionComponent: ReactNode; } const ApplicationApproval = ({ instructor, actionComponent }: Props) => { const [open, setOpen] = useState(false); const statuses = ['pending', 'approved', 'rejected'].filter((status) => status !== instructor.status); // Get translations from usePage hook const { props } = usePage(); const { translate } = props; const { dashboard, input, button } = translate; const { data, put, setData, processing, errors, reset } = useForm({ status: '', feedback: '', }); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); put(route('instructors.status', { id: instructor.id }), { onSuccess: () => { reset(); setOpen(false); }, }); }; return ( {actionComponent} {dashboard.are_you_absolutely_sure} {/* add a form where admin can select status then write a feedback and submit */}
setData((prev) => ({ ...prev, feedback: value as string, })) } />
{button.submit}
); }; export default ApplicationApproval;