| 71 | } |
| 72 | |
| 73 | export async function deleteBounty(bountyId: string) { |
| 74 | const session = await getServerSession(authOptions); |
| 75 | |
| 76 | if (!session || !session.user || session.user.role !== ROLES.ADMIN) { |
| 77 | return { error: 'Unauthorized or insufficient permissions' }; |
| 78 | } |
| 79 | try { |
| 80 | const deleteBounty = await prisma.bountySubmission.delete({ |
| 81 | where: { id: bountyId }, |
| 82 | }); |
| 83 | return { success: !!deleteBounty }; |
| 84 | } catch (e) { |
| 85 | return { error: 'An error occurred while approving the bounty.' }; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | export async function confirmBounty(bountyId: string, amount: number) { |
| 90 | const session = await getServerSession(authOptions); |