diff --git a/backend/src/app.ts b/backend/src/app.ts index 0b7b542..725cf0d 100644 --- a/backend/src/app.ts +++ b/backend/src/app.ts @@ -3566,6 +3566,7 @@ app.post('/api/birds', requireAuth, requireWriteAccess, requireWorkspaceRole(['o toWorkspaceId: req.auth!.workspace.id, locationLabel: bird!.location_label, locationDetails: bird!.location_details, + eventDate: emptyToNull(parsed.data.locationDate), createdByUserId: req.auth!.user.id, }); res.status(201).json({ bird: normalizeBird(bird!) }); @@ -3945,6 +3946,7 @@ app.put('/api/birds/:birdId', requireAuth, requireWriteAccess, requireWorkspaceR toWorkspaceId: req.auth!.workspace.id, locationLabel: bird.location_label, locationDetails: bird.location_details, + eventDate: emptyToNull(parsed.data.locationDate), createdByUserId: req.auth!.user.id, }); } diff --git a/backend/src/schemas.ts b/backend/src/schemas.ts index cefdaf9..34910ba 100644 --- a/backend/src/schemas.ts +++ b/backend/src/schemas.ts @@ -104,6 +104,7 @@ export const locationSearchSchema = z.object({ }); export const birdSchema = z.object({ + locationDate: dateStringSchema.optional().or(z.literal('')), name: z.string().trim().min(1).max(120), tagId: z.string().trim().max(80).optional().or(z.literal('')), species: z.string().trim().min(1).max(120), diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 45fdf81..f9e4b95 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -271,6 +271,7 @@ type FlockNoteFormState = { }; type BirdFormState = { + locationDate: string; name: string; tagId: string; species: string; @@ -812,6 +813,7 @@ const VerifiedLocationSearchField = ({ }; const emptyBirdForm: BirdFormState = { + locationDate: '', name: '', tagId: '', species: '', @@ -966,6 +968,7 @@ const ProviderIcon = ({ providerKey }: { providerKey: AuthProvider['providerKey' const sortBirdsByName = (nextBirds: Bird[]) => [...nextBirds].sort((left, right) => left.name.localeCompare(right.name)); const toBirdForm = (bird: Bird): BirdFormState => ({ + locationDate: '', name: bird.name, tagId: bird.tagId ?? '', species: bird.species, @@ -3988,7 +3991,7 @@ function App() { const response = await apiFetch(isEditing ? `/birds/${editingBirdId}` : '/birds', authToken, { method, headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ ...birdForm, hatchDay: birdForm.dateOfBirth, locationLabel }), + body: JSON.stringify({ ...birdForm, hatchDay: birdForm.dateOfBirth, locationLabel, locationDate: birdForm.locationDate || getLocalDateString() }), }); if (!response.ok) { @@ -6586,27 +6589,6 @@ function App() { ) : null} -
Location
-Location
+