import { enhance } from "$app/forms";
import { goto } from "$app/navigation";
+ import InfoModal from "./InfoModal.svelte";
export let user: any;
let icon: string = "";
@@ -17,6 +18,8 @@
async function navToLog() {
goto("/log");
}
+
+ let isInfoModalOpen: boolean = false;
@@ -42,8 +45,17 @@
{/if}
+
+
+
+
+{#if isInfoModalOpen}
+ (isInfoModalOpen = false)} />
+{/if}
diff --git a/src/lib/index.ts b/src/lib/index.ts
index cc1f350..1d825a7 100644
--- a/src/lib/index.ts
+++ b/src/lib/index.ts
@@ -1,5 +1,6 @@
import inspirationalQuotes from "./json/quotes.json";
import countryCodes from "./json/countries.json";
+import type { Adventure } from "./utils/types";
/**
* Converts a country code to its corresponding country name.
@@ -8,7 +9,8 @@ import countryCodes from "./json/countries.json";
*/
export function countryCodeToName(countryCode: string): string | null {
// Look up the country name using the provided country code
- const countryName = countryCodes[countryCode.toLowerCase() as keyof typeof countryCodes];
+ const countryName =
+ countryCodes[countryCode.toLowerCase() as keyof typeof countryCodes];
// Return the country name if found, otherwise return null
return countryName || null;
}
@@ -19,10 +21,10 @@ export function countryCodeToName(countryCode: string): string | null {
* @param country - The 2 digit country code representing the desired flag.
* @returns The URL of the flag image.
*/
-export function getFlag(size:number,country: string) {
+export function getFlag(size: number, country: string) {
return `https://flagcdn.com/h${size}/${country}.png`;
}
-
+
/**
* Generates a random string consisting of alphanumeric characters.
* @returns {string} The randomly generated string.
@@ -48,5 +50,30 @@ export function getRandomQuote() {
const randomIndex = Math.floor(Math.random() * quotes.length);
let quoteString = quotes[randomIndex].quote;
let authorString = quotes[randomIndex].author;
- return "\"" + quoteString + "\" - " + authorString;
+ return '"' + quoteString + '" - ' + authorString;
+}
+
+/**
+ * Adds activity types to the adventure.
+ *
+ * @param activityInput - The input string containing activity types separated by commas.
+ * @param adventureToEdit - The adventure object to which the activity types will be added.
+ * @returns The adventure object with the updated activity types.
+ */
+export function addActivityType(
+ activityInput: string,
+ adventureToEdit: Adventure
+) {
+ if (activityInput.trim() !== "") {
+ const activities = activityInput
+ .split(",")
+ .filter((activity) => activity.trim() !== "");
+ // trims the whitespace from the activities
+ for (let i = 0; i < activities.length; i++) {
+ activities[i] = activities[i].trim();
+ }
+ adventureToEdit.activityTypes = activities;
+ activityInput = "";
+ }
+ return adventureToEdit;
}
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index 5e8b46c..8e905af 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -12,26 +12,281 @@
}
-
- {#if data.user && data.user.username != ""}
-
- Welcome {data.user.first_name}. Let's get Exploring!
-
- {:else}
-
Welcome. Let's get Exploring!
- {/if}
+
-
-
-
-
-
-
Logged Adventures
-
{$visitCount}
-
+
+
+
+
+
+
+ Discover the World's Most Thrilling Adventures
+
+
+ Discover and plan your next epic adventure with our cutting-edge
+ travel app. Explore breathtaking destinations, create custom
+ itineraries, and stay connected on the go.
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+ Key Features
+
+
+ Discover, Plan, and Explore with Ease
+
+
+ Our adventure travel app is designed to simplify your journey,
+ providing you with the tools and resources to plan, pack, and navigate
+ your next epic adventure.
+
+
+
+
+
+
+
+
+
+
+
Trip Planning
+
+ Easily create custom itineraries and get real-time updates on
+ your trip.
+
+
+
+
+
+
Packing Lists
+
+ Never forget a thing with our comprehensive packing lists.
+
+
+
+
+
+
Destination Guides
+
+ Discover the best attractions, activities, and hidden gems in
+ your destination.
+
+
+
+
+
+
+
+
+
+
Home | AdventureLog
diff --git a/src/routes/api/visits/+server.ts b/src/routes/api/visits/+server.ts
index 42dcb6c..5092016 100644
--- a/src/routes/api/visits/+server.ts
+++ b/src/routes/api/visits/+server.ts
@@ -180,7 +180,7 @@ export async function PUT(event: RequestEvent): Promise {
});
}
- 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 {
});
}
+ 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,
diff --git a/src/routes/planner/+page.svelte b/src/routes/planner/+page.svelte
index 8e9092d..409f3d1 100644
--- a/src/routes/planner/+page.svelte
+++ b/src/routes/planner/+page.svelte
@@ -8,6 +8,7 @@
saveAdventure,
removeAdventure,
addAdventure,
+ changeType,
} from "../../services/adventureService.js";
import SucessToast from "$lib/components/SucessToast.svelte";
import mapDrawing from "$lib/assets/adventure_map.svg";
@@ -87,6 +88,18 @@
showToast("Failed to add adventure");
}
};
+
+ async function markVisited(event: { detail: Adventure }) {
+ let initialLength: number = plans.length;
+ let newArray = await changeType(event.detail, "mylog", plans);
+ if (newArray.length + 1 == initialLength) {
+ plans = newArray;
+ showToast("Adventure moved to visit log!");
+ } else {
+ showToast("Failed to moves adventure");
+ }
+ adventureToEdit = undefined;
+ }
{#if isShowingToast}
@@ -131,6 +144,7 @@
type="planner"
on:edit={editPlan}
on:remove={remove}
+ on:markVisited={markVisited}
/>
{/each}