Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
quick007 committed Nov 29, 2023
2 parents d00b8a4 + 0c79806 commit aa7941d
Show file tree
Hide file tree
Showing 28 changed files with 386 additions and 166 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ jobs:
deno-version: v1.x

- name: Build step
env:
ALLOWED_EMAILS: ${{ secrets.ALLOWED_EMAILS }}
IMAGEKIT_ENABLED: ${{ secrets.IMAGEKIT_ENABLED }}
IMAGEKIT_PRIVATE_KEY: ${{ secrets.IMAGEKIT_PRIVATE_KEY }}
IMAGEKIT_PUBLIC_KEY: ${{ secrets.IMAGEKIT_PUBLIC_KEY }}
IMAGEKIT_URL_ENDPOINT: ${{ secrets.IMAGEKIT_URL_ENDPOINT }}
env:
ALLOWED_EMAILS: ${{ secrets.ALLOWED_EMAILS }}
IMAGEKIT_ENABLED: ${{ secrets.IMAGEKIT_ENABLED }}
IMAGEKIT_PRIVATE_KEY: ${{ secrets.IMAGEKIT_PRIVATE_KEY }}
IMAGEKIT_PUBLIC_KEY: ${{ secrets.IMAGEKIT_PUBLIC_KEY }}
IMAGEKIT_URL_ENDPOINT: ${{ secrets.IMAGEKIT_URL_ENDPOINT }}
run: "deno task build" # 📝 Update the build command(s) if necessary

- name: Upload to Deno Deploy
Expand Down
2 changes: 1 addition & 1 deletion components/buttons/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Button = ({
href?: string;
onClick?: () => void;
small?: boolean;
type?: string
type?: string;
}) => {
const Wrapper = (props: {
children: ComponentChildren;
Expand Down
4 changes: 2 additions & 2 deletions components/buttons/cta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const CTA = ({
btnSize == "norm"
? "w-64 [@media(min-width:300px)]:w-72 h-12 text-lg "
: btnSize == "sm"
? "w-40 h-10"
: "px-2 h-8"
? "w-40 h-10"
: "px-2 h-8"
} rounded-md font-semibold peer z-10 hover:brightness-95 transition hover:focus:ring-1 hover:focus:brightness-100 disabled:brightness-90 disabled:cursor-not-allowed ${
btnType == "cta"
? "bg-theme-normal ring-[#da7351] text-white "
Expand Down
4 changes: 1 addition & 3 deletions fresh.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { defineConfig } from "$fresh/server.ts";
import unocssPlugin from "@/utils/plugins/unocss.ts";
import {
kvInsightsPlugin,
} from "https://deno.land/x/deno_kv_insights@v0.7.0-beta/mod.ts";
import { kvInsightsPlugin } from "https://deno.land/x/deno_kv_insights@v0.7.0-beta/mod.ts";
import { kv } from "@/utils/db/kv.ts";

export default defineConfig({
Expand Down
8 changes: 6 additions & 2 deletions islands/components/peices/ticket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ export default function Ticket({
) : (
<QR />
)}
<p class="text-xs text-gray-500 text-center mt-4">ID: {id.split("_")[2]}</p>
<p class="text-xs text-gray-500 text-center mt-4">
ID: {id.split("_")[2]}
</p>
<div class="grid gap-2">
<div>
<h5 class="font-medium mb-0.5 mt-4 text-sm text-center">Event Date & Time</h5>
<h5 class="font-medium mb-0.5 mt-4 text-sm text-center">
Event Date & Time
</h5>
<div class="bg-gray-100 border font-medium px-1.5 rounded-md text-center">
{fmtDate(new Date(showTime.startDate!))}
</div>
Expand Down
8 changes: 4 additions & 4 deletions islands/components/pickers/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ export default function ImagePicker({
{loading
? "Converting..."
: uploading
? "Uploading..."
: dragging
? "Drop Image to Upload"
: "Upload Banner Image"}
? "Uploading..."
: dragging
? "Drop Image to Upload"
: "Upload Banner Image"}
</p>
</div>
<input
Expand Down
2 changes: 1 addition & 1 deletion islands/components/pickers/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function Select({
className,
selectClassName,
selected,
disabled
disabled,
}: {
options: string[];
updateOption?: (option: number) => void;
Expand Down
4 changes: 2 additions & 2 deletions islands/entriesManagement.tsx
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;
4 changes: 2 additions & 2 deletions islands/entryManagement.tsx
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;
3 changes: 2 additions & 1 deletion islands/events/editing/delete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export default function EventDeletion({ eventID }: { eventID: string }) {
>
<h5 className="font-bold text-xl">Delete Event</h5>
<p>
Are you sure you want to delete this event? This action is irrevocable and cannot be undone!
Are you sure you want to delete this event? This action is
irrevocable and cannot be undone!
</p>
<CTA
btnType="secondary"
Expand Down
6 changes: 1 addition & 5 deletions islands/events/list/filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ export default function HomeFilters({
ascending.value = !ascending.value;
}}
/>
<Button
label={`Search Events`}
icon={<IconSearch class="w-5 h-5" />}

/>
<Button label={`Search Events`} icon={<IconSearch class="w-5 h-5" />} />
</form>
</>
);
Expand Down
10 changes: 7 additions & 3 deletions islands/events/teams/filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import Button from "@/components/buttons/button.tsx";
import Search from "$tabler/search.tsx";
import { Signal } from "@preact/signals";

export default function TeamFilters(
{ query, sort }: { query: Signal<string>; sort: Signal<number> },
) {
export default function TeamFilters({
query,
sort,
}: {
query: Signal<string>;
sort: Signal<number>;
}) {
return (
<form
class="flex gap-2 flex-col md:flex-row"
Expand Down
56 changes: 29 additions & 27 deletions islands/events/teams/manage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function ManageUser({

const rolesToShow = ["Admin", "Manager", "Scanner"].filter((r, i) => {
if (clientRole == Roles.OWNER) return true;
if ((clientRole <= user.role)) {
if (clientRole <= user.role) {
return i + 1 >= user.role;
}
});
Expand Down Expand Up @@ -103,42 +103,44 @@ export default function ManageUser({
<Select
options={["Admin", "Manager", "Scanner"].filter((r, i) => {
if (clientRole == Roles.OWNER) return true;
if ((clientRole <= user.role)) {
if (clientRole <= user.role) {
return i + 1 >= user.role;
}
})}
selectClassName="py-1"
// Owner comes first and that's not in this dropdown
selected={user.role - 1 - rolesToShow.length - 3}
updateOption={updateUserRole}
disabled={clientRole == Roles.SCANNER || (clientRole > user.role)}
disabled={clientRole == Roles.SCANNER || clientRole > user.role}
/>

{(clientRole == Roles.SCANNER ||
(clientRole >= user.role && user.email != client.email))
? <></>
: (
<Dropdown
options={[
...(user.role == Roles.OWNER
? [{
content: "Transfer Ownership",
onClick: () => (transferOpen.value = true),
}]
: []),
{
content: "Remove User",
onClick: removeUser,
},
]}
{clientRole == Roles.SCANNER ||
(clientRole >= user.role && user.email != client.email) ? (
<></>
) : (
<Dropdown
options={[
...(user.role == Roles.OWNER
? [
{
content: "Transfer Ownership",
onClick: () => (transferOpen.value = true),
},
]
: []),
{
content: "Remove User",
onClick: removeUser,
},
]}
>
<div
className={`w-8 grid place-items-center border h-8 rounded-md`}
>
<div
className={`w-8 grid place-items-center border h-8 rounded-md`}
>
<DotsVertical class="h-5 w-5" />
</div>
</Dropdown>
)}
<DotsVertical class="h-5 w-5" />
</div>
</Dropdown>
)}
</div>
</>
);
Expand Down
4 changes: 2 additions & 2 deletions islands/queueManagement.tsx
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;
22 changes: 10 additions & 12 deletions islands/tickets/filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import Button from "@/components/buttons/button.tsx";
import Search from "$tabler/search.tsx";
import { Signal } from "@preact/signals";

export default function TeamFilters(
{ query, sort }: { query: Signal<string>; sort: Signal<number> },
) {
export default function TicketsFilters({
query,
sort,
}: {
query: Signal<string>;
sort: Signal<number>;
}) {
return (
<form
class="flex gap-2 flex-col md:flex-row"
class="flex gap-2 mt-8 flex-col md:flex-row"
onSubmit={(e) => {
e.preventDefault();

Expand All @@ -26,23 +30,17 @@ export default function TeamFilters(
location.href = url.toString();
}}
>
<input
class="rounded-md border py-1.5 px-2 grow"
placeholder="Search tickets..."
value={query}
onInput={(e) => (query.value = e.currentTarget.value)}
/>
<div class="flex gap-2">
<Select
options={["Email A-Z", "Email Z-A"]}
options={["Purchused", "Email A-Z", "Email Z-A"]}
selectClassName="py-2"
className="grow"
selected={sort.value}
updateOption={(e) => (sort.value = e)}
/>
<Button
icon={<Search class="w-5 h-5" />}
label="Search Tickets"
label="Search Users"
type="submit"
/>
</div>
Expand Down
11 changes: 6 additions & 5 deletions routes/api/events/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,19 @@ export const handler: Handlers = {
imageKit!.deleteFile(event.value.banner.id);
}

let atomic = kv.atomic()
.delete(["event", eventID])
let atomic = kv.atomic().delete(["event", eventID]);

const members = await kv.getMany<User[]>(event.value.members.map(e => ["user", e.email]))
const members = await kv.getMany<User[]>(
event.value.members.map((e) => ["user", e.email]),
);

for (const member of members) {
const user = member.value!;

atomic = atomic.set(["user", user.email], {
...user,
events: user.events.filter(e => e != eventID)
})
events: user.events.filter((e) => e != eventID),
});
}

const atomicResult = await atomic.commit();
Expand Down
86 changes: 86 additions & 0 deletions routes/api/events/fetch.ts
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,
});
},
};
Loading

0 comments on commit aa7941d

Please sign in to comment.