diff --git a/src/lib/components/AdventureCard.svelte b/src/lib/components/AdventureCard.svelte
index 6ced9fc..2434252 100644
--- a/src/lib/components/AdventureCard.svelte
+++ b/src/lib/components/AdventureCard.svelte
@@ -4,38 +4,31 @@
import calendar from "$lib/assets/calendar.svg";
import { goto } from "$app/navigation";
import { desc } from "drizzle-orm";
+ import type { Adventure } from "$lib/utils/types";
const dispatch = createEventDispatcher();
export let type: String;
- export let name: String | undefined = undefined;
- export let location: 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 adventure: Adventure;
+
+ // export let name: String | undefined = undefined;
+ // export let location: String | undefined = undefined;
+ // export let date: String | undefined = undefined;
+ // export let id: Number | undefined = undefined;
function remove() {
- dispatch("remove", id);
+ dispatch("remove", adventure.id);
}
function edit() {
- dispatch("edit", id);
+ dispatch("edit", adventure.id);
}
function add() {
- dispatch("add", { name, location });
- }
- function markVisited() {
- dispatch("markVisited", regionId);
- visited = true;
- }
- function removeVisit() {
- dispatch("removeVisit", regionId);
- visited = false;
+ dispatch("add", adventure);
}
function moreInfo() {
- console.log(id);
- goto(`/adventure/${id}`);
+ console.log(adventure.id);
+ goto(`/adventure/${adventure.id}`);
}
@@ -43,17 +36,17 @@
class="card min-w-max lg:w-96 md:w-80 sm:w-60 xs:w-40 bg-primary-content shadow-xl overflow-hidden text-base-content"
>
-
{name}
- {#if location && location !== ""}
+
{adventure.name}
+ {#if adventure.location && adventure.location !== ""}
-
{location}
+
{adventure.location}
{/if}
- {#if date && date !== ""}
+ {#if adventure.date && adventure.date !== ""}
-
{date}
+
{adventure.date}
{/if}
diff --git a/src/lib/components/EditModal.svelte b/src/lib/components/EditModal.svelte
index a2c1f09..5b1db35 100644
--- a/src/lib/components/EditModal.svelte
+++ b/src/lib/components/EditModal.svelte
@@ -61,7 +61,7 @@
/>
-
+
+
+
+
+
diff --git a/src/lib/components/MoreFieldsInput.svelte b/src/lib/components/MoreFieldsInput.svelte
new file mode 100644
index 0000000..ec7b4d9
--- /dev/null
+++ b/src/lib/components/MoreFieldsInput.svelte
@@ -0,0 +1,95 @@
+
+
+
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index b587ecc..52e491c 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -15,7 +15,7 @@
inject();
injectSpeedInsights();
} else {
- console.log("Not using Vercel");
+ // console.log("Not using Vercel");
}
let isServerSetup = data.isServerSetup;
diff --git a/src/routes/adventure/[id]/+page.svelte b/src/routes/adventure/[id]/+page.svelte
index 6bd2669..a266a4e 100644
--- a/src/routes/adventure/[id]/+page.svelte
+++ b/src/routes/adventure/[id]/+page.svelte
@@ -33,7 +33,7 @@
{/if}
{#if adventure.date}
- Visited on: {new Date(adventure.date).toLocaleDateString()}
+ Visited on: {adventure.date}
{/if}
{#if adventure.rating !== undefined && adventure.rating !== null}
diff --git a/src/routes/api/visits/+server.ts b/src/routes/api/visits/+server.ts
index 0350389..8db110c 100644
--- a/src/routes/api/visits/+server.ts
+++ b/src/routes/api/visits/+server.ts
@@ -86,7 +86,7 @@ export async function POST(event: RequestEvent): Promise
{
const { newAdventure } = await event.request.json();
console.log(newAdventure);
- const { name, location, date } = newAdventure;
+ const { name, location, date, description } = newAdventure;
// insert the adventure to the user's visited list
await db
@@ -97,6 +97,7 @@ export async function POST(event: RequestEvent): Promise {
name: name,
location: location,
date: date,
+ description: description,
})
.execute();
let res = await db
@@ -107,7 +108,8 @@ export async function POST(event: RequestEvent): Promise {
eq(adventureTable.userId, event.locals.user.id),
eq(adventureTable.name, name),
eq(adventureTable.location, location),
- eq(adventureTable.date, date)
+ eq(adventureTable.date, date),
+ eq(adventureTable.description, description)
)
)
.execute();
@@ -142,7 +144,7 @@ export async function PUT(event: RequestEvent): Promise {
// get properties from the body
const { newAdventure } = await event.request.json();
console.log(newAdventure);
- const { name, location, date, id } = newAdventure;
+ const { name, location, date, id, description } = newAdventure;
// update the adventure in the user's visited list
await db
@@ -151,6 +153,7 @@ export async function PUT(event: RequestEvent): Promise {
name: name,
location: location,
date: date,
+ description: description,
})
.where(
and(
@@ -162,7 +165,7 @@ export async function PUT(event: RequestEvent): Promise {
return new Response(
JSON.stringify({
- adventure: { id, name, location, date },
+ adventure: { id, name, location, date, description },
message: { message: "Adventure updated" },
}),
{
diff --git a/src/routes/featured/+page.svelte b/src/routes/featured/+page.svelte
index 0130fca..8d0cd46 100644
--- a/src/routes/featured/+page.svelte
+++ b/src/routes/featured/+page.svelte
@@ -10,11 +10,10 @@
count = value;
});
- async function add(event: CustomEvent<{ name: string; location: string }>) {
+ async function add(event: CustomEvent) {
let newAdventure: Adventure = {
name: event.detail.name,
location: event.detail.location,
- date: "",
type: "mylog",
id: -1,
};
@@ -47,14 +46,7 @@
class="grid xl:grid-cols-3 lg:grid-cols-3 md:grid-cols-2 sm:grid-cols-1 gap-4 mt-4 content-center auto-cols-auto ml-6 mr-6"
>
{#each data.result as adventure (adventure.id)}
-
+
{/each}
diff --git a/src/routes/log/+page.svelte b/src/routes/log/+page.svelte
index 4c26a6a..672b913 100644
--- a/src/routes/log/+page.svelte
+++ b/src/routes/log/+page.svelte
@@ -13,10 +13,13 @@
import EditModal from "$lib/components/EditModal.svelte";
import { generateRandomString } from "$lib";
import { visitCount } from "$lib/utils/stores/visitCountStore";
+ import MoreFieldsInput from "$lib/components/MoreFieldsInput.svelte";
let newName = "";
let newLocation = "";
+ let isShowingMoreFields = false;
+
let adventureToEdit: Adventure | undefined;
let isShowingToast: boolean = false;
@@ -56,16 +59,13 @@
URL.revokeObjectURL(url);
}
- const createNewAdventure = () => {
- let currentDate = new Date();
- let dateString = currentDate.toISOString().slice(0, 10); // Get date in "yyyy-mm-dd" format
- // post to /api/visits
-
+ const createNewAdventure = (event: { detail: Adventure }) => {
let newAdventure: Adventure = {
type: "mylog",
- name: newName,
- location: newLocation,
- date: dateString,
+ name: event.detail.name,
+ location: event.detail.location,
+ date: event.detail.date,
+ description: event.detail.description,
id: -1,
};
@@ -87,9 +87,10 @@
{
id: newId,
type: "mylog",
- name: newName,
- location: newLocation,
- date: dateString,
+ name: event.detail.name,
+ location: event.detail.location,
+ date: event.detail.date,
+ description: event.detail.description,
},
];
newName = ""; // Reset newName and newLocation after adding adventure
@@ -111,6 +112,7 @@
location: event.detail.location,
date: event.detail.date,
id: event.detail.id,
+ description: event.detail.description,
};
// put request to /api/visits with id and advneture data
@@ -171,6 +173,7 @@
function handleClose() {
adventureToEdit = undefined;
+ isShowingMoreFields = false;
}
function deleteData() {
@@ -226,21 +229,13 @@