feat: Add activity types functionality to CreateNewAdventure and AdventureCard components
This commit is contained in:
@@ -103,7 +103,7 @@ export async function POST(event: RequestEvent): Promise<Response> {
|
||||
});
|
||||
}
|
||||
|
||||
const { name, location, date, description, activityTypes } =
|
||||
const { name, location, date, description, activityTypes, rating } =
|
||||
body.detailAdventure;
|
||||
|
||||
if (!name) {
|
||||
@@ -112,6 +112,12 @@ export async function POST(event: RequestEvent): Promise<Response> {
|
||||
});
|
||||
}
|
||||
|
||||
if (rating && (rating < 1 || rating > 5)) {
|
||||
return error(400, {
|
||||
message: "Rating must be between 1 and 5",
|
||||
});
|
||||
}
|
||||
|
||||
console.log(activityTypes);
|
||||
|
||||
// insert the adventure to the user's visited list
|
||||
@@ -125,6 +131,7 @@ export async function POST(event: RequestEvent): Promise<Response> {
|
||||
date: date || null,
|
||||
description: description || null,
|
||||
activityTypes: JSON.stringify(activityTypes) || null,
|
||||
rating: rating || null,
|
||||
})
|
||||
.returning({ insertedId: adventureTable.id })
|
||||
.execute();
|
||||
@@ -168,7 +175,7 @@ export async function PUT(event: RequestEvent): Promise<Response> {
|
||||
});
|
||||
}
|
||||
|
||||
const { name, location, date, description, activityTypes, id } =
|
||||
const { name, location, date, description, activityTypes, id, rating } =
|
||||
body.detailAdventure;
|
||||
|
||||
if (!name) {
|
||||
@@ -185,6 +192,7 @@ export async function PUT(event: RequestEvent): Promise<Response> {
|
||||
location: location,
|
||||
date: date,
|
||||
description: description,
|
||||
rating: rating,
|
||||
activityTypes: JSON.stringify(activityTypes),
|
||||
})
|
||||
.where(
|
||||
|
||||
Reference in New Issue
Block a user