From 10bd897a5545d38ede03829ab14cbb4666a9f6c1 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Sun, 26 May 2024 13:49:57 +0000 Subject: [PATCH] Add image url to adventures and plans --- src/lib/components/CreateNewAdventure.svelte | 11 +++++++++ src/lib/components/EditModal.svelte | 9 +++++++ src/routes/api/adventure/+server.ts | 4 +-- src/routes/api/planner/+server.ts | 26 +++++++++++++++++--- src/routes/api/visits/+server.ts | 17 ++++++++++--- 5 files changed, 58 insertions(+), 9 deletions(-) diff --git a/src/lib/components/CreateNewAdventure.svelte b/src/lib/components/CreateNewAdventure.svelte index 1636f26..ecadf70 100644 --- a/src/lib/components/CreateNewAdventure.svelte +++ b/src/lib/components/CreateNewAdventure.svelte @@ -9,6 +9,7 @@ location: "", date: "", activityTypes: [], + imageUrl: "", }; import { createEventDispatcher } from "svelte"; @@ -121,6 +122,16 @@ class="input input-bordered w-full max-w-xs" /> +
+ + +
+ diff --git a/src/routes/api/adventure/+server.ts b/src/routes/api/adventure/+server.ts index 7bfba3e..8dc6837 100644 --- a/src/routes/api/adventure/+server.ts +++ b/src/routes/api/adventure/+server.ts @@ -28,8 +28,8 @@ export const GET: RequestHandler = async ({ url, locals }) => { .where( and( eq(adventureTable.id, Number(id)), // Convert id to number - eq(adventureTable.userId, user.id), - eq(adventureTable.type, "mylog") + eq(adventureTable.userId, user.id) + // eq(adventureTable.type, "mylog") ) ) .limit(1) diff --git a/src/routes/api/planner/+server.ts b/src/routes/api/planner/+server.ts index 2272af7..7bf8fb5 100644 --- a/src/routes/api/planner/+server.ts +++ b/src/routes/api/planner/+server.ts @@ -109,8 +109,16 @@ export async function POST(event: RequestEvent): Promise { }); } - const { name, location, date, description, activityTypes, rating, tripId } = - body.detailAdventure; + const { + name, + location, + date, + description, + activityTypes, + rating, + tripId, + imageUrl, + } = body.detailAdventure; if (!name) { return error(400, { @@ -139,6 +147,7 @@ export async function POST(event: RequestEvent): Promise { description: description || null, activityTypes: JSON.stringify(activityTypes) || null, rating: rating || null, + imageUrl: imageUrl || null, }) .returning({ insertedId: adventureTable.id }) .execute(); @@ -182,8 +191,16 @@ export async function PUT(event: RequestEvent): Promise { }); } - const { name, location, date, description, activityTypes, id, rating } = - body.detailAdventure; + const { + name, + location, + date, + description, + activityTypes, + id, + rating, + imageUrl, + } = body.detailAdventure; if (!name) { return error(400, { @@ -201,6 +218,7 @@ export async function PUT(event: RequestEvent): Promise { description: description, rating: rating, activityTypes: JSON.stringify(activityTypes), + imageUrl: imageUrl, }) .where( and( diff --git a/src/routes/api/visits/+server.ts b/src/routes/api/visits/+server.ts index 5092016..827fb23 100644 --- a/src/routes/api/visits/+server.ts +++ b/src/routes/api/visits/+server.ts @@ -108,7 +108,7 @@ export async function POST(event: RequestEvent): Promise { }); } - const { name, location, date, description, activityTypes, rating } = + const { name, location, date, description, activityTypes, rating, imageUrl } = body.detailAdventure; if (!name) { @@ -137,6 +137,7 @@ export async function POST(event: RequestEvent): Promise { description: description || null, activityTypes: JSON.stringify(activityTypes) || null, rating: rating || null, + imageUrl: imageUrl || null, }) .returning({ insertedId: adventureTable.id }) .execute(); @@ -180,8 +181,17 @@ export async function PUT(event: RequestEvent): Promise { }); } - const { name, location, date, description, activityTypes, id, rating, type } = - body.detailAdventure; + const { + name, + location, + date, + description, + activityTypes, + id, + rating, + type, + imageUrl, + } = body.detailAdventure; if (!name) { return error(400, { @@ -206,6 +216,7 @@ export async function PUT(event: RequestEvent): Promise { description: description, rating: rating, activityTypes: JSON.stringify(activityTypes), + imageUrl: imageUrl, }) .where( and(