This repository has been archived on 2026-01-31. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
nextjs-serve-actions/app/components/Settings/Profiles/actions/DeleteProfileAction.ts
2024-05-23 16:55:29 +02:00

23 lines
431 B
TypeScript

'use server';
import { z } from 'zod';
import prisma from '../../../../../prisma/prisma';
export async function DeleteProfileAction(id: string) {
const validatedBody = z.string().safeParse(id);
if (!validatedBody.success) {
throw new Error('Bad request');
}
try {
await prisma.profile.delete({
where: {
id
}
});
} catch (error) {
throw new Error(`Failed to delete profile`);
}
}