'use server';

import { redirect } from 'next/navigation';
import { prisma } from '@/lib/prisma';

export async function markRequestDone(formData: FormData) {
  const id = String(formData.get('id') ?? '');
  if (!id) return;
  await prisma.customRequest.update({ where: { id }, data: { status: 'DONE' } });
  redirect('/admin/custom-requests');
}

export async function markRequestNew(formData: FormData) {
  const id = String(formData.get('id') ?? '');
  if (!id) return;
  await prisma.customRequest.update({ where: { id }, data: { status: 'NEW' } });
  redirect('/admin/custom-requests');
}

export async function deleteRequest(formData: FormData) {
  const id = String(formData.get('id') ?? '');
  if (!id) return;
  await prisma.customRequest.delete({ where: { id } });
  redirect('/admin/custom-requests');
}
