From 1d05f342c39f30b1b607da89cf105aafcc14a996 Mon Sep 17 00:00:00 2001 From: Dale B Date: Mon, 5 Aug 2024 11:02:00 +0800 Subject: [PATCH 1/4] chore: disable 3d badge on mobile --- .../{page.jsx => components/badge-3d.jsx} | 2 +- src/app/badge/components/badge-showcase.tsx | 20 +++++++++++++++++++ src/app/badge/page.tsx | 5 +++++ 3 files changed, 26 insertions(+), 1 deletion(-) rename src/app/badge/{page.jsx => components/badge-3d.jsx} (99%) create mode 100644 src/app/badge/components/badge-showcase.tsx create mode 100644 src/app/badge/page.tsx diff --git a/src/app/badge/page.jsx b/src/app/badge/components/badge-3d.jsx similarity index 99% rename from src/app/badge/page.jsx rename to src/app/badge/components/badge-3d.jsx index 86694c9..587ffad 100644 --- a/src/app/badge/page.jsx +++ b/src/app/badge/components/badge-3d.jsx @@ -31,7 +31,7 @@ useTexture.preload( "https://github.com/user-attachments/assets/999b5d58-ac8a-4c20-8fc6-74e8ab7876e7", ); -export default function App() { +export default function Badge3D() { const { debug } = useControls({ debug: false }); return ( diff --git a/src/app/badge/components/badge-showcase.tsx b/src/app/badge/components/badge-showcase.tsx new file mode 100644 index 0000000..69c68f4 --- /dev/null +++ b/src/app/badge/components/badge-showcase.tsx @@ -0,0 +1,20 @@ +"use client"; + +import useMediaQuery from "@/hooks/use-media-query"; +import Badge3D from "./badge-3d"; + +export default function BadgeShowcase() { + const isDesktop = useMediaQuery("(min-width: 768px)"); + + return ( + <> + {isDesktop ? ( + + ) : ( +
+

Badge 2D

+
+ )} + + ); +} diff --git a/src/app/badge/page.tsx b/src/app/badge/page.tsx new file mode 100644 index 0000000..b5d0b3f --- /dev/null +++ b/src/app/badge/page.tsx @@ -0,0 +1,5 @@ +import BadgeShowcase from "./components/badge-showcase"; + +export default async function Badge() { + return ; +} From 48b0f761affed27827953f307fcd1f5cf3035a82 Mon Sep 17 00:00:00 2001 From: Dale B Date: Sun, 4 Aug 2024 15:44:21 +0800 Subject: [PATCH 2/4] fix: update bunx syntax --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f9255c3..7b6b6ed 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "build": "next build", "start": "next start", "lint": "next lint", - "ui:add": "bunx --bun shadcn-ui@latest add" + "ui:add": "bun x --bun shadcn-ui@latest add" }, "dependencies": { "@hookform/resolvers": "^3.3.4", From 6ba0a2f658307d30396bf89483a1eff78261aa50 Mon Sep 17 00:00:00 2001 From: Dale B Date: Mon, 5 Aug 2024 15:45:57 +0800 Subject: [PATCH 3/4] feat: integrate db data to 3d badge --- src/app/badge/components/badge-showcase.tsx | 20 -------- src/app/badge/page.tsx | 5 -- .../[name]}/badge/components/badge-3d.jsx | 33 ++++++++----- .../badge/components/badge-showcase.tsx | 48 +++++++++++++++++++ src/app/event/[name]/badge/page.tsx | 13 +++++ 5 files changed, 83 insertions(+), 36 deletions(-) delete mode 100644 src/app/badge/components/badge-showcase.tsx delete mode 100644 src/app/badge/page.tsx rename src/app/{ => event/[name]}/badge/components/badge-3d.jsx (93%) create mode 100644 src/app/event/[name]/badge/components/badge-showcase.tsx create mode 100644 src/app/event/[name]/badge/page.tsx diff --git a/src/app/badge/components/badge-showcase.tsx b/src/app/badge/components/badge-showcase.tsx deleted file mode 100644 index 69c68f4..0000000 --- a/src/app/badge/components/badge-showcase.tsx +++ /dev/null @@ -1,20 +0,0 @@ -"use client"; - -import useMediaQuery from "@/hooks/use-media-query"; -import Badge3D from "./badge-3d"; - -export default function BadgeShowcase() { - const isDesktop = useMediaQuery("(min-width: 768px)"); - - return ( - <> - {isDesktop ? ( - - ) : ( -
-

Badge 2D

-
- )} - - ); -} diff --git a/src/app/badge/page.tsx b/src/app/badge/page.tsx deleted file mode 100644 index b5d0b3f..0000000 --- a/src/app/badge/page.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import BadgeShowcase from "./components/badge-showcase"; - -export default async function Badge() { - return ; -} diff --git a/src/app/badge/components/badge-3d.jsx b/src/app/event/[name]/badge/components/badge-3d.jsx similarity index 93% rename from src/app/badge/components/badge-3d.jsx rename to src/app/event/[name]/badge/components/badge-3d.jsx index 587ffad..a632bff 100644 --- a/src/app/badge/components/badge-3d.jsx +++ b/src/app/event/[name]/badge/components/badge-3d.jsx @@ -31,7 +31,7 @@ useTexture.preload( "https://github.com/user-attachments/assets/999b5d58-ac8a-4c20-8fc6-74e8ab7876e7", ); -export default function Badge3D() { +export default function Badge3D({ attendee }) { const { debug } = useControls({ debug: false }); return ( @@ -42,7 +42,7 @@ export default function Badge3D() { gravity={[0, -40, 0]} timeStep={1 / 60} > - + @@ -79,7 +79,7 @@ export default function Badge3D() { ); } -function BadgeTexture() { +function BadgeTexture({ attendee }) { // const viewport = useThree((state) => state.viewport); return ( @@ -105,19 +105,31 @@ function BadgeTexture() { bevelSize={0} font="/Geist_Regular.json" height={0} - position={[0.9, 2, 0]} + position={[1.05, 2.1, 0]} rotation={[0, Math.PI, Math.PI]} - size={0.2} - letterSpacing={-0.03} + size={0.15} + letterSpacing={-0.02} > - hyamero + {attendee.firstName} + {attendee.lastName} + + - {/* */} - + diff --git a/src/app/event/[name]/badge/components/badge-showcase.tsx b/src/app/event/[name]/badge/components/badge-showcase.tsx new file mode 100644 index 0000000..d0a5985 --- /dev/null +++ b/src/app/event/[name]/badge/components/badge-showcase.tsx @@ -0,0 +1,48 @@ +"use client"; + +import useMediaQuery from "@/hooks/use-media-query"; +import Badge3D from "./badge-3d"; +import { db } from "@/config/firebase"; +import { doc } from "firebase/firestore"; +import type { Attendee } from "@/lib/types"; +import { usePathname, useSearchParams } from "next/navigation"; +import { useDocumentOnce } from "react-firebase-hooks/firestore"; +import Loading from "../../loading"; + +export default function BadgeShowcase() { + const isDesktop = useMediaQuery("(min-width: 768px)"); + + const pathname = usePathname(); + const searchParams = useSearchParams(); + const certId = searchParams.get("id"); + + const [attendeeValue, attendeeLoading] = useDocumentOnce( + doc(db, `${pathname.split("/")[2]}/data/certificates/${certId}`), + ); + + const attendee = { + ...attendeeValue?.data(), + id: attendeeValue?.id, + } as Attendee; + + if (attendeeLoading) return ; + + if (!attendee.email) + return ( +
+

Certificate not found

+
+ ); + + return ( + <> + {isDesktop ? ( + + ) : ( +
+

Badge 2D

+
+ )} + + ); +} diff --git a/src/app/event/[name]/badge/page.tsx b/src/app/event/[name]/badge/page.tsx new file mode 100644 index 0000000..5ecdb3d --- /dev/null +++ b/src/app/event/[name]/badge/page.tsx @@ -0,0 +1,13 @@ +import { doc, getDoc } from "firebase/firestore"; +import BadgeShowcase from "./components/badge-showcase"; +import { db } from "@/config/firebase"; +import EventNotFound from "../../components/event-not-found"; + +export default async function Badge({ params }: { params: { name: string } }) { + const docRef = doc(db, params.name, "data"); + const docSnap = await getDoc(docRef); + + if (!docSnap.exists()) return ; + + return ; +} From 4c8252c6ccddffc7cd8a226b5ca3a801d520810d Mon Sep 17 00:00:00 2001 From: Dale B Date: Mon, 5 Aug 2024 15:46:36 +0800 Subject: [PATCH 4/4] chore: generate badge-cert selection --- src/app/event/components/event-landing.tsx | 55 ++++++++++++++++++---- src/app/page.tsx | 2 +- src/components/event-buttons.tsx | 2 +- src/components/magicui/retro-grid.tsx | 2 +- 4 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/app/event/components/event-landing.tsx b/src/app/event/components/event-landing.tsx index 43eae2c..71e7d50 100644 --- a/src/app/event/components/event-landing.tsx +++ b/src/app/event/components/event-landing.tsx @@ -20,8 +20,16 @@ import { FormDescription, FormField, FormItem, + FormLabel, FormMessage, } from "@/components/ui/form"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; export type EventDetails = { title: string; @@ -40,6 +48,8 @@ const formSchema = z.object({ message: "This field has to be filled", }) .email("This is not a valid email"), + + type: z.enum(["badge", "cert"]), }); export default function EventLanding({ @@ -53,6 +63,7 @@ export default function EventLanding({ resolver: zodResolver(formSchema), defaultValues: { email: "dale@ban.com", + type: "badge", }, }); @@ -70,7 +81,7 @@ export default function EventLanding({ let message = "⚠️ Certificate Not Found"; querySnapshot.forEach((doc) => { if (doc.data().email) { - push(`/event/${eventCode}/cert?id=${doc.id}`); + push(`/event/${eventCode}/${values.type}?id=${doc.id}`); message = "✅ Certificate found!"; return; } @@ -119,13 +130,41 @@ export default function EventLanding({ )} /> - +
+ ( + + Select type + + + + )} + /> + +
diff --git a/src/app/page.tsx b/src/app/page.tsx index 7343d4b..4db0ee3 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -16,7 +16,7 @@ export default async function Home() { )} > - + ✨ Experimental: Visit 3D Badge diff --git a/src/components/event-buttons.tsx b/src/components/event-buttons.tsx index 2c11194..104d725 100644 --- a/src/components/event-buttons.tsx +++ b/src/components/event-buttons.tsx @@ -78,7 +78,7 @@ export function EventButtons() { const SearchEventForm = ({}) => { const router = useRouter(); - const [event, setEvent] = useState(""); + const [event, setEvent] = useState("hacking-ai"); const [loading, setLoading] = useState(false); const handleSubmit = (e: FormEvent) => { diff --git a/src/components/magicui/retro-grid.tsx b/src/components/magicui/retro-grid.tsx index f389b16..d7d3610 100644 --- a/src/components/magicui/retro-grid.tsx +++ b/src/components/magicui/retro-grid.tsx @@ -4,7 +4,7 @@ export default function RetroGrid({ className }: { className?: string }) { return (