mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-24 23:39:37 +02:00
Add new columns to userPlannedAdventures table and update Adventure interface
This commit is contained in:
parent
b2184bdee3
commit
a3d4d757a9
16 changed files with 548 additions and 43 deletions
2
migrations/0007_clear_sinister_six.sql
Normal file
2
migrations/0007_clear_sinister_six.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE "userPlannedAdventures" ADD COLUMN "description" text;--> statement-breakpoint
|
||||
ALTER TABLE "userPlannedAdventures" ADD COLUMN "plannedDate" text;
|
475
migrations/meta/0007_snapshot.json
Normal file
475
migrations/meta/0007_snapshot.json
Normal file
|
@ -0,0 +1,475 @@
|
|||
{
|
||||
"id": "2dd5d59b-9e77-4a7a-9287-65e6b2456eab",
|
||||
"prevId": "42010132-1400-4431-800b-7ecd45c7aa9a",
|
||||
"version": "5",
|
||||
"dialect": "pg",
|
||||
"tables": {
|
||||
"featuredAdventures": {
|
||||
"name": "featuredAdventures",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "serial",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"location": {
|
||||
"name": "location",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {
|
||||
"featuredAdventures_name_unique": {
|
||||
"name": "featuredAdventures_name_unique",
|
||||
"nullsNotDistinct": false,
|
||||
"columns": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"session": {
|
||||
"name": "session",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"expires_at": {
|
||||
"name": "expires_at",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"session_user_id_user_id_fk": {
|
||||
"name": "session_user_id_user_id_fk",
|
||||
"tableFrom": "session",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {}
|
||||
},
|
||||
"sharedAdventures": {
|
||||
"name": "sharedAdventures",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"data": {
|
||||
"name": "data",
|
||||
"type": "json",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"date": {
|
||||
"name": "date",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {}
|
||||
},
|
||||
"userPlannedAdventures": {
|
||||
"name": "userPlannedAdventures",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "serial",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"userId": {
|
||||
"name": "userId",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"adventureName": {
|
||||
"name": "adventureName",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"location": {
|
||||
"name": "location",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"activityTypes": {
|
||||
"name": "activityTypes",
|
||||
"type": "json",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"description": {
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"plannedDate": {
|
||||
"name": "plannedDate",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"userPlannedAdventures_userId_user_id_fk": {
|
||||
"name": "userPlannedAdventures_userId_user_id_fk",
|
||||
"tableFrom": "userPlannedAdventures",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"userId"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {}
|
||||
},
|
||||
"user": {
|
||||
"name": "user",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"username": {
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"first_name": {
|
||||
"name": "first_name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"last_name": {
|
||||
"name": "last_name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"icon": {
|
||||
"name": "icon",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"hashed_password": {
|
||||
"name": "hashed_password",
|
||||
"type": "varchar",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"signup_date": {
|
||||
"name": "signup_date",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"last_login": {
|
||||
"name": "last_login",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"role": {
|
||||
"name": "role",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {}
|
||||
},
|
||||
"userVisitedAdventures": {
|
||||
"name": "userVisitedAdventures",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"adventure_id": {
|
||||
"name": "adventure_id",
|
||||
"type": "serial",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"adventure_name": {
|
||||
"name": "adventure_name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"location": {
|
||||
"name": "location",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"visited_date": {
|
||||
"name": "visited_date",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"userVisitedAdventures_user_id_user_id_fk": {
|
||||
"name": "userVisitedAdventures_user_id_user_id_fk",
|
||||
"tableFrom": "userVisitedAdventures",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {}
|
||||
},
|
||||
"userVisitedWorldTravel": {
|
||||
"name": "userVisitedWorldTravel",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "serial",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"country_code": {
|
||||
"name": "country_code",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"region_id": {
|
||||
"name": "region_id",
|
||||
"type": "varchar",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"userVisitedWorldTravel_country_code_worldTravelCountries_country_code_fk": {
|
||||
"name": "userVisitedWorldTravel_country_code_worldTravelCountries_country_code_fk",
|
||||
"tableFrom": "userVisitedWorldTravel",
|
||||
"tableTo": "worldTravelCountries",
|
||||
"columnsFrom": [
|
||||
"country_code"
|
||||
],
|
||||
"columnsTo": [
|
||||
"country_code"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"userVisitedWorldTravel_user_id_user_id_fk": {
|
||||
"name": "userVisitedWorldTravel_user_id_user_id_fk",
|
||||
"tableFrom": "userVisitedWorldTravel",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"userVisitedWorldTravel_region_id_worldTravelCountryRegions_id_fk": {
|
||||
"name": "userVisitedWorldTravel_region_id_worldTravelCountryRegions_id_fk",
|
||||
"tableFrom": "userVisitedWorldTravel",
|
||||
"tableTo": "worldTravelCountryRegions",
|
||||
"columnsFrom": [
|
||||
"region_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {}
|
||||
},
|
||||
"worldTravelCountries": {
|
||||
"name": "worldTravelCountries",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "serial",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"country_code": {
|
||||
"name": "country_code",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"continent": {
|
||||
"name": "continent",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {
|
||||
"worldTravelCountries_country_code_unique": {
|
||||
"name": "worldTravelCountries_country_code_unique",
|
||||
"nullsNotDistinct": false,
|
||||
"columns": [
|
||||
"country_code"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"worldTravelCountryRegions": {
|
||||
"name": "worldTravelCountryRegions",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "varchar",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"country_code": {
|
||||
"name": "country_code",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"info": {
|
||||
"name": "info",
|
||||
"type": "json",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"worldTravelCountryRegions_country_code_worldTravelCountries_country_code_fk": {
|
||||
"name": "worldTravelCountryRegions_country_code_worldTravelCountries_country_code_fk",
|
||||
"tableFrom": "worldTravelCountryRegions",
|
||||
"tableTo": "worldTravelCountries",
|
||||
"columnsFrom": [
|
||||
"country_code"
|
||||
],
|
||||
"columnsTo": [
|
||||
"country_code"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {}
|
||||
}
|
||||
},
|
||||
"enums": {},
|
||||
"schemas": {},
|
||||
"_meta": {
|
||||
"columns": {},
|
||||
"schemas": {},
|
||||
"tables": {}
|
||||
}
|
||||
}
|
|
@ -50,6 +50,13 @@
|
|||
"when": 1713739045755,
|
||||
"tag": "0006_colorful_inertia",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 7,
|
||||
"version": "5",
|
||||
"when": 1713739446962,
|
||||
"tag": "0007_clear_sinister_six",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
|
@ -3,18 +3,20 @@
|
|||
import locationDot from "$lib/assets/locationDot.svg";
|
||||
import calendar from "$lib/assets/calendar.svg";
|
||||
import { goto } from "$app/navigation";
|
||||
import { desc } from "drizzle-orm";
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
export let type: String;
|
||||
|
||||
export let name: String | undefined = undefined;
|
||||
export let location: String | undefined = undefined;
|
||||
export let created: String | undefined = undefined;
|
||||
export let date: String | undefined = undefined;
|
||||
export let id: Number | undefined = undefined;
|
||||
export let regionId: String | undefined = undefined;
|
||||
export let visited: Boolean | undefined = undefined;
|
||||
export let countryCode: String | undefined = undefined;
|
||||
export let activityTypes: String[] | undefined = undefined;
|
||||
export let description: String | undefined = undefined;
|
||||
|
||||
function remove() {
|
||||
dispatch("remove", id);
|
||||
|
@ -51,10 +53,10 @@
|
|||
<p class="ml-.5">{location}</p>
|
||||
</div>
|
||||
{/if}
|
||||
{#if created !== ""}
|
||||
{#if date !== ""}
|
||||
<div class="inline-flex items-center">
|
||||
<iconify-icon icon="mdi:calendar" class="text-xl"></iconify-icon>
|
||||
<p class="ml-1">{created}</p>
|
||||
<p class="ml-1">{date}</p>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="card-actions justify-end">
|
||||
|
@ -96,10 +98,10 @@
|
|||
<p class="ml-.5">{location}</p>
|
||||
</div>
|
||||
{/if}
|
||||
{#if created !== ""}
|
||||
{#if date !== ""}
|
||||
<div class="inline-flex items-center">
|
||||
<iconify-icon icon="mdi:calendar" class="text-xl"></iconify-icon>
|
||||
<p class="ml-1">{created}</p>
|
||||
<p class="ml-1">{date}</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
@ -141,7 +143,22 @@
|
|||
</div>
|
||||
{/if}
|
||||
{#if activityTypes && activityTypes.length > 0}
|
||||
<p>{activityTypes}</p>
|
||||
{#each activityTypes as activity}
|
||||
<div
|
||||
class="relative grid select-none items-center whitespace-nowrap rounded-lg bg-gray-900 py-1.5 px-3 font-sans text-xs font-bold uppercase text-white"
|
||||
>
|
||||
<span class="">{activity}</span>
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
{#if description && description.length > 0}
|
||||
<p>{description}</p>
|
||||
{/if}
|
||||
{#if date && date != undefined}
|
||||
<div class="inline-flex items-center">
|
||||
<iconify-icon icon="mdi:calendar" class="text-xl"></iconify-icon>
|
||||
<p class="ml-1">{date}</p>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="card-actions justify-end">
|
||||
<button class="btn btn-primary" on:click={add}>Add</button>
|
||||
|
|
|
@ -51,10 +51,10 @@
|
|||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label for="created">Created</label>
|
||||
<label for="date">date</label>
|
||||
<input
|
||||
type="date"
|
||||
id="created"
|
||||
id="date"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
export let editId: number = NaN;
|
||||
export let editName: string = "";
|
||||
export let editLocation: string = "";
|
||||
export let editCreated: string = "";
|
||||
export let editdate: string = "";
|
||||
import { createEventDispatcher } from "svelte";
|
||||
import type { Adventure } from "$lib/utils/types";
|
||||
const dispatch = createEventDispatcher();
|
||||
|
@ -23,7 +23,7 @@
|
|||
id: editId,
|
||||
name: editName,
|
||||
location: editLocation,
|
||||
created: editCreated,
|
||||
date: editdate,
|
||||
};
|
||||
dispatch("submit", adventureEdited);
|
||||
console.log(adventureEdited);
|
||||
|
@ -70,11 +70,11 @@
|
|||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label for="created">Created</label>
|
||||
<label for="date">date</label>
|
||||
<input
|
||||
type="date"
|
||||
id="created"
|
||||
bind:value={editCreated}
|
||||
id="date"
|
||||
bind:value={editdate}
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<h2 class="card-title">{user.first_name} {user.last_name}</h2>
|
||||
<p>{user.username} - {user.icon}</p>
|
||||
<p>Last Login: {user.last_login}</p>
|
||||
<p>Created: {user.signup_date}</p>
|
||||
<p>date: {user.signup_date}</p>
|
||||
<p>{user.role}</p>
|
||||
<p>{user.id}</p>
|
||||
<div class="card-actions justify-end">
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { desc } from "drizzle-orm";
|
||||
import {
|
||||
pgTable,
|
||||
text,
|
||||
|
@ -99,4 +100,6 @@ export const userPlannedAdventures = pgTable("userPlannedAdventures", {
|
|||
name: text("adventureName").notNull(),
|
||||
location: text("location"),
|
||||
activityTypes: json("activityTypes"),
|
||||
description: text("description"),
|
||||
date: text("plannedDate"),
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@ export interface Adventure {
|
|||
id?: number;
|
||||
name?: string;
|
||||
location?: string | undefined;
|
||||
created?: string | undefined;
|
||||
date?: string | undefined;
|
||||
description?: string | undefined;
|
||||
activityTypes?: string[] | undefined;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ export async function GET(event: RequestEvent): Promise<Response> {
|
|||
id: item.adventureID,
|
||||
name: item.adventureName,
|
||||
location: item.location,
|
||||
created: item.visitedDate,
|
||||
date: item.visitedDate,
|
||||
})),
|
||||
}),
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ export async function POST(event: RequestEvent): Promise<Response> {
|
|||
}
|
||||
|
||||
// get properties from the body
|
||||
const { name, location, created } = await event.request.json();
|
||||
const { name, location, date } = await event.request.json();
|
||||
|
||||
// insert the adventure to the user's visited list
|
||||
await db
|
||||
|
@ -100,10 +100,10 @@ export async function POST(event: RequestEvent): Promise<Response> {
|
|||
userId: event.locals.user.id,
|
||||
adventureName: name,
|
||||
location: location,
|
||||
visitedDate: created,
|
||||
visitedDate: date,
|
||||
})
|
||||
.execute();
|
||||
let res = await db
|
||||
let res = await db
|
||||
.select()
|
||||
.from(userVisitedAdventures)
|
||||
.where(
|
||||
|
@ -111,17 +111,17 @@ let res = await db
|
|||
eq(userVisitedAdventures.userId, event.locals.user.id),
|
||||
eq(userVisitedAdventures.adventureName, name),
|
||||
eq(userVisitedAdventures.location, location),
|
||||
eq(userVisitedAdventures.visitedDate, created)
|
||||
eq(userVisitedAdventures.visitedDate, date)
|
||||
)
|
||||
)
|
||||
.execute();
|
||||
|
||||
// return a response with the adventure object values
|
||||
// return a response with the adventure object values
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
adventure: { name, location, created },
|
||||
adventure: { name, location, date },
|
||||
message: { message: "Adventure added" },
|
||||
id: res[0].adventureID
|
||||
id: res[0].adventureID,
|
||||
}),
|
||||
{
|
||||
status: 200,
|
||||
|
@ -144,7 +144,7 @@ export async function PUT(event: RequestEvent): Promise<Response> {
|
|||
}
|
||||
|
||||
// get properties from the body
|
||||
const { id, name, location, created } = await event.request.json();
|
||||
const { id, name, location, date } = await event.request.json();
|
||||
|
||||
// update the adventure in the user's visited list
|
||||
await db
|
||||
|
@ -152,7 +152,7 @@ export async function PUT(event: RequestEvent): Promise<Response> {
|
|||
.set({
|
||||
adventureName: name,
|
||||
location: location,
|
||||
visitedDate: created,
|
||||
visitedDate: date,
|
||||
})
|
||||
.where(
|
||||
and(
|
||||
|
@ -164,7 +164,7 @@ export async function PUT(event: RequestEvent): Promise<Response> {
|
|||
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
adventure: { id, name, location, created },
|
||||
adventure: { id, name, location, date },
|
||||
message: { message: "Adventure updated" },
|
||||
}),
|
||||
{
|
||||
|
@ -174,4 +174,4 @@ export async function PUT(event: RequestEvent): Promise<Response> {
|
|||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
body: JSON.stringify({
|
||||
name: event.detail.name,
|
||||
location: event.detail.location,
|
||||
created: "",
|
||||
date: "",
|
||||
}),
|
||||
});
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
|||
on:add={add}
|
||||
name={adventure.name}
|
||||
location={adventure.location}
|
||||
created=""
|
||||
date=""
|
||||
id={NaN}
|
||||
/>
|
||||
{/each}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
let editId: number = NaN;
|
||||
let editName: string = "";
|
||||
let editLocation: string = "";
|
||||
let editCreated: string = "";
|
||||
let editdate: string = "";
|
||||
|
||||
let isShowingToast: boolean = false;
|
||||
let toastAction: string = "";
|
||||
|
@ -71,7 +71,7 @@
|
|||
body: JSON.stringify({
|
||||
name: newName,
|
||||
location: newLocation,
|
||||
created: dateString,
|
||||
date: dateString,
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
|
@ -84,7 +84,7 @@
|
|||
id: newId,
|
||||
name: newName,
|
||||
location: newLocation,
|
||||
created: dateString,
|
||||
date: dateString,
|
||||
},
|
||||
];
|
||||
newName = ""; // Reset newName and newLocation after adding adventure
|
||||
|
@ -109,7 +109,7 @@
|
|||
id: event.detail.id,
|
||||
name: event.detail.name,
|
||||
location: event.detail.location,
|
||||
created: event.detail.created,
|
||||
date: event.detail.date,
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
|
@ -122,7 +122,7 @@
|
|||
editId = NaN;
|
||||
editName = "";
|
||||
editLocation = "";
|
||||
editCreated = "";
|
||||
editdate = "";
|
||||
showToast("Adventure edited successfully!");
|
||||
})
|
||||
.catch((error) => {
|
||||
|
@ -138,7 +138,7 @@
|
|||
editId = adventure.id || 0;
|
||||
editName = adventure.name || "";
|
||||
editLocation = adventure.location || "";
|
||||
editCreated = adventure.created || "";
|
||||
editdate = adventure.date || "";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@
|
|||
editId = NaN;
|
||||
editName = "";
|
||||
editLocation = "";
|
||||
editCreated = "";
|
||||
editdate = "";
|
||||
}
|
||||
|
||||
function deleteData() {
|
||||
|
@ -263,7 +263,7 @@
|
|||
bind:editId
|
||||
bind:editName
|
||||
bind:editLocation
|
||||
bind:editCreated
|
||||
bind:editdate
|
||||
on:submit={saveAdventure}
|
||||
on:close={handleClose}
|
||||
/>
|
||||
|
@ -278,7 +278,7 @@
|
|||
id={adventure.id}
|
||||
name={adventure.name}
|
||||
location={adventure.location}
|
||||
created={adventure.created}
|
||||
date={adventure.date}
|
||||
on:edit={editAdventure}
|
||||
on:remove={removeAdventure}
|
||||
/>
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
name={adventure.name}
|
||||
location={adventure.location}
|
||||
activityTypes={adventure.activityTypes}
|
||||
description={adventure?.description}
|
||||
date={adventure?.date}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
|
|
|
@ -25,14 +25,13 @@ export async function load({ params }) {
|
|||
id: item.id,
|
||||
name: item.name,
|
||||
location: item.location,
|
||||
created: item.created,
|
||||
date: item.date,
|
||||
} as Adventure;
|
||||
});
|
||||
|
||||
let name = rawData.name;
|
||||
let date = rawData.date;
|
||||
|
||||
|
||||
// Return the array of Adventure objects
|
||||
return {
|
||||
adventureArray,
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<div>
|
||||
<h1>{adventure.name}</h1>
|
||||
<p>{adventure.location}</p>
|
||||
<p>{adventure.created}</p>
|
||||
<p>{adventure.date}</p>
|
||||
<p>{adventure.id}</p>
|
||||
</div>
|
||||
{/each} -->
|
||||
|
@ -25,7 +25,7 @@
|
|||
id={adventure.id}
|
||||
name={adventure.name}
|
||||
location={adventure.location}
|
||||
created={adventure.created}
|
||||
date={adventure.date}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
|
|
|
@ -129,7 +129,7 @@ export const actions: Actions = {
|
|||
"content-type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
message: "User created",
|
||||
message: "User date",
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue