1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-04 20:55:19 +02:00

Add image url to adventures and plans

This commit is contained in:
Sean Morley 2024-05-26 13:49:57 +00:00
parent 175c088776
commit 10bd897a55
5 changed files with 58 additions and 9 deletions

View file

@ -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"
/>
</div>
<div>
<label for="rating">Image URL</label>
<input
type="url"
id="iamgeUrl"
bind:value={newAdventure.imageUrl}
class="input input-bordered w-full max-w-xs"
/>
</div>
<button
type="submit"
class="btn btn-primary mr-4 mt-4"

View file

@ -110,6 +110,15 @@
class="input input-bordered w-full max-w-xs"
/>
</div>
<div>
<label for="rating">Image URL</label>
<input
type="url"
id="imageUrl"
bind:value={adventureToEdit.imageUrl}
class="input input-bordered w-full max-w-xs"
/>
</div>
<button class="btn btn-primary mr-4 mt-4" on:click={submit}>Save</button
>
<!-- if there is a button in form, it will close the modal -->

View file

@ -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)

View file

@ -109,8 +109,16 @@ export async function POST(event: RequestEvent): Promise<Response> {
});
}
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<Response> {
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<Response> {
});
}
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<Response> {
description: description,
rating: rating,
activityTypes: JSON.stringify(activityTypes),
imageUrl: imageUrl,
})
.where(
and(

View file

@ -108,7 +108,7 @@ export async function POST(event: RequestEvent): Promise<Response> {
});
}
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<Response> {
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<Response> {
});
}
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<Response> {
description: description,
rating: rating,
activityTypes: JSON.stringify(activityTypes),
imageUrl: imageUrl,
})
.where(
and(