mirror of
https://github.com/EdiFarcas/Giveaway-app.git
synced 2026-06-28 21:00:48 +03:00
Initial Entry logic
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
"use server"
|
||||
import { db } from "@/lib/db";
|
||||
|
||||
async function handleEnterGiveawayClick(giveawayId: string, entryValue: number, userId: string) {
|
||||
|
||||
await db.entry.create({
|
||||
data: {
|
||||
userId: userId,
|
||||
giveawayId: giveawayId,
|
||||
weight: 1,
|
||||
},
|
||||
});
|
||||
|
||||
await db.user.update({
|
||||
where: { id: userId },
|
||||
data: {
|
||||
coins: { decrement: entryValue },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export default handleEnterGiveawayClick;
|
||||
Reference in New Issue
Block a user