feat: Add markVisited function to AdventureCard.svelte and +page.svelte
The code changes include adding a new function called markVisited to the AdventureCard.svelte and +page.svelte files. This function is responsible for marking an adventure as visited and dispatching an event to update the adventure's status. This enhancement allows users to mark adventures as visited in the planner page and triggers the corresponding API request to update the adventure's status in the database.
This commit is contained in:
@@ -180,7 +180,7 @@ export async function PUT(event: RequestEvent): Promise<Response> {
|
||||
});
|
||||
}
|
||||
|
||||
const { name, location, date, description, activityTypes, id, rating } =
|
||||
const { name, location, date, description, activityTypes, id, rating, type } =
|
||||
body.detailAdventure;
|
||||
|
||||
if (!name) {
|
||||
@@ -189,11 +189,18 @@ export async function PUT(event: RequestEvent): Promise<Response> {
|
||||
});
|
||||
}
|
||||
|
||||
if (type == "featured") {
|
||||
return error(400, {
|
||||
message: "Featured adventures cannot be created at the moment",
|
||||
});
|
||||
}
|
||||
|
||||
// update the adventure in the user's visited list
|
||||
await db
|
||||
.update(adventureTable)
|
||||
.set({
|
||||
name: name,
|
||||
type: type,
|
||||
location: location,
|
||||
date: date,
|
||||
description: description,
|
||||
|
||||
Reference in New Issue
Block a user