-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add registration dialog #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,278 @@ | ||||||||||||
| import { useForm } from '@tanstack/react-form' | ||||||||||||
|
|
||||||||||||
| import * as z from 'zod' | ||||||||||||
|
|
||||||||||||
| import { RegistrationAnswerSchema } from '@events.comp-soc.com/shared' | ||||||||||||
| import type { | ||||||||||||
| CustomField, | ||||||||||||
| RegistrationFormAnswer, | ||||||||||||
| } from '@events.comp-soc.com/shared' | ||||||||||||
|
|
||||||||||||
| import { | ||||||||||||
| Field, | ||||||||||||
| FieldError, | ||||||||||||
| FieldGroup, | ||||||||||||
| FieldLabel, | ||||||||||||
| } from '@/components/ui/field.tsx' | ||||||||||||
| import { Input } from '@/components/ui/input.tsx' | ||||||||||||
| import { | ||||||||||||
| Select, | ||||||||||||
| SelectContent, | ||||||||||||
| SelectItem, | ||||||||||||
| SelectTrigger, | ||||||||||||
| SelectValue, | ||||||||||||
| } from '@/components/ui/select.tsx' | ||||||||||||
| import { Textarea } from '@/components/ui/textarea.tsx' | ||||||||||||
| import { Button } from '@/components/ui/button.tsx' | ||||||||||||
| import { | ||||||||||||
| Dialog, | ||||||||||||
| DialogContent, | ||||||||||||
| DialogDescription, | ||||||||||||
| DialogFooter, | ||||||||||||
| DialogHeader, | ||||||||||||
| DialogTitle, | ||||||||||||
| } from '@/components/ui/dialog.tsx' | ||||||||||||
|
|
||||||||||||
| function buildRegistrationSchema(formStructure: Array<CustomField>) { | ||||||||||||
| const schemaShape: Record<string, z.ZodTypeAny> = {} | ||||||||||||
|
|
||||||||||||
| formStructure.forEach((field) => { | ||||||||||||
| let fieldSchema: z.ZodTypeAny | ||||||||||||
|
|
||||||||||||
| switch (field.type) { | ||||||||||||
| case 'input': | ||||||||||||
| case 'textarea': | ||||||||||||
| fieldSchema = field.required | ||||||||||||
| ? z.string().min(1, `${field.label} is required`) | ||||||||||||
| : z.string().optional() | ||||||||||||
| break | ||||||||||||
| case 'select': | ||||||||||||
| if (field.options && field.options.length > 0) { | ||||||||||||
| fieldSchema = field.required | ||||||||||||
| ? z.enum(field.options as [string, ...Array<string>], { | ||||||||||||
| error: () => ({ message: `${field.label} is required` }), | ||||||||||||
| }) | ||||||||||||
| : z.enum(field.options as [string, ...Array<string>]).optional() | ||||||||||||
|
||||||||||||
| : z.enum(field.options as [string, ...Array<string>]).optional() | |
| : z | |
| .enum(field.options as [string, ...Array<string>]) | |
| .or(z.literal('')) | |
| .optional() |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The onOpenChange prop type is defined as () => void, but the Dialog component from Radix UI expects (open: boolean) => void. This type mismatch means the component won't receive the proper boolean value indicating whether the dialog should be open or closed. Update the type to onOpenChange: (open: boolean) => void to match the Dialog API.
| onOpenChange: () => void | |
| onOpenChange: (open: boolean) => void |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo in the CSS class name: "justify-start!" should be "!justify-start" following Tailwind's important modifier syntax. The exclamation mark should precede the utility class name, not follow it.
| <DialogFooter className="justify-start!"> | |
| <DialogFooter className="!justify-start"> |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The form element is placed outside the DialogContent, which may cause issues with form submission and keyboard navigation. In Radix UI Dialog, portal-based content can have accessibility and focus management issues when form elements are structured this way. Consider placing the form element inside the DialogContent or wrapping just the DialogContent with the form to ensure proper behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The schema change removes support for array values (z.array(z.string())) from RegistrationAnswerSchema, but the buildRegistrationSchema function in event-registration-form-dialog.tsx doesn't handle multi-select fields. If multi-select fields were previously supported or are planned, this breaking change could cause data loss or errors. If array values are no longer needed, ensure this is intentional and that no existing registrations use array values.