-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b497f88
commit 651a3b3
Showing
10 changed files
with
355 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import prisma from '@/app/libs/prismadb'; // Adjust this import according to your file structure | ||
|
||
interface TicketDetails { | ||
userId: number; | ||
eventId: number; | ||
name?: string | null; | ||
member1?: string | null; | ||
member2?: string | null; | ||
member3?: string | null; | ||
} | ||
|
||
export async function getTicketDetails(userId: number, eventId: number): Promise<TicketDetails | null> { | ||
try { | ||
const ticket = await prisma.ticket.findFirst({ | ||
where: { | ||
userId: userId, | ||
eventId: eventId, | ||
} | ||
}); | ||
|
||
if (!ticket) { | ||
console.log(`Ticket not found for userId: ${userId} and eventId: ${eventId}`); | ||
return null; | ||
} | ||
|
||
return { | ||
userId: ticket.userId, | ||
eventId: ticket.eventId, | ||
name: ticket.name, | ||
member1: ticket.member1, | ||
member2: ticket.member2, | ||
member3: ticket.member3, | ||
|
||
}; | ||
} catch (error) { | ||
console.error('Error retrieving ticket details:', error); | ||
throw error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"use client" | ||
|
||
import Modal from "../../components/modals/Modal"; | ||
import Heading from "../../components/Heading"; | ||
import Lottie from "lottie-react"; | ||
import animationData from '../../../public/assets/animation_ln457zq4.json' | ||
import useTicketModal from "@/app/hooks/useTicketModal"; | ||
import { SafeEvent, SafeUser } from "@/app/types"; | ||
|
||
interface TicketModalProps { | ||
currentUser?: SafeUser | null; | ||
currEvent?: SafeEvent | null; | ||
qrUrl?: any; | ||
} | ||
|
||
const TicketModal: React.FC<TicketModalProps> = ({ | ||
currentUser, | ||
currEvent, | ||
qrUrl | ||
}) => { | ||
const ticketModal = useTicketModal(); | ||
|
||
const bodyContent = ( | ||
<div className='flex flex-col gap-4'> | ||
<Heading | ||
title='Show this during entry' | ||
center | ||
/> | ||
<div className="flex items-center justify-center"> | ||
<img src={qrUrl} alt="Ticket QR Code" /> | ||
</div> | ||
</div> | ||
) | ||
|
||
return ( | ||
<div> | ||
<Modal | ||
isOpen = {ticketModal.isOpen} | ||
title= {`Your ticket for ${currEvent?.title}`} | ||
actionLabel='Okay' | ||
onClose={ticketModal.onClose} | ||
onSubmit={ticketModal.onClose} | ||
body={bodyContent} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export default TicketModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { create } from 'zustand'; | ||
|
||
interface TicketModalSTore { | ||
isOpen: boolean; | ||
onOpen: () => void; | ||
onClose: () => void; | ||
} | ||
|
||
const useTicketModal = create<TicketModalSTore>((set) => ({ | ||
isOpen: false, | ||
onOpen: () => set({ isOpen: true }), | ||
onClose: () => set({ isOpen: false }) | ||
})); | ||
|
||
|
||
export default useTicketModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import QRCode from 'qrcode'; | ||
|
||
const generateQRCode = async (ticketDetails: any) => { | ||
try { | ||
const serializedTicketDetails = JSON.stringify(ticketDetails); | ||
const qrCodeDataURL = await QRCode.toDataURL(serializedTicketDetails); | ||
return qrCodeDataURL; | ||
} catch (error) { | ||
console.error('Error generating QR code:', error); | ||
return null; | ||
} | ||
}; | ||
export default generateQRCode; |
Oops, something went wrong.