creavte venue inside create event

This commit is contained in:
2025-07-28 08:10:07 -04:00
parent 27590f9509
commit 6ea3b151c3
4 changed files with 208 additions and 31 deletions

View File

@@ -7,7 +7,7 @@ import { Label } from '../ui/label'
import { toast } from 'sonner'
interface CreateVenueFormProps {
onSuccess?: () => void
onSuccess?: (newVenueId?: string) => void
}
export default function CreateVenueForm({ onSuccess }: CreateVenueFormProps) {
@@ -38,7 +38,7 @@ export default function CreateVenueForm({ onSuccess }: CreateVenueFormProps) {
}
setLoading(true)
try {
try {
const res = await fetch('/api/venues/create', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
@@ -47,6 +47,9 @@ export default function CreateVenueForm({ onSuccess }: CreateVenueFormProps) {
if (!res.ok) throw new Error('Failed to create venue')
const data = await res.json()
const newVenueId = data?.id
toast.success('Venue created!')
setFormData({
name: '',
@@ -59,7 +62,7 @@ export default function CreateVenueForm({ onSuccess }: CreateVenueFormProps) {
email: ''
})
if (onSuccess) onSuccess()
if (onSuccess) onSuccess(newVenueId)
} catch (err) {
console.error(err)
toast.error('Something went wrong')