mirror of
https://github.com/EdiFarcas/Giveaway-app.git
synced 2026-06-28 23:00:55 +03:00
Update giveaway entry count
This commit is contained in:
Generated
+2491
-2328
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,13 @@
|
|||||||
|
import { db } from "@/lib/db";
|
||||||
|
|
||||||
|
async function entrycount(userId: string, giveawayId: string) {
|
||||||
|
const entryCount = await db.entry.count({
|
||||||
|
where: {
|
||||||
|
userId: userId,
|
||||||
|
giveawayId: giveawayId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return entryCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default entrycount;
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import handleEnterGiveawayClick from './GiveawayCardServer';
|
import handleEnterGiveawayClick from './GiveawayCardServer';
|
||||||
|
import entrycount from './EntryCount';
|
||||||
|
|
||||||
interface GiveawayCardProps {
|
interface GiveawayCardProps {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -34,6 +35,7 @@ const GiveawayCard: React.FC<GiveawayCardProps> = ({ id, title, description, ima
|
|||||||
<h3 className="text-lg font-bold mb-2">{title}</h3>
|
<h3 className="text-lg font-bold mb-2">{title}</h3>
|
||||||
<p className="text-gray-600 text-sm">{description}</p>
|
<p className="text-gray-600 text-sm">{description}</p>
|
||||||
<p className="text-gray-600 text-sm mt-2">Value: {value} coins</p>
|
<p className="text-gray-600 text-sm mt-2">Value: {value} coins</p>
|
||||||
|
<p className="text-gray-600 text-sm mt-2">Your entries: {entrycount(userId, id)}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="p-4 flex items-center">
|
<div className="p-4 flex items-center">
|
||||||
<button
|
<button
|
||||||
|
|||||||
Reference in New Issue
Block a user