diff --git a/backend/src/app.ts b/backend/src/app.ts index 5d62e8d..2899197 100644 --- a/backend/src/app.ts +++ b/backend/src/app.ts @@ -3745,6 +3745,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!) }); @@ -4124,6 +4125,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 106c610..949f27d 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 1ce2ac1..b0e455f 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -288,6 +288,7 @@ type FlockNoteFormState = { }; type BirdFormState = { + locationDate: string; name: string; tagId: string; species: string; @@ -841,6 +842,7 @@ const VerifiedLocationSearchField = ({ }; const emptyBirdForm: BirdFormState = { + locationDate: '', name: '', tagId: '', species: '', @@ -1007,6 +1009,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, @@ -4302,7 +4305,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) { @@ -7130,27 +7133,6 @@ function App() { ) : null} -
-

Location

-

Mappable location

-
- searchVerifiedLocations(birdLocationSearch, setBirdLocationSearch)} - onSelect={(location) => { - const locationLabel = formatVerifiedLocationLabel(location); - setBirdForm({ ...birdForm, locationDetails: location, locationLabel }); - setBirdLocationSearch({ ...emptyLocationSearchState, query: locationLabel }); - }} - onClear={() => { - setBirdForm({ ...birdForm, locationDetails: emptyVerifiedLocationDetails, locationLabel: '' }); - setBirdLocationSearch(emptyLocationSearchState); - }} - />
Gender
@@ -7289,6 +7271,37 @@ function App() { ))}
+
+

Location

+

Mappable location

+
+ searchVerifiedLocations(birdLocationSearch, setBirdLocationSearch)} + onSelect={(location) => { + const locationLabel = formatVerifiedLocationLabel(location); + setBirdForm({ ...birdForm, locationDetails: location, locationLabel }); + setBirdLocationSearch({ ...emptyLocationSearchState, query: locationLabel }); + }} + onClear={() => { + setBirdForm({ ...birdForm, locationDetails: emptyVerifiedLocationDetails, locationLabel: '' }); + setBirdLocationSearch(emptyLocationSearchState); + }} + /> +