-
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.
Merge branch 'main' of https://github.com/Wave-Studio/Events
- Loading branch information
Showing
28 changed files
with
386 additions
and
166 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
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
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import EntriesManagement from 'https://deno.land/x/deno_kv_insights@v0.7.0-beta/lib/entry/islands/entriesManagement.tsx'; | ||
import EntriesManagement from "https://deno.land/x/deno_kv_insights@v0.7.0-beta/lib/entry/islands/entriesManagement.tsx"; | ||
|
||
export default EntriesManagement; | ||
export default EntriesManagement; |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import EntryManagement from 'https://deno.land/x/deno_kv_insights@v0.7.0-beta/lib/entry/islands/entryManagement.tsx'; | ||
import EntryManagement from "https://deno.land/x/deno_kv_insights@v0.7.0-beta/lib/entry/islands/entryManagement.tsx"; | ||
|
||
export default EntryManagement; | ||
export default EntryManagement; |
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import QueueManagement from 'https://deno.land/x/deno_kv_insights@v0.7.0-beta/lib/queue/islands/queueManagement.tsx'; | ||
import QueueManagement from "https://deno.land/x/deno_kv_insights@v0.7.0-beta/lib/queue/islands/queueManagement.tsx"; | ||
|
||
export default QueueManagement; | ||
export default QueueManagement; |
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,86 @@ | ||
import { Handlers } from "$fresh/server.ts"; | ||
import { Event, getUser, kv, Ticket } from "@/utils/db/kv.ts"; | ||
|
||
export const handler: Handlers = { | ||
async POST(req) { | ||
const user = await getUser(req); | ||
|
||
if (user == undefined) { | ||
return new Response( | ||
JSON.stringify({ | ||
error: { | ||
message: "You must be logged in to scan tickets for an event", | ||
}, | ||
}), | ||
{ | ||
status: 400, | ||
}, | ||
); | ||
} | ||
|
||
const { | ||
eventID, | ||
ticketID, | ||
showtimeID, | ||
}: { eventID: string; ticketID: string; showtimeID?: string } = | ||
await req.json(); | ||
|
||
const event = await kv.get<Event>(["event", eventID]); | ||
|
||
if (event.value == undefined) { | ||
return new Response( | ||
JSON.stringify({ | ||
error: { | ||
message: "Unknown event", | ||
}, | ||
}), | ||
{ | ||
status: 400, | ||
}, | ||
); | ||
} | ||
|
||
if (event.value.members.find((m) => m.email == user.email) == undefined) { | ||
return new Response( | ||
JSON.stringify({ | ||
error: { | ||
message: "You are not a member of this event", | ||
}, | ||
}), | ||
{ | ||
status: 400, | ||
}, | ||
); | ||
} | ||
|
||
const isFullTicket = ticketID.split("_").length == 3; | ||
const soloTicketID = ticketID.split("_").reverse()[0]; | ||
const showtime = isFullTicket | ||
? ticketID.split("_")[1] | ||
: (showtimeID as string); | ||
|
||
const ticket = await kv.get<Ticket>([ | ||
"ticket", | ||
eventID, | ||
showtime, | ||
`${isFullTicket ? ticketID : `${eventID}_${showtime}_${soloTicketID}`}`, | ||
]); | ||
|
||
if (ticket.value == undefined) { | ||
return new Response( | ||
JSON.stringify({ | ||
error: { | ||
message: "Unknown ticket", | ||
}, | ||
}), | ||
{ | ||
status: 400, | ||
}, | ||
); | ||
} | ||
|
||
return new Response(JSON.stringify(ticket.value), { | ||
status: 200, | ||
}); | ||
}, | ||
}; |
Oops, something went wrong.