import InputError from '@/components/input-error'; import LoadingButton from '@/components/loading-button'; import { Button } from '@/components/ui/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 { cn } from '@/lib/utils'; import { Link, router, useForm, usePage } from '@inertiajs/react'; import { useState } from 'react'; import { Editor } from 'richtor'; import 'richtor/styles'; import { ExamUpdateProps } from '../update'; const ExamUpdateHeader = () => { const [open, setOpen] = useState(false); const { props } = usePage(); const user = props.auth.user; const { exam } = props; const statuses = ['draft', 'published', 'archived'].filter((status) => status !== exam.status); const { data, post, setData, processing, errors, reset } = useForm({ tab: 'status', status: '', feedback: '', }); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); post(route('exams.update', exam.id), { onSuccess: () => { reset(); setOpen(false); }, }); }; return (
{user.role === 'instructor' && exam.status !== 'published' && ( )} {user.role === 'admin' && ( Change Exam Status
setData((prev) => ({ ...prev, feedback: value as string, })) } />
Update Status
)}
); }; export default ExamUpdateHeader;