mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-05 13:15:18 +02:00
Add image url to adventures and plans
This commit is contained in:
parent
175c088776
commit
10bd897a55
5 changed files with 58 additions and 9 deletions
|
@ -9,6 +9,7 @@
|
||||||
location: "",
|
location: "",
|
||||||
date: "",
|
date: "",
|
||||||
activityTypes: [],
|
activityTypes: [],
|
||||||
|
imageUrl: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
import { createEventDispatcher } from "svelte";
|
import { createEventDispatcher } from "svelte";
|
||||||
|
@ -121,6 +122,16 @@
|
||||||
class="input input-bordered w-full max-w-xs"
|
class="input input-bordered w-full max-w-xs"
|
||||||
/>
|
/>
|
||||||
</div>
|
</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
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
class="btn btn-primary mr-4 mt-4"
|
class="btn btn-primary mr-4 mt-4"
|
||||||
|
|
|
@ -110,6 +110,15 @@
|
||||||
class="input input-bordered w-full max-w-xs"
|
class="input input-bordered w-full max-w-xs"
|
||||||
/>
|
/>
|
||||||
</div>
|
</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
|
<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 -->
|
<!-- if there is a button in form, it will close the modal -->
|
||||||
|
|
|
@ -28,8 +28,8 @@ export const GET: RequestHandler = async ({ url, locals }) => {
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(adventureTable.id, Number(id)), // Convert id to number
|
eq(adventureTable.id, Number(id)), // Convert id to number
|
||||||
eq(adventureTable.userId, user.id),
|
eq(adventureTable.userId, user.id)
|
||||||
eq(adventureTable.type, "mylog")
|
// eq(adventureTable.type, "mylog")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.limit(1)
|
.limit(1)
|
||||||
|
|
|
@ -109,8 +109,16 @@ export async function POST(event: RequestEvent): Promise<Response> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const { name, location, date, description, activityTypes, rating, tripId } =
|
const {
|
||||||
body.detailAdventure;
|
name,
|
||||||
|
location,
|
||||||
|
date,
|
||||||
|
description,
|
||||||
|
activityTypes,
|
||||||
|
rating,
|
||||||
|
tripId,
|
||||||
|
imageUrl,
|
||||||
|
} = body.detailAdventure;
|
||||||
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
return error(400, {
|
return error(400, {
|
||||||
|
@ -139,6 +147,7 @@ export async function POST(event: RequestEvent): Promise<Response> {
|
||||||
description: description || null,
|
description: description || null,
|
||||||
activityTypes: JSON.stringify(activityTypes) || null,
|
activityTypes: JSON.stringify(activityTypes) || null,
|
||||||
rating: rating || null,
|
rating: rating || null,
|
||||||
|
imageUrl: imageUrl || null,
|
||||||
})
|
})
|
||||||
.returning({ insertedId: adventureTable.id })
|
.returning({ insertedId: adventureTable.id })
|
||||||
.execute();
|
.execute();
|
||||||
|
@ -182,8 +191,16 @@ export async function PUT(event: RequestEvent): Promise<Response> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const { name, location, date, description, activityTypes, id, rating } =
|
const {
|
||||||
body.detailAdventure;
|
name,
|
||||||
|
location,
|
||||||
|
date,
|
||||||
|
description,
|
||||||
|
activityTypes,
|
||||||
|
id,
|
||||||
|
rating,
|
||||||
|
imageUrl,
|
||||||
|
} = body.detailAdventure;
|
||||||
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
return error(400, {
|
return error(400, {
|
||||||
|
@ -201,6 +218,7 @@ export async function PUT(event: RequestEvent): Promise<Response> {
|
||||||
description: description,
|
description: description,
|
||||||
rating: rating,
|
rating: rating,
|
||||||
activityTypes: JSON.stringify(activityTypes),
|
activityTypes: JSON.stringify(activityTypes),
|
||||||
|
imageUrl: imageUrl,
|
||||||
})
|
})
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
|
|
|
@ -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;
|
body.detailAdventure;
|
||||||
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
|
@ -137,6 +137,7 @@ export async function POST(event: RequestEvent): Promise<Response> {
|
||||||
description: description || null,
|
description: description || null,
|
||||||
activityTypes: JSON.stringify(activityTypes) || null,
|
activityTypes: JSON.stringify(activityTypes) || null,
|
||||||
rating: rating || null,
|
rating: rating || null,
|
||||||
|
imageUrl: imageUrl || null,
|
||||||
})
|
})
|
||||||
.returning({ insertedId: adventureTable.id })
|
.returning({ insertedId: adventureTable.id })
|
||||||
.execute();
|
.execute();
|
||||||
|
@ -180,8 +181,17 @@ export async function PUT(event: RequestEvent): Promise<Response> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const { name, location, date, description, activityTypes, id, rating, type } =
|
const {
|
||||||
body.detailAdventure;
|
name,
|
||||||
|
location,
|
||||||
|
date,
|
||||||
|
description,
|
||||||
|
activityTypes,
|
||||||
|
id,
|
||||||
|
rating,
|
||||||
|
type,
|
||||||
|
imageUrl,
|
||||||
|
} = body.detailAdventure;
|
||||||
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
return error(400, {
|
return error(400, {
|
||||||
|
@ -206,6 +216,7 @@ export async function PUT(event: RequestEvent): Promise<Response> {
|
||||||
description: description,
|
description: description,
|
||||||
rating: rating,
|
rating: rating,
|
||||||
activityTypes: JSON.stringify(activityTypes),
|
activityTypes: JSON.stringify(activityTypes),
|
||||||
|
imageUrl: imageUrl,
|
||||||
})
|
})
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue