feat:migrate location name from finds to location table and update the frontend components to reflect the change.

This commit is contained in:
2025-12-16 12:53:59 +01:00
parent d67b9b7911
commit 577a3cab56
8 changed files with 875 additions and 21 deletions

View File

@@ -14,7 +14,6 @@
let title = $state('');
let description = $state('');
let locationName = $state('');
let category = $state('cafe');
let isPublic = $state(true);
let selectedFiles = $state<FileList | null>(null);
@@ -93,7 +92,6 @@
locationId,
title: title.trim(),
description: description.trim() || null,
locationName: locationName.trim() || null,
category,
isPublic,
media: uploadedMedia
@@ -118,7 +116,6 @@
function resetForm() {
title = '';
description = '';
locationName = '';
category = 'cafe';
isPublic = true;
selectedFiles = null;
@@ -177,15 +174,6 @@
></textarea>
</div>
<div class="field">
<Label for="location-name">Location name (optional)</Label>
<Input
name="location-name"
placeholder="Café Central, Brussels"
bind:value={locationName}
/>
</div>
<div class="field-group">
<div class="field">
<Label for="category">Category</Label>

View File

@@ -16,6 +16,7 @@
let latitude = $state('');
let longitude = $state('');
let locationName = $state('');
let isSubmitting = $state(false);
let useManualLocation = $state(false);
@@ -59,7 +60,8 @@
},
body: JSON.stringify({
latitude: lat,
longitude: lng
longitude: lng,
locationName: locationName.trim() || null
})
});
@@ -85,6 +87,7 @@
}
function handlePlaceSelected(place: PlaceResult) {
locationName = place.name;
latitude = place.latitude.toString();
longitude = place.longitude.toString();
}
@@ -100,6 +103,7 @@
function resetForm() {
latitude = '';
longitude = '';
locationName = '';
useManualLocation = false;
}
@@ -158,6 +162,16 @@
{/if}
</div>
<div class="field">
<Label for="location-name">Location Name (Optional)</Label>
<Input
name="location-name"
type="text"
placeholder="Café Central, Brussels"
bind:value={locationName}
/>
</div>
{#if useManualLocation || (!latitude && !longitude)}
<div class="field-group">
<div class="field">

View File

@@ -29,6 +29,7 @@ export const location = pgTable('location', {
.references(() => user.id, { onDelete: 'cascade' }),
latitude: text('latitude').notNull(), // Using text for precision
longitude: text('longitude').notNull(), // Using text for precision
locationName: text('location_name'), // e.g., "Café Belga, Brussels"
createdAt: timestamp('created_at', { withTimezone: true, mode: 'date' }).defaultNow().notNull()
});
@@ -43,7 +44,6 @@ export const find = pgTable('find', {
.references(() => user.id, { onDelete: 'cascade' }),
title: text('title').notNull(),
description: text('description'),
locationName: text('location_name'), // e.g., "Café Belga, Brussels"
category: text('category'), // e.g., "cafe", "restaurant", "park", "landmark"
isPublic: integer('is_public').default(1), // Using integer for boolean (1 = true, 0 = false)
createdAt: timestamp('created_at', { withTimezone: true, mode: 'date' }).defaultNow().notNull(),