-
+
+
+
Edit {type} Adventure
+ {#if adventureToEdit.id === '' || isDetails}
+
+
+
+
+ {/if}
diff --git a/frontend/src/lib/components/NewAdventure.svelte b/frontend/src/lib/components/NewAdventure.svelte
index a19ee82..3fb8e25 100644
--- a/frontend/src/lib/components/NewAdventure.svelte
+++ b/frontend/src/lib/components/NewAdventure.svelte
@@ -4,8 +4,6 @@
import { onMount } from 'svelte';
import { enhance } from '$app/forms';
import { addToast } from '$lib/toasts';
- import PointSelectionModal from './PointSelectionModal.svelte';
- import ImageFetcher from './ImageFetcher.svelte';
export let type: string = 'visited';
@@ -13,20 +11,13 @@
export let latitude: number | null = null;
export let collection_id: string | null = null;
- import { DefaultMarker, MapEvents, MapLibre, Popup } from 'svelte-maplibre';
+ import { DefaultMarker, MapEvents, MapLibre } from 'svelte-maplibre';
let markers: Point[] = [];
let query: string = '';
let places: OpenStreetMapPlace[] = [];
+ let images: { id: string; image: string }[] = [];
- import MapMarker from '~icons/mdi/map-marker';
- import Calendar from '~icons/mdi/calendar';
- import Notebook from '~icons/mdi/notebook';
- import ClipboardList from '~icons/mdi/clipboard-list';
- import Star from '~icons/mdi/star';
- import Attachment from '~icons/mdi/attachment';
- import Map from '~icons/mdi/map';
import Earth from '~icons/mdi/earth';
- import Wikipedia from '~icons/mdi/wikipedia';
import ActivityComplete from './ActivityComplete.svelte';
import { appVersion } from '$lib/config';
@@ -57,6 +48,11 @@
reverseGeocode();
}
+ function saveAndClose() {
+ dispatch('create', newAdventure);
+ close();
+ }
+
$: if (markers.length > 0) {
newAdventure.latitude = Math.round(markers[0].lngLat.lat * 1e6) / 1e6;
newAdventure.longitude = Math.round(markers[0].lngLat.lng * 1e6) / 1e6;
@@ -104,12 +100,8 @@
console.log(data);
}
- let image: File;
let fileInput: HTMLInputElement;
- let isPointModalOpen: boolean = false;
- let isImageFetcherOpen: boolean = false;
-
const dispatch = createEventDispatcher();
let modal: HTMLDialogElement;
@@ -147,8 +139,13 @@
function imageSubmit() {
return async ({ result }: any) => {
if (result.type === 'success') {
- if (result.data.success) {
- newAdventure.images.push(result.data.id);
+ if (result.data.id && result.data.image) {
+ newAdventure.images = [...newAdventure.images, result.data];
+ images = [...images, result.data];
+ addToast('success', 'Image uploaded');
+
+ fileInput.value = '';
+ console.log(newAdventure);
} else {
addToast('error', result.data.error || 'Failed to upload image');
}
@@ -191,7 +188,7 @@
>
Basic Information
-
+
+
@@ -340,6 +339,8 @@
class="input input-bordered w-full"
/>
+
+
-
Location Information
+
+
Location Information
+
+
{/if}