mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-25 15:59:38 +02:00
Enhance adventure management: add error handling for category fetch, implement unique email constraint in user model, and update adventure save logic to ensure category assignment
This commit is contained in:
parent
86d213bb8b
commit
736ede2417
15 changed files with 216 additions and 60 deletions
|
@ -2,6 +2,7 @@
|
|||
import { createEventDispatcher } from 'svelte';
|
||||
import type {
|
||||
Adventure,
|
||||
Category,
|
||||
Collection,
|
||||
OpenStreetMapPlace,
|
||||
Point,
|
||||
|
@ -17,7 +18,7 @@
|
|||
export let latitude: number | null = null;
|
||||
export let collection: Collection | null = null;
|
||||
|
||||
import { DefaultMarker, FillLayer, MapEvents, MapLibre } from 'svelte-maplibre';
|
||||
import { DefaultMarker, MapEvents, MapLibre } from 'svelte-maplibre';
|
||||
|
||||
let query: string = '';
|
||||
let places: OpenStreetMapPlace[] = [];
|
||||
|
@ -25,9 +26,11 @@
|
|||
let warningMessage: string = '';
|
||||
let constrainDates: boolean = false;
|
||||
|
||||
let categories: Category[] = [];
|
||||
|
||||
import ActivityComplete from './ActivityComplete.svelte';
|
||||
import { appVersion } from '$lib/config';
|
||||
import { ADVENTURE_TYPES } from '$lib';
|
||||
import CategoryDropdown from './CategoryDropdown.svelte';
|
||||
|
||||
let wikiError: string = '';
|
||||
|
||||
|
@ -53,13 +56,7 @@
|
|||
images: [],
|
||||
user_id: null,
|
||||
collection: collection?.id || null,
|
||||
category: {
|
||||
id: '',
|
||||
name: '',
|
||||
display_name: '',
|
||||
icon: '',
|
||||
user_id: ''
|
||||
}
|
||||
category: ''
|
||||
};
|
||||
|
||||
export let adventureToEdit: Adventure | null = null;
|
||||
|
@ -81,13 +78,7 @@
|
|||
collection: adventureToEdit?.collection || collection?.id || null,
|
||||
visits: adventureToEdit?.visits || [],
|
||||
is_visited: adventureToEdit?.is_visited || false,
|
||||
category: adventureToEdit?.category || {
|
||||
id: '',
|
||||
name: '',
|
||||
display_name: '',
|
||||
icon: '',
|
||||
user_id: ''
|
||||
}
|
||||
category: adventureToEdit?.category || ''
|
||||
};
|
||||
|
||||
let markers: Point[] = [];
|
||||
|
@ -336,6 +327,12 @@
|
|||
modal = document.getElementById('my_modal_1') as HTMLDialogElement;
|
||||
modal.showModal();
|
||||
console.log('open');
|
||||
let categoryFetch = await fetch('/api/categories/categories');
|
||||
if (categoryFetch.ok) {
|
||||
categories = await categoryFetch.json();
|
||||
} else {
|
||||
addToast('error', $t('adventures.category_fetch_error'));
|
||||
}
|
||||
});
|
||||
|
||||
function close() {
|
||||
|
@ -465,12 +462,8 @@
|
|||
</div>
|
||||
<div>
|
||||
<label for="link">{$t('adventures.category')}</label><br />
|
||||
<select class="select select-bordered w-full max-w-xs" bind:value={adventure.type}>
|
||||
<option disabled selected>{$t('adventures.select_adventure_category')}</option>
|
||||
{#each ADVENTURE_TYPES as type}
|
||||
<option value={type.type}>{type.label}</option>
|
||||
{/each}
|
||||
</select>
|
||||
|
||||
<CategoryDropdown bind:categories bind:category_id={adventure.category} />
|
||||
</div>
|
||||
<div>
|
||||
<label for="rating">{$t('adventures.rating')}</label><br />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue