Skip to content

Commit

Permalink
chore: generate badge-cert selection
Browse files Browse the repository at this point in the history
  • Loading branch information
hyamero committed Aug 5, 2024
1 parent 6ba0a2f commit 4c8252c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 11 deletions.
55 changes: 47 additions & 8 deletions src/app/event/components/event-landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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({
Expand All @@ -53,6 +63,7 @@ export default function EventLanding({
resolver: zodResolver(formSchema),
defaultValues: {
email: "dale@ban.com",
type: "badge",
},
});

Expand All @@ -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;
}
Expand Down Expand Up @@ -119,13 +130,41 @@ export default function EventLanding({
</FormItem>
)}
/>
<Button
type="submit"
className="w-full font-semibold"
disabled={loading}
>
{loading ? <Icons.spinner /> : "Get Certificate"}
</Button>
<div className="space-y-1">
<FormField
control={form.control}
name="type"
render={({ field }) => (
<FormItem>
<FormLabel>Select type</FormLabel>
<Select onValueChange={field.onChange} {...field}>
<FormControl>
<SelectTrigger>
<SelectValue placeholder="Select a type" />
</SelectTrigger>
</FormControl>
<SelectContent>
<SelectItem className="cursor-pointer" value="badge">
Badge
</SelectItem>
<SelectItem className="cursor-pointer" value="cert">
Certificate
</SelectItem>
</SelectContent>
</Select>
<FormMessage />
</FormItem>
)}
/>
<Button
variant="secondary"
type="submit"
className="w-full font-medium"
disabled={loading}
>
{loading ? <Icons.spinner /> : "Generate"}
</Button>
</div>
</form>
</Form>
</CardContent>
Expand Down
2 changes: 1 addition & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default async function Home() {
)}
>
<AnimatedShinyText className="inline-flex items-center justify-center px-4 py-1 transition ease-out hover:text-neutral-600 hover:duration-300 hover:dark:text-neutral-400">
<Link href="/badge">
<Link href={`/event/hacking-ai/badge?id=Z5jdHi6BmyT`}>
✨ Experimental:
<span className="font-semibold"> Visit 3D Badge</span>
</Link>
Expand Down
2 changes: 1 addition & 1 deletion src/components/event-buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLFormElement>) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/magicui/retro-grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default function RetroGrid({ className }: { className?: string }) {
return (
<div
className={cn(
"pointer-events-none absolute size-full overflow-hidden opacity-70 [perspective:200px]",
"pointer-events-none absolute size-full overflow-hidden [perspective:200px]",
className,
)}
>
Expand Down

0 comments on commit 4c8252c

Please sign in to comment.