From c5ce984cac7d7a58335869defca5e1c8df5a3a24 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Sun, 14 Apr 2024 13:39:32 +0000 Subject: [PATCH 01/13] Add country_code field to userVisitedWorldTravel table --- migrations/0001_closed_wendell_vaughn.sql | 6 + migrations/meta/0001_snapshot.json | 385 ++++++++++++++++++ migrations/meta/_journal.json | 7 + src/lib/db/schema.ts | 3 + src/routes/api/regionvisit/+server.ts | 1 + .../worldtravel/[countrycode]/+page.server.ts | 10 +- .../worldtravel/[countrycode]/+page.svelte | 1 + 7 files changed, 411 insertions(+), 2 deletions(-) create mode 100644 migrations/0001_closed_wendell_vaughn.sql create mode 100644 migrations/meta/0001_snapshot.json diff --git a/migrations/0001_closed_wendell_vaughn.sql b/migrations/0001_closed_wendell_vaughn.sql new file mode 100644 index 0000000..9f9d831 --- /dev/null +++ b/migrations/0001_closed_wendell_vaughn.sql @@ -0,0 +1,6 @@ +ALTER TABLE "userVisitedWorldTravel" ADD COLUMN "country_code" text NOT NULL;--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "userVisitedWorldTravel" ADD CONSTRAINT "userVisitedWorldTravel_country_code_worldTravelCountries_country_code_fk" FOREIGN KEY ("country_code") REFERENCES "worldTravelCountries"("country_code") ON DELETE no action ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; diff --git a/migrations/meta/0001_snapshot.json b/migrations/meta/0001_snapshot.json new file mode 100644 index 0000000..6c4e538 --- /dev/null +++ b/migrations/meta/0001_snapshot.json @@ -0,0 +1,385 @@ +{ + "id": "4c095e1a-9f13-4899-aa83-f56864191f51", + "prevId": "b6ab23b7-42f0-4475-aa5d-23b92c00e97f", + "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": {} + }, + "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 + } + }, + "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 + } + }, + "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": {} + } +} \ No newline at end of file diff --git a/migrations/meta/_journal.json b/migrations/meta/_journal.json index ce56d99..66fa826 100644 --- a/migrations/meta/_journal.json +++ b/migrations/meta/_journal.json @@ -8,6 +8,13 @@ "when": 1713037717607, "tag": "0000_hard_mach_iv", "breakpoints": true + }, + { + "idx": 1, + "version": "5", + "when": 1713050481064, + "tag": "0001_closed_wendell_vaughn", + "breakpoints": true } ] } \ No newline at end of file diff --git a/src/lib/db/schema.ts b/src/lib/db/schema.ts index 2167882..89d201c 100644 --- a/src/lib/db/schema.ts +++ b/src/lib/db/schema.ts @@ -70,6 +70,9 @@ export const worldTravelCountryRegions = pgTable("worldTravelCountryRegions", { export const userVisitedWorldTravel = pgTable("userVisitedWorldTravel", { id: serial("id").primaryKey(), + country_code: text("country_code") + .notNull() + .references(() => worldTravelCountries.country_code), userId: text("user_id") .notNull() .references(() => userTable.id), diff --git a/src/routes/api/regionvisit/+server.ts b/src/routes/api/regionvisit/+server.ts index b28b75a..0c18c19 100644 --- a/src/routes/api/regionvisit/+server.ts +++ b/src/routes/api/regionvisit/+server.ts @@ -18,6 +18,7 @@ export async function POST(event: RequestEvent): Promise { .values({ userId: event.locals.user.id, region_id: body.region_id, + country_code: body.country_code, }) .execute(); return new Response(JSON.stringify({ res: res }), { diff --git a/src/routes/worldtravel/[countrycode]/+page.server.ts b/src/routes/worldtravel/[countrycode]/+page.server.ts index fab7813..da4a840 100644 --- a/src/routes/worldtravel/[countrycode]/+page.server.ts +++ b/src/routes/worldtravel/[countrycode]/+page.server.ts @@ -1,6 +1,6 @@ import { db } from '$lib/db/db.server.js'; import { userVisitedWorldTravel, worldTravelCountryRegions } from '$lib/db/schema.js'; -import { eq } from 'drizzle-orm'; +import { and, eq } from 'drizzle-orm'; import type { PageServerLoad } from './$types'; export const load: PageServerLoad = async ({ params, locals }) => { @@ -13,10 +13,16 @@ export const load: PageServerLoad = async ({ params, locals }) => { let visitedRegions: { id: number; userId: string; region_id: string; }[] = []; if (locals.user) { + let countryCode = params.countrycode visitedRegions = await db .select() .from(userVisitedWorldTravel) - .where(eq(userVisitedWorldTravel.userId, locals.user.id)) + .where( + and( + eq(userVisitedWorldTravel.userId, locals.user.id), + eq(userVisitedWorldTravel.country_code, countryCode) + ) + ) .execute(); } diff --git a/src/routes/worldtravel/[countrycode]/+page.svelte b/src/routes/worldtravel/[countrycode]/+page.svelte index 22f195a..2d73dc4 100644 --- a/src/routes/worldtravel/[countrycode]/+page.svelte +++ b/src/routes/worldtravel/[countrycode]/+page.svelte @@ -15,6 +15,7 @@ }, body: JSON.stringify({ region_id: event.detail, + country_code: data.countrycode, }), }).then((response) => { if (response.status === 401) { From 9c46c16bbe820067e3126729a0a6dedba141227d Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Sun, 14 Apr 2024 14:03:06 +0000 Subject: [PATCH 02/13] Update AdventureCard component to include regionId and visited properties, and add country flag support --- src/lib/components/maps/us.svelte | 876 ++++++++++++++++++++++++++++++ 1 file changed, 876 insertions(+) create mode 100644 src/lib/components/maps/us.svelte diff --git a/src/lib/components/maps/us.svelte b/src/lib/components/maps/us.svelte new file mode 100644 index 0000000..c1dd7bc --- /dev/null +++ b/src/lib/components/maps/us.svelte @@ -0,0 +1,876 @@ + + + + + + + + + handleStateClick("US-AL")} + > + + + + handleStateClick("US-AK")} + > + + + + handleStateClick("US-AZ")} + > + + + + handleStateClick("US-AR")} + > + + + + handleStateClick("US-CA")} + > + + + + handleStateClick("US-CO")} + > + + + + handleStateClick("US-CT")} + > + + + + + + handleStateClick("US-DE")} + > + + + + + + handleStateClick("US-FL")} + > + + + + handleStateClick("US-GA")} + > + + + + handleStateClick("US-HI")} + > + + + + handleStateClick("US-ID")} + > + + + + handleStateClick("US-IL")} + > + + + + handleStateClick("US-IN")} + > + + + + handleStateClick("US-IA")} + > + + + + handleStateClick("US-KS")} + > + + + + handleStateClick("US-KY")} + > + + + + handleStateClick("US-LA")} + > + + + + handleStateClick("US-ME")} + > + + + + handleStateClick("US-MD")} + > + + + + + + handleStateClick("US-MA")} + > + + + + + + handleStateClick("US-MI")} + > + + + + + handleStateClick("US-MN")} + > + + + + handleStateClick("US-MS")} + > + + + + handleStateClick("US-MO")} + > + + + + handleStateClick("US-MT")} + > + + + + handleStateClick("US-NE")} + > + + + + handleStateClick("US-NV")} + > + + + + handleStateClick("US-NH")} + > + + + + + + handleStateClick("US-NJ")} + > + + + + + + handleStateClick("US-NM")} + > + + + + handleStateClick("US-NY")} + > + + + + handleStateClick("US-NC")} + > + + + + handleStateClick("US-ND")} + > + + + + handleStateClick("US-OH")} + > + + + + handleStateClick("US-OK")} + > + + + + handleStateClick("US-OR")} + > + + + + handleStateClick("US-PA")} + > + + + + handleStateClick("US-RI")} + > + + + + + + handleStateClick("US-SC")} + > + + + + handleStateClick("US-SD")} + > + + + + handleStateClick("US-TN")} + > + + + + handleStateClick("US-TX")} + > + + + + handleStateClick("US-UT")} + > + + + + handleStateClick("US-VT")} + > + + + + + + handleStateClick("US-VA")} + > + + + + handleStateClick("US-WA")} + > + + + + handleStateClick("US-WV")} + > + + + + handleStateClick("US-WI")} + > + + + + handleStateClick("US-WY")} + > + + + + + + + From f58271e27c9a0627987a1be2842471c455e4f6c3 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Sun, 14 Apr 2024 16:56:27 +0000 Subject: [PATCH 03/13] Update docker-compose.yml to remove unnecessary volume mapping --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4a58128..04e8cd2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,8 +9,6 @@ services: - ORIGIN=http://localhost:3000 depends_on: - db - volumes: - - ./sql:/sql db: image: postgres environment: From c6d8730b4c456fb2eb12a2407289f38cb93bce08 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Sun, 14 Apr 2024 17:08:52 +0000 Subject: [PATCH 04/13] Add volume mapping for ./sql in docker-compose.yml --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 04e8cd2..4a58128 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,8 @@ services: - ORIGIN=http://localhost:3000 depends_on: - db + volumes: + - ./sql:/sql db: image: postgres environment: From 8133e8e99e1bc5e0804d04915d34ad8fb9b3def9 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Sun, 14 Apr 2024 17:44:52 +0000 Subject: [PATCH 05/13] Update AdventureCard component to include viewType property and add radio buttons for card and map views --- .../components/maps/{us.svelte => US.svelte} | 0 .../worldtravel/[countrycode]/+page.svelte | 58 ++++++++++++++----- 2 files changed, 43 insertions(+), 15 deletions(-) rename src/lib/components/maps/{us.svelte => US.svelte} (100%) diff --git a/src/lib/components/maps/us.svelte b/src/lib/components/maps/US.svelte similarity index 100% rename from src/lib/components/maps/us.svelte rename to src/lib/components/maps/US.svelte diff --git a/src/routes/worldtravel/[countrycode]/+page.svelte b/src/routes/worldtravel/[countrycode]/+page.svelte index 2d73dc4..cb7f916 100644 --- a/src/routes/worldtravel/[countrycode]/+page.svelte +++ b/src/routes/worldtravel/[countrycode]/+page.svelte @@ -6,6 +6,8 @@ import { goto } from "$app/navigation"; import { onMount } from "svelte"; + let viewType: String = "cards"; + function markVisited(event: { detail: string }) { console.log(`Marked ${event.detail} as visited`); fetch("/api/regionvisit", { @@ -43,6 +45,10 @@ }); } + function setViewType(type: String) { + viewType = type; + } + onMount(() => { console.log(data.visitedRegions); }); @@ -57,19 +63,41 @@ /> -
- {#each data.regions as region (region.id)} - visitedRegion.region_id === region.id, - )} - on:removeVisit={removeVisit} - /> - {/each} +
+ setViewType("cards")} + /> + setViewType("map")} + />
+ +{#if viewType == "cards"} +
+ {#each data.regions as region (region.id)} + visitedRegion.region_id === region.id, + )} + on:removeVisit={removeVisit} + /> + {/each} +
+{/if} + +{#if viewType == "map"}{/if} From 715a4ffd878793723b3d721a955dd9c7e0579e5d Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Sun, 14 Apr 2024 17:58:18 +0000 Subject: [PATCH 06/13] Add US map component to world travel page --- src/lib/components/maps/US.svelte | 4 ++++ src/routes/worldtravel/[countrycode]/+page.svelte | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/components/maps/US.svelte b/src/lib/components/maps/US.svelte index c1dd7bc..7b24e5d 100644 --- a/src/lib/components/maps/US.svelte +++ b/src/lib/components/maps/US.svelte @@ -1,6 +1,9 @@ @@ -12,6 +15,7 @@ version="1.1" width="1200" height="600" + fill="#ffffff" > diff --git a/src/routes/worldtravel/[countrycode]/+page.svelte b/src/routes/worldtravel/[countrycode]/+page.svelte index cb7f916..bbafcdc 100644 --- a/src/routes/worldtravel/[countrycode]/+page.svelte +++ b/src/routes/worldtravel/[countrycode]/+page.svelte @@ -5,6 +5,7 @@ import { getFlag } from "$lib"; import { goto } from "$app/navigation"; import { onMount } from "svelte"; + import Us from "$lib/components/maps/US.svelte"; let viewType: String = "cards"; @@ -100,4 +101,8 @@
{/if} -{#if viewType == "map"}{/if} +{#if viewType == "map"} + {#if data.countrycode.toLowerCase() == "us"} + + {/if} +{/if} From a550fd58f76760229c842f061272597ffadf0f07 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Sun, 14 Apr 2024 20:33:58 +0000 Subject: [PATCH 07/13] Update AdventureCard component to include regionId and visited properties, and add country flag support --- migrations/0002_far_mephistopheles.sql | 1 + migrations/meta/0002_snapshot.json | 391 ++++++++++++++++++ migrations/meta/_journal.json | 7 + sql/002_us.sql | 54 ++- src/lib/components/AdventureCard.svelte | 7 + src/lib/db/schema.ts | 1 + src/lib/utils/types.ts | 33 ++ .../worldtravel/[countrycode]/+page.svelte | 1 + .../[regioncode]/+page.server.ts | 34 ++ .../[countrycode]/[regioncode]/+page.svelte | 20 + 10 files changed, 548 insertions(+), 1 deletion(-) create mode 100644 migrations/0002_far_mephistopheles.sql create mode 100644 migrations/meta/0002_snapshot.json create mode 100644 src/routes/worldtravel/[countrycode]/[regioncode]/+page.server.ts create mode 100644 src/routes/worldtravel/[countrycode]/[regioncode]/+page.svelte diff --git a/migrations/0002_far_mephistopheles.sql b/migrations/0002_far_mephistopheles.sql new file mode 100644 index 0000000..5a0139a --- /dev/null +++ b/migrations/0002_far_mephistopheles.sql @@ -0,0 +1 @@ +ALTER TABLE "worldTravelCountryRegions" ADD COLUMN "info" json; \ No newline at end of file diff --git a/migrations/meta/0002_snapshot.json b/migrations/meta/0002_snapshot.json new file mode 100644 index 0000000..f84336c --- /dev/null +++ b/migrations/meta/0002_snapshot.json @@ -0,0 +1,391 @@ +{ + "id": "91692e84-91ec-4411-ad9d-7b8b14f67dda", + "prevId": "4c095e1a-9f13-4899-aa83-f56864191f51", + "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": {} + }, + "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 + } + }, + "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": {} + } +} \ No newline at end of file diff --git a/migrations/meta/_journal.json b/migrations/meta/_journal.json index 66fa826..12ecd45 100644 --- a/migrations/meta/_journal.json +++ b/migrations/meta/_journal.json @@ -15,6 +15,13 @@ "when": 1713050481064, "tag": "0001_closed_wendell_vaughn", "breakpoints": true + }, + { + "idx": 2, + "version": "5", + "when": 1713125110816, + "tag": "0002_far_mephistopheles", + "breakpoints": true } ] } \ No newline at end of file diff --git a/sql/002_us.sql b/sql/002_us.sql index aef770c..1ae5546 100644 --- a/sql/002_us.sql +++ b/sql/002_us.sql @@ -1,6 +1,58 @@ INSERT INTO "worldTravelCountryRegions" (id, name, country_code) VALUES - ('US-AL', 'Alabama', 'us'), + ('US-AL', 'Alabama', 'us', '{ + "name": "Alabama", + "abbreviation": "AL", + "description": "Alabama is a state located in the southeastern region of the United States. Known for its rich history, including its role in the American Civil War and the Civil Rights Movement, Alabama offers a diverse landscape of mountains, plains, and coastal areas. The state boasts a humid subtropical climate and is known for its strong tradition in college sports, particularly football. Alabama's economy is diverse, with major industries including automotive manufacturing, agriculture, and aerospace. Tourists are drawn to Alabama's natural beauty, historical sites, and cultural landmarks.", + "capital": "Montgomery", + "largest_city": "Birmingham", + "area": { + "total": 52420, + "units": "square miles" + }, + "population": { + "estimate": 4903185, + "year": 2020 + }, + "state_flower": "Camellia", + "state_bird": "Yellowhammer", + "state_tree": "Southern Longleaf Pine", + "climate": { + "description": "Humid subtropical", + "summer_highs": "80-90°F", + "winter_lows": "30-50°F", + "precipitation": "Abundant throughout the year" + }, + "economy": { + "industries": [ + "Automotive Manufacturing", + "Agriculture", + "Mining", + "Technology", + "Aerospace" + ], + "agricultural_products": [ + "Poultry", + "Cotton", + "Peanuts", + "Soybeans", + "Corn" + ] + }, + "tourism": { + "attractions": [ + "U.S. Space & Rocket Center", + "Gulf Shores and Orange Beach", + "Rosa Parks Museum", + "Civil Rights Institute", + "Little River Canyon National Preserve" + ] + }, + "major_sports_teams": [ + "Alabama Crimson Tide (NCAA)", + "Auburn Tigers (NCAA)" + ] +}'), ('US-AK', 'Alaska', 'us'), ('US-AZ', 'Arizona', 'us'), ('US-AR', 'Arkansas', 'us'), diff --git a/src/lib/components/AdventureCard.svelte b/src/lib/components/AdventureCard.svelte index c88d253..5ed4e82 100644 --- a/src/lib/components/AdventureCard.svelte +++ b/src/lib/components/AdventureCard.svelte @@ -2,6 +2,7 @@ import { createEventDispatcher } from "svelte"; import locationDot from "$lib/assets/locationDot.svg"; import calendar from "$lib/assets/calendar.svg"; + import { goto } from "$app/navigation"; const dispatch = createEventDispatcher(); export let type: String; @@ -12,6 +13,7 @@ export let id: Number | undefined = undefined; export let regionId: String | undefined = undefined; export let visited: Boolean | undefined = undefined; + export let countryCode: String | undefined = undefined; function remove() { dispatch("remove", id); @@ -30,6 +32,10 @@ dispatch("removeVisit", regionId); visited = false; } + + function moreInfo() { + goto(`/worldtravel/${countryCode}/${regionId}`); + } {#if type === "mylog"} @@ -122,6 +128,7 @@

{name}

{regionId}

+ {#if !visited} worldTravelCountries.country_code), + info: json("info"), }); export const userVisitedWorldTravel = pgTable("userVisitedWorldTravel", { diff --git a/src/lib/utils/types.ts b/src/lib/utils/types.ts index 39cb486..645621c 100644 --- a/src/lib/utils/types.ts +++ b/src/lib/utils/types.ts @@ -4,3 +4,36 @@ export interface Adventure { location: string; created: string; } + +export interface RegionInfo { + name: string; + abbreviation: string; + description: string; + capital: string; + largest_city: string; + area: { + total: number; + units: string; + }; + population: { + estimate: number; + year: number; + }; + state_flower: string; + state_bird: string; + state_tree: string; + climate: { + description: string; + summer_highs: string; + winter_lows: string; + precipitation: string; + }; + economy: { + industries: string[]; + agricultural_products: string[]; + }; + tourism: { + attractions: string[]; + }; + major_sports_teams: string[]; +}; diff --git a/src/routes/worldtravel/[countrycode]/+page.svelte b/src/routes/worldtravel/[countrycode]/+page.svelte index bbafcdc..9c4ff20 100644 --- a/src/routes/worldtravel/[countrycode]/+page.svelte +++ b/src/routes/worldtravel/[countrycode]/+page.svelte @@ -89,6 +89,7 @@ {#each data.regions as region (region.id)} { + const { regioncode } = params; + + let info = await db + .select({data: worldTravelCountryRegions}) + .from(worldTravelCountryRegions) + .where(eq(worldTravelCountryRegions.id, regioncode)) + .limit(1) + .execute(); + + let visited = false; + if (locals.user) { + let userVisited = await db + .select({data: userVisitedWorldTravel}) + .from(userVisitedWorldTravel) + .where(and(eq(userVisitedWorldTravel.userId, locals.user.id), eq(userVisitedWorldTravel.region_id, regioncode))) + .limit(1) + .execute(); + if (userVisited.length !== 0) { + visited = true; + } + } + + return { + info : info[0], + visited : visited, + }; +} \ No newline at end of file diff --git a/src/routes/worldtravel/[countrycode]/[regioncode]/+page.svelte b/src/routes/worldtravel/[countrycode]/[regioncode]/+page.svelte new file mode 100644 index 0000000..ead9b7b --- /dev/null +++ b/src/routes/worldtravel/[countrycode]/[regioncode]/+page.svelte @@ -0,0 +1,20 @@ + + +

Info About {regionName} in {country}

+{#if visited} +

You have visited this region!

+{/if} + +

Region Info

+{#if info.description} +

{info.description}

+{/if} From 6aca3d72b018b4d6b82cf9a5d19c649f6bb88573 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Sun, 14 Apr 2024 20:47:52 +0000 Subject: [PATCH 08/13] Update region page to display detailed information about a region in the world travel section --- sql/002_us.sql | 168 +++++++++++++++++- .../[countrycode]/[regioncode]/+page.svelte | 82 ++++++++- 2 files changed, 239 insertions(+), 11 deletions(-) diff --git a/sql/002_us.sql b/sql/002_us.sql index 1ae5546..6fca4aa 100644 --- a/sql/002_us.sql +++ b/sql/002_us.sql @@ -3,7 +3,7 @@ VALUES ('US-AL', 'Alabama', 'us', '{ "name": "Alabama", "abbreviation": "AL", - "description": "Alabama is a state located in the southeastern region of the United States. Known for its rich history, including its role in the American Civil War and the Civil Rights Movement, Alabama offers a diverse landscape of mountains, plains, and coastal areas. The state boasts a humid subtropical climate and is known for its strong tradition in college sports, particularly football. Alabama's economy is diverse, with major industries including automotive manufacturing, agriculture, and aerospace. Tourists are drawn to Alabama's natural beauty, historical sites, and cultural landmarks.", + "description": "Alabama is a state located in the southeastern region of the United States. Known for its rich history, including its role in the American Civil War and the Civil Rights Movement, Alabama offers a diverse landscape of mountains, plains, and coastal areas. The state boasts a humid subtropical climate and is known for its strong tradition in college sports, particularly football. Alabama''s economy is diverse, with major industries including automotive manufacturing, agriculture, and aerospace. Tourists are drawn to Alabama''s natural beauty, historical sites, and cultural landmarks.", "capital": "Montgomery", "largest_city": "Birmingham", "area": { @@ -53,9 +53,169 @@ VALUES "Auburn Tigers (NCAA)" ] }'), - ('US-AK', 'Alaska', 'us'), - ('US-AZ', 'Arizona', 'us'), - ('US-AR', 'Arkansas', 'us'), + ('US-AK', 'Alaska', 'us', '{ + "name": "Alaska", + "abbreviation": "AK", + "description": "Alaska is the largest state in the United States by area, known for its rugged and breathtaking natural beauty. It is situated in the northwesternmost region of North America and is bordered by Canada to the east, the Arctic Ocean to the north, and the Pacific Ocean to the west and south. Alaska is renowned for its diverse wildlife, glaciers, and majestic mountains. The state is sparsely populated, with the majority of its residents living in and around Anchorage and Fairbanks. Alaska''s economy is heavily dependent on oil and gas production, as well as fishing, tourism, and mining.", + "capital": "Juneau", + "largest_city": "Anchorage", + "area": { + "total": 663267, + "units": "square miles" + }, + "population": { + "estimate": 731158, + "year": 2020 + }, + "state_flower": "Forget-Me-Not", + "state_bird": "Willow Ptarmigan", + "state_tree": "Sitka Spruce", + "climate": { + "description": "Varies by region, with subarctic and arctic climates in the interior and north and more temperate maritime climates along the coast.", + "summer_highs": "50-70°F (varies by region)", + "winter_lows": "-40 to 20°F (varies by region)", + "precipitation": "Ranges from low in the interior to high along the coast" + }, + "economy": { + "industries": [ + "Oil and Gas", + "Fishing", + "Mining", + "Tourism", + "Forestry" + ], + "agricultural_products": [ + "Cattle", + "Hay", + "Vegetables", + "Barley", + "Dairy products" + ] + }, + "tourism": { + "attractions": [ + "Denali National Park", + "Glacier Bay National Park", + "Kenai Fjords National Park", + "Sitka National Historical Park", + "Anchorage Museum" + ] + }, + "major_sports_teams": [ + "Anchorage Wolverines (NAHL)", + "Alaska Aces (ECHL, formerly)" + ] +} +'), + ('US-AZ', 'Arizona', 'us', '{ + "name": "Arizona", + "abbreviation": "AZ", + "description": "Arizona is a state located in the southwestern region of the United States, known for its dramatic desert landscapes and vibrant history. The state is home to iconic landmarks such as the Grand Canyon and Monument Valley. Arizona''s diverse geography includes mountain ranges, forests, and high plateaus. The state has a warm desert climate in the southern and central areas and cooler mountain climates in the northern region. Arizona''s economy is driven by industries such as healthcare, technology, manufacturing, and tourism.", + "capital": "Phoenix", + "largest_city": "Phoenix", + "area": { + "total": 113990, + "units": "square miles" + }, + "population": { + "estimate": 7151502, + "year": 2020 + }, + "state_flower": "Saguaro Cactus Blossom", + "state_bird": "Cactus Wren", + "state_tree": "Palo Verde", + "climate": { + "description": "Mostly arid and semi-arid, with desert climates in the southern and central regions and temperate climates in the north.", + "summer_highs": "85-120°F (varies by region)", + "winter_lows": "30-60°F (varies by region)", + "precipitation": "Low in most areas, with higher amounts in mountain regions" + }, + "economy": { + "industries": [ + "Healthcare", + "Technology", + "Manufacturing", + "Tourism", + "Agriculture" + ], + "agricultural_products": [ + "Cattle", + "Dairy", + "Lettuce", + "Cotton", + "Alfalfa" + ] + }, + "tourism": { + "attractions": [ + "Grand Canyon National Park", + "Sedona", + "Monument Valley", + "Saguaro National Park", + "Petrified Forest National Park" + ] + }, + "major_sports_teams": [ + "Arizona Cardinals (NFL)", + "Phoenix Suns (NBA)", + "Arizona Diamondbacks (MLB)", + "Arizona Coyotes (NHL)" + ] +} +'), + ('US-AR', 'Arkansas', 'us', '{ + "name": "Arkansas", + "abbreviation": "AR", + "description": "Arkansas is a state located in the southeastern region of the United States, known for its natural beauty and diverse landscapes that include mountains, forests, and rivers. The state is nicknamed ''The Natural State'' due to its abundant natural resources and outdoor recreational opportunities. Arkansas has a rich history and played a significant role during the American Civil War. The state''s economy is driven by agriculture, manufacturing, and tourism, with key agricultural products including rice, poultry, and soybeans.", + "capital": "Little Rock", + "largest_city": "Little Rock", + "area": { + "total": 53179, + "units": "square miles" + }, + "population": { + "estimate": 3013756, + "year": 2020 + }, + "state_flower": "Apple Blossom", + "state_bird": "Northern Mockingbird", + "state_tree": "Pine", + "climate": { + "description": "Humid subtropical climate, with hot summers and mild winters.", + "summer_highs": "80-90°F", + "winter_lows": "20-40°F", + "precipitation": "High, especially in the spring" + }, + "economy": { + "industries": [ + "Agriculture", + "Manufacturing", + "Retail", + "Tourism", + "Education" + ], + "agricultural_products": [ + "Rice", + "Poultry", + "Soybeans", + "Cotton", + "Catfish" + ] + }, + "tourism": { + "attractions": [ + "Hot Springs National Park", + "Buffalo National River", + "Crater of Diamonds State Park", + "Little Rock Central High School National Historic Site", + "Ozark National Forest" + ] + }, + "major_sports_teams": [ + "Arkansas Razorbacks (NCAA)" + ] +} +'), ('US-CA', 'California', 'us'), ('US-CO', 'Colorado', 'us'), ('US-CT', 'Connecticut', 'us'), diff --git a/src/routes/worldtravel/[countrycode]/[regioncode]/+page.svelte b/src/routes/worldtravel/[countrycode]/[regioncode]/+page.svelte index ead9b7b..abc5aeb 100644 --- a/src/routes/worldtravel/[countrycode]/[regioncode]/+page.svelte +++ b/src/routes/worldtravel/[countrycode]/[regioncode]/+page.svelte @@ -9,12 +9,80 @@ let visited = data.visited; -

Info About {regionName} in {country}

-{#if visited} -

You have visited this region!

-{/if} +{#if info} +
+
+

Info About {regionName} in {country}

+ {#if visited} +

You have visited this region!

+ {/if} -

Region Info

-{#if info.description} -

{info.description}

+

Region Info

+ {#if info.description} +

{info.description}

+ {/if} + {#if info.capital} +

Capital: {info.capital}

+ {/if} + {#if info.population} +

+ Population: + {info.population.estimate} ({info.population.year}) +

+ {/if} + {#if info.area} +

Area: {info.area.total} {info.area.units}

+ {/if} + {#if info.state_flower} +

State Flower: {info.state_flower}

+ {/if} + {#if info.state_bird} +

State Bird: {info.state_bird}

+ {/if} + {#if info.state_tree} +

State Tree: {info.state_tree}

+ {/if} + {#if info.climate} +

Climate: {info.climate.description}

+

Summer Highs: {info.climate.summer_highs}

+

Winter Lows: {info.climate.winter_lows}

+

Precipitation: {info.climate.precipitation}

+ {/if} + {#if info.economy} + {#if info.economy.industries && info.economy.industries.length} +

+ Industries: + {info.economy.industries.join(", ")} +

+ {/if} + {#if info.economy.agricultural_products && info.economy.agricultural_products.length} +

+ Agricultural Products: + {info.economy.agricultural_products.join(", ")} +

+ {/if} + {/if} + {#if info.tourism} + {#if info.tourism.attractions && info.tourism.attractions.length} +

+ Tourism Attractions: + {info.tourism.attractions.join(", ")} +

+ {/if} + {/if} + {#if info.major_sports_teams && info.major_sports_teams.length} +

+ Major Sports Teams: + {info.major_sports_teams.join(", ")} +

+ {/if} +
+
+{:else} +
+
+

Region Not Found

+

Sorry, we couldn't find the region you were looking for.

+
+
{/if} From 1710c5b54de02038951abba072571e43870a31fc Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Sun, 14 Apr 2024 23:47:05 +0000 Subject: [PATCH 09/13] Update AdventureCard component to remove commented out code and add exportData function to log page --- sql/002_us.sql | 441 ++++++++++++------------ src/lib/components/AdventureCard.svelte | 2 +- src/routes/log/+page.svelte | 20 +- 3 files changed, 237 insertions(+), 226 deletions(-) diff --git a/sql/002_us.sql b/sql/002_us.sql index 6fca4aa..efa1082 100644 --- a/sql/002_us.sql +++ b/sql/002_us.sql @@ -1,221 +1,226 @@ -INSERT INTO "worldTravelCountryRegions" (id, name, country_code) -VALUES - ('US-AL', 'Alabama', 'us', '{ - "name": "Alabama", - "abbreviation": "AL", - "description": "Alabama is a state located in the southeastern region of the United States. Known for its rich history, including its role in the American Civil War and the Civil Rights Movement, Alabama offers a diverse landscape of mountains, plains, and coastal areas. The state boasts a humid subtropical climate and is known for its strong tradition in college sports, particularly football. Alabama''s economy is diverse, with major industries including automotive manufacturing, agriculture, and aerospace. Tourists are drawn to Alabama''s natural beauty, historical sites, and cultural landmarks.", - "capital": "Montgomery", - "largest_city": "Birmingham", - "area": { - "total": 52420, - "units": "square miles" - }, - "population": { - "estimate": 4903185, - "year": 2020 - }, - "state_flower": "Camellia", - "state_bird": "Yellowhammer", - "state_tree": "Southern Longleaf Pine", - "climate": { - "description": "Humid subtropical", - "summer_highs": "80-90°F", - "winter_lows": "30-50°F", - "precipitation": "Abundant throughout the year" - }, - "economy": { - "industries": [ - "Automotive Manufacturing", - "Agriculture", - "Mining", - "Technology", - "Aerospace" - ], - "agricultural_products": [ - "Poultry", - "Cotton", - "Peanuts", - "Soybeans", - "Corn" - ] - }, - "tourism": { - "attractions": [ - "U.S. Space & Rocket Center", - "Gulf Shores and Orange Beach", - "Rosa Parks Museum", - "Civil Rights Institute", - "Little River Canyon National Preserve" - ] - }, - "major_sports_teams": [ - "Alabama Crimson Tide (NCAA)", - "Auburn Tigers (NCAA)" - ] -}'), - ('US-AK', 'Alaska', 'us', '{ - "name": "Alaska", - "abbreviation": "AK", - "description": "Alaska is the largest state in the United States by area, known for its rugged and breathtaking natural beauty. It is situated in the northwesternmost region of North America and is bordered by Canada to the east, the Arctic Ocean to the north, and the Pacific Ocean to the west and south. Alaska is renowned for its diverse wildlife, glaciers, and majestic mountains. The state is sparsely populated, with the majority of its residents living in and around Anchorage and Fairbanks. Alaska''s economy is heavily dependent on oil and gas production, as well as fishing, tourism, and mining.", - "capital": "Juneau", - "largest_city": "Anchorage", - "area": { - "total": 663267, - "units": "square miles" - }, - "population": { - "estimate": 731158, - "year": 2020 - }, - "state_flower": "Forget-Me-Not", - "state_bird": "Willow Ptarmigan", - "state_tree": "Sitka Spruce", - "climate": { - "description": "Varies by region, with subarctic and arctic climates in the interior and north and more temperate maritime climates along the coast.", - "summer_highs": "50-70°F (varies by region)", - "winter_lows": "-40 to 20°F (varies by region)", - "precipitation": "Ranges from low in the interior to high along the coast" - }, - "economy": { - "industries": [ - "Oil and Gas", - "Fishing", - "Mining", - "Tourism", - "Forestry" - ], - "agricultural_products": [ - "Cattle", - "Hay", - "Vegetables", - "Barley", - "Dairy products" - ] - }, - "tourism": { - "attractions": [ - "Denali National Park", - "Glacier Bay National Park", - "Kenai Fjords National Park", - "Sitka National Historical Park", - "Anchorage Museum" - ] - }, - "major_sports_teams": [ - "Anchorage Wolverines (NAHL)", - "Alaska Aces (ECHL, formerly)" - ] -} -'), - ('US-AZ', 'Arizona', 'us', '{ - "name": "Arizona", - "abbreviation": "AZ", - "description": "Arizona is a state located in the southwestern region of the United States, known for its dramatic desert landscapes and vibrant history. The state is home to iconic landmarks such as the Grand Canyon and Monument Valley. Arizona''s diverse geography includes mountain ranges, forests, and high plateaus. The state has a warm desert climate in the southern and central areas and cooler mountain climates in the northern region. Arizona''s economy is driven by industries such as healthcare, technology, manufacturing, and tourism.", - "capital": "Phoenix", - "largest_city": "Phoenix", - "area": { - "total": 113990, - "units": "square miles" - }, - "population": { - "estimate": 7151502, - "year": 2020 - }, - "state_flower": "Saguaro Cactus Blossom", - "state_bird": "Cactus Wren", - "state_tree": "Palo Verde", - "climate": { - "description": "Mostly arid and semi-arid, with desert climates in the southern and central regions and temperate climates in the north.", - "summer_highs": "85-120°F (varies by region)", - "winter_lows": "30-60°F (varies by region)", - "precipitation": "Low in most areas, with higher amounts in mountain regions" - }, - "economy": { - "industries": [ - "Healthcare", - "Technology", - "Manufacturing", - "Tourism", - "Agriculture" - ], - "agricultural_products": [ - "Cattle", - "Dairy", - "Lettuce", - "Cotton", - "Alfalfa" - ] - }, - "tourism": { - "attractions": [ - "Grand Canyon National Park", - "Sedona", - "Monument Valley", - "Saguaro National Park", - "Petrified Forest National Park" - ] - }, - "major_sports_teams": [ - "Arizona Cardinals (NFL)", - "Phoenix Suns (NBA)", - "Arizona Diamondbacks (MLB)", - "Arizona Coyotes (NHL)" - ] -} -'), - ('US-AR', 'Arkansas', 'us', '{ - "name": "Arkansas", - "abbreviation": "AR", - "description": "Arkansas is a state located in the southeastern region of the United States, known for its natural beauty and diverse landscapes that include mountains, forests, and rivers. The state is nicknamed ''The Natural State'' due to its abundant natural resources and outdoor recreational opportunities. Arkansas has a rich history and played a significant role during the American Civil War. The state''s economy is driven by agriculture, manufacturing, and tourism, with key agricultural products including rice, poultry, and soybeans.", - "capital": "Little Rock", - "largest_city": "Little Rock", - "area": { - "total": 53179, - "units": "square miles" - }, - "population": { - "estimate": 3013756, - "year": 2020 - }, - "state_flower": "Apple Blossom", - "state_bird": "Northern Mockingbird", - "state_tree": "Pine", - "climate": { - "description": "Humid subtropical climate, with hot summers and mild winters.", - "summer_highs": "80-90°F", - "winter_lows": "20-40°F", - "precipitation": "High, especially in the spring" - }, - "economy": { - "industries": [ - "Agriculture", - "Manufacturing", - "Retail", - "Tourism", - "Education" - ], - "agricultural_products": [ - "Rice", - "Poultry", - "Soybeans", - "Cotton", - "Catfish" - ] - }, - "tourism": { - "attractions": [ - "Hot Springs National Park", - "Buffalo National River", - "Crater of Diamonds State Park", - "Little Rock Central High School National Historic Site", - "Ozark National Forest" - ] - }, - "major_sports_teams": [ - "Arkansas Razorbacks (NCAA)" - ] -} -'), +-- INSERT INTO "worldTravelCountryRegions" (id, name, country_code) +-- VALUES +-- ('US-AL', 'Alabama', 'us', '{ +-- "name": "Alabama", +-- "abbreviation": "AL", +-- "description": "Alabama is a state located in the southeastern region of the United States. Known for its rich history, including its role in the American Civil War and the Civil Rights Movement, Alabama offers a diverse landscape of mountains, plains, and coastal areas. The state boasts a humid subtropical climate and is known for its strong tradition in college sports, particularly football. Alabama''s economy is diverse, with major industries including automotive manufacturing, agriculture, and aerospace. Tourists are drawn to Alabama''s natural beauty, historical sites, and cultural landmarks.", +-- "capital": "Montgomery", +-- "largest_city": "Birmingham", +-- "area": { +-- "total": 52420, +-- "units": "square miles" +-- }, +-- "population": { +-- "estimate": 4903185, +-- "year": 2020 +-- }, +-- "state_flower": "Camellia", +-- "state_bird": "Yellowhammer", +-- "state_tree": "Southern Longleaf Pine", +-- "climate": { +-- "description": "Humid subtropical", +-- "summer_highs": "80-90°F", +-- "winter_lows": "30-50°F", +-- "precipitation": "Abundant throughout the year" +-- }, +-- "economy": { +-- "industries": [ +-- "Automotive Manufacturing", +-- "Agriculture", +-- "Mining", +-- "Technology", +-- "Aerospace" +-- ], +-- "agricultural_products": [ +-- "Poultry", +-- "Cotton", +-- "Peanuts", +-- "Soybeans", +-- "Corn" +-- ] +-- }, +-- "tourism": { +-- "attractions": [ +-- "U.S. Space & Rocket Center", +-- "Gulf Shores and Orange Beach", +-- "Rosa Parks Museum", +-- "Civil Rights Institute", +-- "Little River Canyon National Preserve" +-- ] +-- }, +-- "major_sports_teams": [ +-- "Alabama Crimson Tide (NCAA)", +-- "Auburn Tigers (NCAA)" +-- ] +-- }'), +-- ('US-AK', 'Alaska', 'us', '{ +-- "name": "Alaska", +-- "abbreviation": "AK", +-- "description": "Alaska is the largest state in the United States by area, known for its rugged and breathtaking natural beauty. It is situated in the northwesternmost region of North America and is bordered by Canada to the east, the Arctic Ocean to the north, and the Pacific Ocean to the west and south. Alaska is renowned for its diverse wildlife, glaciers, and majestic mountains. The state is sparsely populated, with the majority of its residents living in and around Anchorage and Fairbanks. Alaska''s economy is heavily dependent on oil and gas production, as well as fishing, tourism, and mining.", +-- "capital": "Juneau", +-- "largest_city": "Anchorage", +-- "area": { +-- "total": 663267, +-- "units": "square miles" +-- }, +-- "population": { +-- "estimate": 731158, +-- "year": 2020 +-- }, +-- "state_flower": "Forget-Me-Not", +-- "state_bird": "Willow Ptarmigan", +-- "state_tree": "Sitka Spruce", +-- "climate": { +-- "description": "Varies by region, with subarctic and arctic climates in the interior and north and more temperate maritime climates along the coast.", +-- "summer_highs": "50-70°F (varies by region)", +-- "winter_lows": "-40 to 20°F (varies by region)", +-- "precipitation": "Ranges from low in the interior to high along the coast" +-- }, +-- "economy": { +-- "industries": [ +-- "Oil and Gas", +-- "Fishing", +-- "Mining", +-- "Tourism", +-- "Forestry" +-- ], +-- "agricultural_products": [ +-- "Cattle", +-- "Hay", +-- "Vegetables", +-- "Barley", +-- "Dairy products" +-- ] +-- }, +-- "tourism": { +-- "attractions": [ +-- "Denali National Park", +-- "Glacier Bay National Park", +-- "Kenai Fjords National Park", +-- "Sitka National Historical Park", +-- "Anchorage Museum" +-- ] +-- }, +-- "major_sports_teams": [ +-- "Anchorage Wolverines (NAHL)", +-- "Alaska Aces (ECHL, formerly)" +-- ] +-- } +-- '), +-- ('US-AZ', 'Arizona', 'us', '{ +-- "name": "Arizona", +-- "abbreviation": "AZ", +-- "description": "Arizona is a state located in the southwestern region of the United States, known for its dramatic desert landscapes and vibrant history. The state is home to iconic landmarks such as the Grand Canyon and Monument Valley. Arizona''s diverse geography includes mountain ranges, forests, and high plateaus. The state has a warm desert climate in the southern and central areas and cooler mountain climates in the northern region. Arizona''s economy is driven by industries such as healthcare, technology, manufacturing, and tourism.", +-- "capital": "Phoenix", +-- "largest_city": "Phoenix", +-- "area": { +-- "total": 113990, +-- "units": "square miles" +-- }, +-- "population": { +-- "estimate": 7151502, +-- "year": 2020 +-- }, +-- "state_flower": "Saguaro Cactus Blossom", +-- "state_bird": "Cactus Wren", +-- "state_tree": "Palo Verde", +-- "climate": { +-- "description": "Mostly arid and semi-arid, with desert climates in the southern and central regions and temperate climates in the north.", +-- "summer_highs": "85-120°F (varies by region)", +-- "winter_lows": "30-60°F (varies by region)", +-- "precipitation": "Low in most areas, with higher amounts in mountain regions" +-- }, +-- "economy": { +-- "industries": [ +-- "Healthcare", +-- "Technology", +-- "Manufacturing", +-- "Tourism", +-- "Agriculture" +-- ], +-- "agricultural_products": [ +-- "Cattle", +-- "Dairy", +-- "Lettuce", +-- "Cotton", +-- "Alfalfa" +-- ] +-- }, +-- "tourism": { +-- "attractions": [ +-- "Grand Canyon National Park", +-- "Sedona", +-- "Monument Valley", +-- "Saguaro National Park", +-- "Petrified Forest National Park" +-- ] +-- }, +-- "major_sports_teams": [ +-- "Arizona Cardinals (NFL)", +-- "Phoenix Suns (NBA)", +-- "Arizona Diamondbacks (MLB)", +-- "Arizona Coyotes (NHL)" +-- ] +-- } +-- '), +-- ('US-AR', 'Arkansas', 'us', '{ +-- "name": "Arkansas", +-- "abbreviation": "AR", +-- "description": "Arkansas is a state located in the southeastern region of the United States, known for its natural beauty and diverse landscapes that include mountains, forests, and rivers. The state is nicknamed ''The Natural State'' due to its abundant natural resources and outdoor recreational opportunities. Arkansas has a rich history and played a significant role during the American Civil War. The state''s economy is driven by agriculture, manufacturing, and tourism, with key agricultural products including rice, poultry, and soybeans.", +-- "capital": "Little Rock", +-- "largest_city": "Little Rock", +-- "area": { +-- "total": 53179, +-- "units": "square miles" +-- }, +-- "population": { +-- "estimate": 3013756, +-- "year": 2020 +-- }, +-- "state_flower": "Apple Blossom", +-- "state_bird": "Northern Mockingbird", +-- "state_tree": "Pine", +-- "climate": { +-- "description": "Humid subtropical climate, with hot summers and mild winters.", +-- "summer_highs": "80-90°F", +-- "winter_lows": "20-40°F", +-- "precipitation": "High, especially in the spring" +-- }, +-- "economy": { +-- "industries": [ +-- "Agriculture", +-- "Manufacturing", +-- "Retail", +-- "Tourism", +-- "Education" +-- ], +-- "agricultural_products": [ +-- "Rice", +-- "Poultry", +-- "Soybeans", +-- "Cotton", +-- "Catfish" +-- ] +-- }, +-- "tourism": { +-- "attractions": [ +-- "Hot Springs National Park", +-- "Buffalo National River", +-- "Crater of Diamonds State Park", +-- "Little Rock Central High School National Historic Site", +-- "Ozark National Forest" +-- ] +-- }, +-- "major_sports_teams": [ +-- "Arkansas Razorbacks (NCAA)" +-- ] +-- } +-- '), +INSERT INTO "worldTravelCountryRegions" (id, name, country_code) VALUES + ('US-AL', 'Alabama', 'us'), + ('US-AK', 'Alaska', 'us'), + ('US-AZ', 'Arizona', 'us'), + ('US-AR', 'Arkansas', 'us'), ('US-CA', 'California', 'us'), ('US-CO', 'Colorado', 'us'), ('US-CT', 'Connecticut', 'us'), diff --git a/src/lib/components/AdventureCard.svelte b/src/lib/components/AdventureCard.svelte index 5ed4e82..c37c1c2 100644 --- a/src/lib/components/AdventureCard.svelte +++ b/src/lib/components/AdventureCard.svelte @@ -128,7 +128,7 @@

{name}

{regionId}

- + {#if !visited} { let currentDate = new Date(); let dateString = currentDate.toISOString().slice(0, 10); // Get date in "yyyy-mm-dd" format @@ -290,12 +301,7 @@
- +
diff --git a/src/lib/components/UserAvatar.svelte b/src/lib/components/UserAvatar.svelte index 133562b..ba5628a 100644 --- a/src/lib/components/UserAvatar.svelte +++ b/src/lib/components/UserAvatar.svelte @@ -37,8 +37,8 @@
  • Profile
  • -
    -
  • + +
  • diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 4838575..35f69e4 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -3,7 +3,7 @@ import { fail, redirect } from "@sveltejs/kit"; import type { Actions, PageServerLoad } from "./$types"; -export const load: PageServerLoad = async (event) => { +export const load: PageServerLoad = async (event: { locals: { user: any; }; }) => { if (event.locals.user) return { user: event.locals.user, @@ -15,7 +15,7 @@ export const load: PageServerLoad = async (event) => { // handle the logout action export const actions: Actions = { - default: async (event) => { + logout: async (event) => { if (!event.locals.session) { return fail(401); } @@ -28,4 +28,13 @@ export const actions: Actions = { }); return redirect(302, "/login"); }, + setTheme: async ( { url, cookies }) => { + const theme = url.searchParams.get("theme"); + if (theme) { + cookies.set("colortheme", theme, { + path: "/", + maxAge: 60 * 60 * 24 * 365, + }); + } + }, }; diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte index 1270f7b..d3d5eed 100644 --- a/src/routes/login/+page.svelte +++ b/src/routes/login/+page.svelte @@ -17,7 +17,7 @@ }); if (response.ok) { - // wait .5s before redirecting + errors = {}; goto("/login"); return; } diff --git a/tailwind.config.js b/tailwind.config.js index 2d48b1b..e17912a 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -6,6 +6,6 @@ export default { }, plugins: [require("@tailwindcss/typography"), require("daisyui")], daisyui: { - themes: ["night"], + themes: ["light", "dark"], }, }; From 5efb2912c0ce91680566d9713ff2d5ab0a8d6913 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Wed, 17 Apr 2024 00:15:27 +0000 Subject: [PATCH 12/13] Update theme handling and add theme selection dropdown in Navbar.svelte --- src/lib/components/AdventureCard.svelte | 8 ++++---- src/lib/components/Navbar.svelte | 3 +++ src/routes/+page.server.ts | 3 ++- src/routes/login/+page.svelte | 2 +- tailwind.config.js | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/lib/components/AdventureCard.svelte b/src/lib/components/AdventureCard.svelte index c37c1c2..357635d 100644 --- a/src/lib/components/AdventureCard.svelte +++ b/src/lib/components/AdventureCard.svelte @@ -40,7 +40,7 @@ {#if type === "mylog"}

    {name}

    @@ -72,7 +72,7 @@ {#if type === "featured"}

    {name}

    @@ -94,7 +94,7 @@ {#if type === "shared"}

    {name}

    @@ -122,7 +122,7 @@ {#if type === "worldtravelregion"}

    {name}

    diff --git a/src/lib/components/Navbar.svelte b/src/lib/components/Navbar.svelte index e1a9802..e5ed5de 100644 --- a/src/lib/components/Navbar.svelte +++ b/src/lib/components/Navbar.svelte @@ -107,6 +107,9 @@
  • +
  • + +
  • diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 35f69e4..d63d596 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -30,7 +30,8 @@ export const actions: Actions = { }, setTheme: async ( { url, cookies }) => { const theme = url.searchParams.get("theme"); - if (theme) { + // change the theme only if it is one of the allowed themes + if (theme && ["light", "dark", "night", "retro", "forest"].includes(theme)) { cookies.set("colortheme", theme, { path: "/", maxAge: 60 * 60 * 24 * 365, diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte index d3d5eed..7c723da 100644 --- a/src/routes/login/+page.svelte +++ b/src/routes/login/+page.svelte @@ -55,7 +55,7 @@
    {#if errors.message} -
    +
    {errors.message}
    {/if} diff --git a/tailwind.config.js b/tailwind.config.js index e17912a..90ec0e6 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -6,6 +6,6 @@ export default { }, plugins: [require("@tailwindcss/typography"), require("daisyui")], daisyui: { - themes: ["light", "dark"], + themes: ["light", "dark", "night", "retro", "forest"], }, }; From f0eb5441f01db6cc1990d19093f8613a13c7abde Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Wed, 17 Apr 2024 00:20:56 +0000 Subject: [PATCH 13/13] Add Nord theme option to theme selection dropdown in Navbar.svelte --- src/lib/components/Navbar.svelte | 11 ++++++++++- src/routes/+layout.svelte | 2 +- src/routes/+page.server.ts | 2 +- tailwind.config.js | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/lib/components/Navbar.svelte b/src/lib/components/Navbar.svelte index e5ed5de..386413f 100644 --- a/src/lib/components/Navbar.svelte +++ b/src/lib/components/Navbar.svelte @@ -8,6 +8,7 @@ import { onMount } from "svelte"; import InfoModal from "./InfoModal.svelte"; import infoIcon from "$lib/assets/info.svg"; + import type { SubmitFunction } from "@sveltejs/kit"; async function goHome() { goto("/"); } @@ -27,6 +28,13 @@ goto("/worldtravel"); } + const submitUpdateTheme: SubmitFunction = ({ action }) => { + const theme = action.searchParams.get("theme"); + if (theme) { + document.documentElement.setAttribute("data-theme", theme); + } + }; + let count = 0; let infoModalOpen = false; @@ -104,10 +112,11 @@ tabindex="0" class="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-52" > -
    +
  • +
  • diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index abcd0fc..22582f2 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -2,8 +2,8 @@ export let data; import Footer from "$lib/components/Footer.svelte"; import Navbar from "$lib/components/Navbar.svelte"; + import type { SubmitFunction } from "@sveltejs/kit"; import "../app.css"; - // only show footer if scrolled to the bottom diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index d63d596..e007790 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -31,7 +31,7 @@ export const actions: Actions = { setTheme: async ( { url, cookies }) => { const theme = url.searchParams.get("theme"); // change the theme only if it is one of the allowed themes - if (theme && ["light", "dark", "night", "retro", "forest"].includes(theme)) { + if (theme && ["light", "dark", "night", "retro", "forest", "nord"].includes(theme)) { cookies.set("colortheme", theme, { path: "/", maxAge: 60 * 60 * 24 * 365, diff --git a/tailwind.config.js b/tailwind.config.js index 90ec0e6..f63f6e2 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -6,6 +6,6 @@ export default { }, plugins: [require("@tailwindcss/typography"), require("daisyui")], daisyui: { - themes: ["light", "dark", "night", "retro", "forest"], + themes: ["light", "dark", "night", "retro", "forest", "nord"], }, };