-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add ability to delete events and add confirmation dialogs #35
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,49 @@ | ||
| import { useNavigate } from '@tanstack/react-router' | ||
| import { | ||
| Dialog, | ||
| DialogContent, | ||
| DialogDescription, | ||
| DialogHeader, | ||
| DialogTitle, | ||
| DialogTrigger, | ||
| } from '@/components/ui/dialog.tsx' | ||
| import { Button } from '@/components/ui/button.tsx' | ||
| import { useDeleteEvent } from '@/lib/hooks/use-delete-event.tsx' | ||
|
|
||
| function DeleteEventButton({ eventId }: { eventId: string }) { | ||
| const navigate = useNavigate({ from: '/events/$eventId' }) | ||
| const { deleteEvent, isDeleting } = useDeleteEvent(eventId) | ||
|
|
||
| return ( | ||
| <Dialog> | ||
| <DialogTrigger asChild> | ||
| <Button variant="secondary">Delete</Button> | ||
| </DialogTrigger> | ||
| <DialogContent> | ||
| <DialogHeader> | ||
| <DialogTitle>Delete Event</DialogTitle> | ||
| <DialogDescription> | ||
| Are you sure you want to delete this event? This action is permanent | ||
| and will remove all associated registrations and data. | ||
| </DialogDescription> | ||
| </DialogHeader> | ||
| <div className="flex justify-start gap-3 mt-4"> | ||
| <Button | ||
| disabled={isDeleting} | ||
| onClick={() => { | ||
| deleteEvent(undefined, { | ||
| onSuccess: () => { | ||
| void navigate({ to: '/', replace: true }) | ||
| }, | ||
| }) | ||
| }} | ||
| > | ||
| {isDeleting ? 'Deleting...' : 'Confirm Delete'} | ||
| </Button> | ||
| </div> | ||
| </DialogContent> | ||
| </Dialog> | ||
|
Comment on lines
+18
to
+45
|
||
| ) | ||
| } | ||
|
|
||
| export default DeleteEventButton | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { Button } from '@/components/ui/button.tsx' | ||
| import { usePublishEvent } from '@/lib/hooks/use-publish-event.tsx' | ||
| import { | ||
| Dialog, | ||
| DialogContent, | ||
| DialogDescription, | ||
| DialogHeader, | ||
| DialogTitle, | ||
| DialogTrigger, | ||
| } from '@/components/ui/dialog.tsx' | ||
|
|
||
| function PublishEventButton({ eventId }: { eventId: string }) { | ||
| const { publishEvent, isPublishing } = usePublishEvent(eventId) | ||
|
|
||
| return ( | ||
|
||
| <Dialog> | ||
| <DialogTrigger asChild> | ||
| <Button>Publish</Button> | ||
| </DialogTrigger> | ||
| <DialogContent> | ||
| <DialogHeader> | ||
| <DialogTitle>Publish Event</DialogTitle> | ||
| <DialogDescription> | ||
| Are you sure you want to publish this event? Once published, it will | ||
| be visible in the search results and students will be able to | ||
| register. | ||
| </DialogDescription> | ||
| </DialogHeader> | ||
| <div className="flex justify-start gap-3 mt-4"> | ||
| <Button onClick={() => publishEvent()} disabled={isPublishing}> | ||
| {isPublishing ? 'Publishing' : 'Publish'} | ||
| </Button> | ||
| </div> | ||
| </DialogContent> | ||
| </Dialog> | ||
|
Comment on lines
+16
to
+35
|
||
| ) | ||
| } | ||
|
|
||
| export default PublishEventButton | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { useState } from 'react' | ||
| import type { CustomField } from '@events.comp-soc.com/shared' | ||
| import { Button } from '@/components/ui/button.tsx' | ||
| import { useCommitteeAuth } from '@/lib/auth.ts' | ||
| import EventRegistrationFormDialog from '@/components/forms/event-registration-form-dialog.tsx' | ||
|
|
||
| function RegisterEventButton({ | ||
| form, | ||
| title, | ||
| }: { | ||
| form: Array<CustomField> | ||
| title: string | ||
| }) { | ||
| const [open, setOpen] = useState(false) | ||
| const { isAuthenticated } = useCommitteeAuth() | ||
|
|
||
| return ( | ||
| <> | ||
| <Button onClick={() => setOpen(!open)} disabled={!isAuthenticated}> | ||
| Register Now | ||
| </Button> | ||
| <EventRegistrationFormDialog | ||
| onFormSubmit={() => {}} | ||
| formStructure={form} | ||
| isOpen={open} | ||
| onOpenChange={() => setOpen(!open)} | ||
| eventTitle={title} | ||
| /> | ||
| </> | ||
| ) | ||
| } | ||
|
|
||
| export default RegisterEventButton |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,24 @@ | ||||||||||||||||||||||||||||||||||
| import type { CustomField } from '@events.comp-soc.com/shared' | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| export const DEFAULT_FIELDS: Array<CustomField> = [ | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| id: `field-${Date.now()}-1`, | ||||||||||||||||||||||||||||||||||
| type: 'input', | ||||||||||||||||||||||||||||||||||
| label: 'University Email', | ||||||||||||||||||||||||||||||||||
| required: true, | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| id: `field-${Date.now()}-1`, | ||||||||||||||||||||||||||||||||||
| type: 'select', | ||||||||||||||||||||||||||||||||||
| label: 'University Year', | ||||||||||||||||||||||||||||||||||
| required: true, | ||||||||||||||||||||||||||||||||||
| options: ['1', '2', '3', '4', 'Masters', 'PhD'], | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| id: `field-${Date.now()}-2`, | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+11
to
+18
|
||||||||||||||||||||||||||||||||||
| id: `field-${Date.now()}-1`, | |
| type: 'select', | |
| label: 'University Year', | |
| required: true, | |
| options: ['1', '2', '3', '4', 'Masters', 'PhD'], | |
| }, | |
| { | |
| id: `field-${Date.now()}-2`, | |
| id: `field-${Date.now()}-2`, | |
| type: 'select', | |
| label: 'University Year', | |
| required: true, | |
| options: ['1', '2', '3', '4', 'Masters', 'PhD'], | |
| }, | |
| { | |
| id: `field-${Date.now()}-3`, |
This file was deleted.
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 directory name "controlls" appears to be misspelled. The correct spelling should be "controls" (with one 'l'). This affects the import paths in other files and should be renamed for consistency with standard English spelling.