mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-05 05:05:17 +02:00
commit
26d58d2850
21 changed files with 1100 additions and 646 deletions
|
@ -4,8 +4,6 @@ FROM node:18-alpine AS external-website
|
||||||
# A small line inside the image to show who made it
|
# A small line inside the image to show who made it
|
||||||
LABEL Developers="Sean Morley"
|
LABEL Developers="Sean Morley"
|
||||||
|
|
||||||
RUN apk update && apk add postgresql-client
|
|
||||||
|
|
||||||
# The WORKDIR instruction sets the working directory for everything that will happen next
|
# The WORKDIR instruction sets the working directory for everything that will happen next
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
119
migrations/0000_grey_iron_monger.sql
Normal file
119
migrations/0000_grey_iron_monger.sql
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
CREATE TABLE IF NOT EXISTS "adventures" (
|
||||||
|
"id" serial PRIMARY KEY NOT NULL,
|
||||||
|
"type" text NOT NULL,
|
||||||
|
"userId" text,
|
||||||
|
"name" text NOT NULL,
|
||||||
|
"location" text,
|
||||||
|
"activityTypes" json,
|
||||||
|
"description" text,
|
||||||
|
"rating" integer,
|
||||||
|
"link" text,
|
||||||
|
"imageUrl" text,
|
||||||
|
"date" text
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE IF NOT EXISTS "featuredAdventures" (
|
||||||
|
"id" serial PRIMARY KEY NOT NULL,
|
||||||
|
"name" text NOT NULL,
|
||||||
|
"location" text,
|
||||||
|
CONSTRAINT "featuredAdventures_name_unique" UNIQUE("name")
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE IF NOT EXISTS "session" (
|
||||||
|
"id" text PRIMARY KEY NOT NULL,
|
||||||
|
"user_id" text NOT NULL,
|
||||||
|
"expires_at" timestamp with time zone NOT NULL
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE IF NOT EXISTS "sharedAdventures" (
|
||||||
|
"id" text PRIMARY KEY NOT NULL,
|
||||||
|
"data" json NOT NULL,
|
||||||
|
"name" text NOT NULL,
|
||||||
|
"date" text NOT NULL
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE IF NOT EXISTS "userPlannedTrips" (
|
||||||
|
"id" serial PRIMARY KEY NOT NULL,
|
||||||
|
"userId" text NOT NULL,
|
||||||
|
"adventureName" text NOT NULL,
|
||||||
|
"description" text,
|
||||||
|
"startDate" text,
|
||||||
|
"endDate" text,
|
||||||
|
"adventures" json
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE IF NOT EXISTS "user" (
|
||||||
|
"id" text PRIMARY KEY NOT NULL,
|
||||||
|
"username" text NOT NULL,
|
||||||
|
"first_name" text NOT NULL,
|
||||||
|
"last_name" text NOT NULL,
|
||||||
|
"icon" text,
|
||||||
|
"hashed_password" varchar NOT NULL,
|
||||||
|
"signup_date" timestamp with time zone NOT NULL,
|
||||||
|
"last_login" timestamp with time zone,
|
||||||
|
"role" text NOT NULL
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE IF NOT EXISTS "userVisitedWorldTravel" (
|
||||||
|
"id" serial PRIMARY KEY NOT NULL,
|
||||||
|
"country_code" text NOT NULL,
|
||||||
|
"user_id" text NOT NULL,
|
||||||
|
"region_id" varchar NOT NULL
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE IF NOT EXISTS "worldTravelCountries" (
|
||||||
|
"id" serial PRIMARY KEY NOT NULL,
|
||||||
|
"name" text NOT NULL,
|
||||||
|
"country_code" text NOT NULL,
|
||||||
|
"continent" text NOT NULL,
|
||||||
|
CONSTRAINT "worldTravelCountries_country_code_unique" UNIQUE("country_code")
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE IF NOT EXISTS "worldTravelCountryRegions" (
|
||||||
|
"id" varchar PRIMARY KEY NOT NULL,
|
||||||
|
"name" text NOT NULL,
|
||||||
|
"country_code" text NOT NULL,
|
||||||
|
"info" json
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "adventures" ADD CONSTRAINT "adventures_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "userPlannedTrips" ADD CONSTRAINT "userPlannedTrips_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
|
--> 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 $$;
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "userVisitedWorldTravel" ADD CONSTRAINT "userVisitedWorldTravel_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "userVisitedWorldTravel" ADD CONSTRAINT "userVisitedWorldTravel_region_id_worldTravelCountryRegions_id_fk" FOREIGN KEY ("region_id") REFERENCES "worldTravelCountryRegions"("id") ON DELETE no action ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "worldTravelCountryRegions" ADD CONSTRAINT "worldTravelCountryRegions_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 $$;
|
511
migrations/meta/0000_snapshot.json
Normal file
511
migrations/meta/0000_snapshot.json
Normal file
|
@ -0,0 +1,511 @@
|
||||||
|
{
|
||||||
|
"id": "7cce94bb-5a17-42ff-850f-e0a41834b739",
|
||||||
|
"prevId": "00000000-0000-0000-0000-000000000000",
|
||||||
|
"version": "5",
|
||||||
|
"dialect": "pg",
|
||||||
|
"tables": {
|
||||||
|
"adventures": {
|
||||||
|
"name": "adventures",
|
||||||
|
"schema": "",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "id",
|
||||||
|
"type": "serial",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"name": "type",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"userId": {
|
||||||
|
"name": "userId",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"name": "name",
|
||||||
|
"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
|
||||||
|
},
|
||||||
|
"rating": {
|
||||||
|
"name": "rating",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"link": {
|
||||||
|
"name": "link",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"imageUrl": {
|
||||||
|
"name": "imageUrl",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"date": {
|
||||||
|
"name": "date",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {
|
||||||
|
"adventures_userId_user_id_fk": {
|
||||||
|
"name": "adventures_userId_user_id_fk",
|
||||||
|
"tableFrom": "adventures",
|
||||||
|
"tableTo": "user",
|
||||||
|
"columnsFrom": [
|
||||||
|
"userId"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "no action",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {}
|
||||||
|
},
|
||||||
|
"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": {}
|
||||||
|
},
|
||||||
|
"userPlannedTrips": {
|
||||||
|
"name": "userPlannedTrips",
|
||||||
|
"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
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"name": "description",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"startDate": {
|
||||||
|
"name": "startDate",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"endDate": {
|
||||||
|
"name": "endDate",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"adventures": {
|
||||||
|
"name": "adventures",
|
||||||
|
"type": "json",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {
|
||||||
|
"userPlannedTrips_userId_user_id_fk": {
|
||||||
|
"name": "userPlannedTrips_userId_user_id_fk",
|
||||||
|
"tableFrom": "userPlannedTrips",
|
||||||
|
"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": {}
|
||||||
|
},
|
||||||
|
"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": {}
|
||||||
|
}
|
||||||
|
}
|
13
migrations/meta/_journal.json
Normal file
13
migrations/meta/_journal.json
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"version": "5",
|
||||||
|
"dialect": "pg",
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"idx": 0,
|
||||||
|
"version": "5",
|
||||||
|
"when": 1715035790035,
|
||||||
|
"tag": "0000_grey_iron_monger",
|
||||||
|
"breakpoints": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
105
src/lib/components/CreateNewTripPlan.svelte
Normal file
105
src/lib/components/CreateNewTripPlan.svelte
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
<script lang="ts">
|
||||||
|
let newTrip: Trip;
|
||||||
|
|
||||||
|
newTrip = {
|
||||||
|
id: -1,
|
||||||
|
name: "",
|
||||||
|
description: "",
|
||||||
|
startDate: "",
|
||||||
|
endDate: "",
|
||||||
|
adventures: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
import { createEventDispatcher } from "svelte";
|
||||||
|
import type { Adventure, Trip } from "$lib/utils/types";
|
||||||
|
const dispatch = createEventDispatcher();
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
let modal: HTMLDialogElement;
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
modal = document.getElementById("my_modal_1") as HTMLDialogElement;
|
||||||
|
if (modal) {
|
||||||
|
modal.showModal();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function create() {
|
||||||
|
if (newTrip.name.trim() === "") {
|
||||||
|
alert("Name is required");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dispatch("create", newTrip);
|
||||||
|
console.log(newTrip);
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
dispatch("close");
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleKeydown(event: KeyboardEvent) {
|
||||||
|
if (event.key === "Escape") {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<dialog id="my_modal_1" class="modal">
|
||||||
|
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
||||||
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||||
|
<div class="modal-box" role="dialog" on:keydown={handleKeydown} tabindex="0">
|
||||||
|
<h3 class="font-bold text-lg">New Trip Plan</h3>
|
||||||
|
<p class="py-4">Press ESC key or click the button below to close</p>
|
||||||
|
<div
|
||||||
|
class="modal-action items-center"
|
||||||
|
style="display: flex; flex-direction: column; align-items: center; width: 100%;"
|
||||||
|
>
|
||||||
|
<form method="dialog" style="width: 100%;">
|
||||||
|
<div>
|
||||||
|
<label for="name">Name</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="name"
|
||||||
|
required
|
||||||
|
bind:value={newTrip.name}
|
||||||
|
class="input input-bordered w-full max-w-xs"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="location">Description</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="description"
|
||||||
|
bind:value={newTrip.description}
|
||||||
|
class="input input-bordered w-full max-w-xs"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="date">Start Date</label>
|
||||||
|
<input
|
||||||
|
type="date"
|
||||||
|
id="startDate"
|
||||||
|
bind:value={newTrip.startDate}
|
||||||
|
class="input input-bordered w-full max-w-xs"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="date">End Date</label>
|
||||||
|
<input
|
||||||
|
type="date"
|
||||||
|
id="endDate"
|
||||||
|
bind:value={newTrip.endDate}
|
||||||
|
class="input input-bordered w-full max-w-xs"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
class="btn btn-primary mr-4 mt-4"
|
||||||
|
on:click={create}>Create</button
|
||||||
|
>
|
||||||
|
<!-- if there is a button in form, it will close the modal -->
|
||||||
|
<button class="btn mt-4" on:click={close}>Close</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</dialog>
|
|
@ -1,169 +0,0 @@
|
||||||
<script lang="ts">
|
|
||||||
import { enhance } from "$app/forms";
|
|
||||||
import { visitCount } from "$lib/utils/stores/visitCountStore";
|
|
||||||
import { goto } from "$app/navigation";
|
|
||||||
import type { DatabaseUser } from "$lib/server/auth";
|
|
||||||
export let user: any;
|
|
||||||
import UserAvatar from "./UserAvatar.svelte";
|
|
||||||
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("/");
|
|
||||||
}
|
|
||||||
async function goToLog() {
|
|
||||||
goto("/log");
|
|
||||||
}
|
|
||||||
async function goToFeatured() {
|
|
||||||
goto("/featured");
|
|
||||||
}
|
|
||||||
async function toToLogin() {
|
|
||||||
goto("/login");
|
|
||||||
}
|
|
||||||
async function goToSignup() {
|
|
||||||
goto("/signup");
|
|
||||||
}
|
|
||||||
async function goToWorldTravel() {
|
|
||||||
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;
|
|
||||||
|
|
||||||
function showModal() {
|
|
||||||
infoModalOpen = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeModal() {
|
|
||||||
infoModalOpen = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get value from fetch /api/visitcount
|
|
||||||
|
|
||||||
$: if (user) {
|
|
||||||
onMount(async () => {
|
|
||||||
const res = await fetch("/api/visitcount");
|
|
||||||
const data = await res.json();
|
|
||||||
visitCount.set(data.visitCount);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
visitCount.subscribe((value) => {
|
|
||||||
count = value;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Set the visit count to the number of adventures stored in local storage
|
|
||||||
const isBrowser = typeof window !== "undefined";
|
|
||||||
if (isBrowser) {
|
|
||||||
const storedAdventures = localStorage.getItem("adventures");
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="navbar bg-base-100 flex flex-col md:flex-row">
|
|
||||||
<div class="navbar-start flex justify-around md:justify-start">
|
|
||||||
<button
|
|
||||||
class="btn btn-primary my-2 md:my-0 md:mr-4 md:ml-2"
|
|
||||||
on:click={goHome}>Home</button
|
|
||||||
>
|
|
||||||
{#if user}
|
|
||||||
<button class="btn btn-primary my-2 md:my-0 md:mr-4" on:click={goToLog}
|
|
||||||
>My Log</button
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
class="btn btn-primary my-2 md:my-0 md:mr-4"
|
|
||||||
on:click={() => goto("/planner")}>Planner</button
|
|
||||||
>
|
|
||||||
|
|
||||||
<!-- <button
|
|
||||||
class="btn btn-primary my-2 md:my-0 md:mr-4"
|
|
||||||
on:click={() => goto("/planner")}>Planner</button
|
|
||||||
> -->
|
|
||||||
{/if}
|
|
||||||
<button
|
|
||||||
class="btn btn-primary my-2 md:my-0 md:mr-4"
|
|
||||||
on:click={goToWorldTravel}>World Tavel Log</button
|
|
||||||
>
|
|
||||||
<button class="btn btn-primary my-2 md:my-0" on:click={goToFeatured}
|
|
||||||
>Featured</button
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div class="navbar-center flex justify-center md:justify-center">
|
|
||||||
<a class="btn btn-ghost text-xl" href="/">AdventureLog 🗺️</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{#if infoModalOpen}
|
|
||||||
<InfoModal on:close={closeModal} />
|
|
||||||
{/if}
|
|
||||||
<div class="navbar-end flex justify-around md:justify-end mr-4">
|
|
||||||
{#if !user}
|
|
||||||
<button class="btn btn-primary ml-4" on:click={toToLogin}>Login</button>
|
|
||||||
<button class="btn btn-primary ml-4" on:click={goToSignup}>Signup</button>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if user}
|
|
||||||
<p class="font-bold">Adventures: {count}</p>
|
|
||||||
<UserAvatar {user} />
|
|
||||||
{/if}
|
|
||||||
<button class="btn btn-neutral ml-4 btn-circle" on:click={showModal}
|
|
||||||
><iconify-icon icon="mdi:information" class="text-xl"
|
|
||||||
></iconify-icon></button
|
|
||||||
>
|
|
||||||
<div class="dropdown dropdown-bottom dropdown-end">
|
|
||||||
<div tabindex="0" role="button" class="btn m-1 ml-4">
|
|
||||||
<iconify-icon icon="mdi:theme-light-dark" class="text-xl"
|
|
||||||
></iconify-icon>
|
|
||||||
</div>
|
|
||||||
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
||||||
<ul
|
|
||||||
tabindex="0"
|
|
||||||
class="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-52"
|
|
||||||
>
|
|
||||||
<form method="POST" use:enhance={submitUpdateTheme}>
|
|
||||||
<li>
|
|
||||||
<button formaction="/?/setTheme&theme=light"
|
|
||||||
>Light<iconify-icon icon="mdi:weather-sunny" class="text-xl"
|
|
||||||
></iconify-icon></button
|
|
||||||
>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<button formaction="/?/setTheme&theme=dark"
|
|
||||||
>Dark<iconify-icon icon="mdi:weather-night" class="text-xl"
|
|
||||||
></iconify-icon></button
|
|
||||||
>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<button formaction="/?/setTheme&theme=night"
|
|
||||||
>Night<iconify-icon icon="mdi:weather-night" class="text-xl"
|
|
||||||
></iconify-icon></button
|
|
||||||
>
|
|
||||||
</li>
|
|
||||||
<!-- <li><button formaction="/?/setTheme&theme=nord">Nord</button></li> -->
|
|
||||||
<!-- <li><button formaction="/?/setTheme&theme=retro">Retro</button></li> -->
|
|
||||||
<li>
|
|
||||||
<button formaction="/?/setTheme&theme=forest"
|
|
||||||
>Forest<iconify-icon icon="mdi:forest" class="text-xl"
|
|
||||||
></iconify-icon></button
|
|
||||||
>
|
|
||||||
<button formaction="/?/setTheme&theme=garden"
|
|
||||||
>Garden<iconify-icon icon="mdi:flower" class="text-xl"
|
|
||||||
></iconify-icon></button
|
|
||||||
>
|
|
||||||
<button formaction="/?/setTheme&theme=aqua"
|
|
||||||
>Aqua<iconify-icon icon="mdi:water" class="text-xl"
|
|
||||||
></iconify-icon></button
|
|
||||||
>
|
|
||||||
</li>
|
|
||||||
</form>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
|
@ -1,6 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { enhance } from "$app/forms";
|
import { enhance } from "$app/forms";
|
||||||
import { visitCount } from "$lib/utils/stores/visitCountStore";
|
|
||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
import type { DatabaseUser } from "$lib/server/auth";
|
import type { DatabaseUser } from "$lib/server/auth";
|
||||||
export let user: any;
|
export let user: any;
|
||||||
|
@ -47,20 +46,6 @@
|
||||||
infoModalOpen = false;
|
infoModalOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get value from fetch /api/visitcount
|
|
||||||
|
|
||||||
$: if (user) {
|
|
||||||
onMount(async () => {
|
|
||||||
const res = await fetch("/api/visitcount");
|
|
||||||
const data = await res.json();
|
|
||||||
visitCount.set(data.visitCount);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
visitCount.subscribe((value) => {
|
|
||||||
count = value;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Set the visit count to the number of adventures stored in local storage
|
// Set the visit count to the number of adventures stored in local storage
|
||||||
const isBrowser = typeof window !== "undefined";
|
const isBrowser = typeof window !== "undefined";
|
||||||
if (isBrowser) {
|
if (isBrowser) {
|
||||||
|
|
|
@ -82,16 +82,16 @@ export const userVisitedWorldTravel = pgTable("userVisitedWorldTravel", {
|
||||||
.references(() => worldTravelCountryRegions.id),
|
.references(() => worldTravelCountryRegions.id),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const userPlannedAdventures = pgTable("userPlannedAdventures", {
|
export const userPlannedTrips = pgTable("userPlannedTrips", {
|
||||||
id: serial("id").primaryKey(),
|
id: serial("id").primaryKey(),
|
||||||
userId: text("userId")
|
userId: text("userId")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => userTable.id),
|
.references(() => userTable.id),
|
||||||
name: text("adventureName").notNull(),
|
name: text("adventureName").notNull(),
|
||||||
location: text("location"),
|
|
||||||
activityTypes: json("activityTypes"),
|
|
||||||
description: text("description"),
|
description: text("description"),
|
||||||
date: text("plannedDate"),
|
startDate: text("startDate"),
|
||||||
|
endDate: text("endDate"),
|
||||||
|
adventures: json("adventures"),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const adventureTable = pgTable("adventures", {
|
export const adventureTable = pgTable("adventures", {
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
import { writable } from "svelte/store";
|
|
||||||
|
|
||||||
let value = 0;
|
|
||||||
export const visitCount = writable(value);
|
|
||||||
|
|
|
@ -10,3 +10,12 @@ export interface Adventure {
|
||||||
imageUrl?: string | undefined;
|
imageUrl?: string | undefined;
|
||||||
date?: string | undefined;
|
date?: string | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Trip {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
startDate: string;
|
||||||
|
endDate: string;
|
||||||
|
adventures?: Adventure[] | [];
|
||||||
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
import campingDrawing from "$lib/assets/camping.svg";
|
import campingDrawing from "$lib/assets/camping.svg";
|
||||||
import { visitCount } from "$lib/utils/stores/visitCountStore";
|
|
||||||
import AdventureOverlook from "$lib/assets/AdventureOverlook.webp";
|
import AdventureOverlook from "$lib/assets/AdventureOverlook.webp";
|
||||||
import MapWithPins from "$lib/assets/MapWithPins.webp";
|
import MapWithPins from "$lib/assets/MapWithPins.webp";
|
||||||
|
|
||||||
|
@ -19,7 +18,9 @@
|
||||||
// https://v0.dev/t/PyTNahbwxVP
|
// https://v0.dev/t/PyTNahbwxVP
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<section class="w-full py-12 md:py-24 lg:py-32">
|
<section
|
||||||
|
class="flex items-center justify-center w-full py-12 md:py-24 lg:py-32"
|
||||||
|
>
|
||||||
<div class="container px-4 md:px-6">
|
<div class="container px-4 md:px-6">
|
||||||
<div
|
<div
|
||||||
class="grid gap-6 lg:grid-cols-[1fr_550px] lg:gap-12 xl:grid-cols-[1fr_650px]"
|
class="grid gap-6 lg:grid-cols-[1fr_550px] lg:gap-12 xl:grid-cols-[1fr_650px]"
|
||||||
|
@ -27,7 +28,7 @@
|
||||||
<div class="flex flex-col justify-center space-y-4">
|
<div class="flex flex-col justify-center space-y-4">
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
<h1
|
<h1
|
||||||
class="text-3xl font-bold tracking-tighter sm:text-5xl xl:text-6xl/none bg-gradient-to-r from-primary to-secondary bg-clip-text text-transparent"
|
class="text-3xl font-bold tracking-tighter sm:text-5xl xl:text-6xl/none bg-gradient-to-r from-primary to-secondary bg-clip-text text-transparent pb-4"
|
||||||
>
|
>
|
||||||
Discover the World's Most Thrilling Adventures
|
Discover the World's Most Thrilling Adventures
|
||||||
</h1>
|
</h1>
|
||||||
|
@ -56,7 +57,9 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section class="w-full py-12 md:py-24 lg:py-32 bg-gray-100 dark:bg-gray-800">
|
<section
|
||||||
|
class="flex items-center justify-center w-full py-12 md:py-24 lg:py-32 bg-gray-100 dark:bg-gray-800"
|
||||||
|
>
|
||||||
<div class="container px-4 md:px-6">
|
<div class="container px-4 md:px-6">
|
||||||
<div
|
<div
|
||||||
class="flex flex-col items-center justify-center space-y-4 text-center"
|
class="flex flex-col items-center justify-center space-y-4 text-center"
|
||||||
|
@ -132,172 +135,6 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- <section class="w-full py-12 md:py-24 lg:py-32 border-t">
|
|
||||||
<div
|
|
||||||
class="container grid items-center justify-center gap-4 px-4 text-center md:px-6"
|
|
||||||
>
|
|
||||||
<div class="space-y-3">
|
|
||||||
<h2 class="text-3xl font-bold tracking-tighter md:text-4xl/tight">
|
|
||||||
Explore the World's Most Breathtaking Destinations
|
|
||||||
</h2>
|
|
||||||
<p
|
|
||||||
class="mx-auto max-w-[600px] text-gray-500 md:text-xl/relaxed lg:text-base/relaxed xl:text-xl/relaxed dark:text-gray-400"
|
|
||||||
>
|
|
||||||
F
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
aria-roledescription="carousel"
|
|
||||||
class="relative w-full max-w-5xl"
|
|
||||||
role="region"
|
|
||||||
>
|
|
||||||
<div class="overflow-hidden">
|
|
||||||
<div class="flex -ml-4" style="transform: translate3d(0px, 0px, 0px);">
|
|
||||||
<div
|
|
||||||
aria-roledescription="slide"
|
|
||||||
class="min-w-0 shrink-0 grow-0 basis-full pl-4 md:basis-1/2 lg:basis-1/3"
|
|
||||||
role="group"
|
|
||||||
>
|
|
||||||
<div class="p-1">
|
|
||||||
<div
|
|
||||||
class="rounded-lg border bg-card text-card-foreground shadow-sm"
|
|
||||||
data-v0-t="card"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
src="/placeholder.svg"
|
|
||||||
width="400"
|
|
||||||
height="300"
|
|
||||||
alt="Destination"
|
|
||||||
class="aspect-[4/3] overflow-hidden rounded-t-xl object-cover"
|
|
||||||
/>
|
|
||||||
<div class="space-y-2 p-4">
|
|
||||||
<h3 class="text-xl font-bold">Machu Pic</h3>
|
|
||||||
<p class="text-gray-500 dark:text-gray-400"></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
aria-roledescription="slide"
|
|
||||||
class="min-w-0 shrink-0 grow-0 basis-full pl-4 md:basis-1/2 lg:basis-1/3"
|
|
||||||
role="group"
|
|
||||||
>
|
|
||||||
<div class="p-1">
|
|
||||||
<div
|
|
||||||
class="rounded-lg border bg-card text-card-foreground shadow-sm"
|
|
||||||
data-v0-t="card"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
src="/placeholder.svg"
|
|
||||||
width="400"
|
|
||||||
height="300"
|
|
||||||
alt="Destination"
|
|
||||||
class="aspect-[4/3] overflow-hidden rounded-t-xl object-cover"
|
|
||||||
/>
|
|
||||||
<div class="space-y-2 p-4">
|
|
||||||
<h3 class="text-xl font-bold">Patagonia, Argentina</h3>
|
|
||||||
<p class="text-gray-500 dark:text-gray-400"></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
aria-roledescription="slide"
|
|
||||||
class="min-w-0 shrink-0 grow-0 basis-full pl-4 md:basis-1/2 lg:basis-1/3"
|
|
||||||
role="group"
|
|
||||||
>
|
|
||||||
<div class="p-1">
|
|
||||||
<div
|
|
||||||
class="rounded-lg border bg-card text-card-foreground shadow-sm"
|
|
||||||
data-v0-t="card"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
src="/placeholder.svg"
|
|
||||||
width="400"
|
|
||||||
height="300"
|
|
||||||
alt="Destination"
|
|
||||||
class="aspect-[4/3] overflow-hidden rounded-t-xl object-cover"
|
|
||||||
/>
|
|
||||||
<div class="space-y-2 p-4">
|
|
||||||
<h3 class="text-xl font-bold">Bali, Indonesia</h3>
|
|
||||||
<p class="text-gray-500 dark:text-gray-400">
|
|
||||||
Discover lush jungles, stunning beaches, and ancient
|
|
||||||
temples.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
aria-roledescription="slide"
|
|
||||||
class="min-w-0 shrink-0 grow-0 basis-full pl-4 md:basis-1/2 lg:basis-1/3"
|
|
||||||
role="group"
|
|
||||||
>
|
|
||||||
<div class="p-1">
|
|
||||||
<div
|
|
||||||
class="rounded-lg border bg-card text-card-foreground shadow-sm"
|
|
||||||
data-v0-t="card"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
src="/placeholder.svg"
|
|
||||||
width="400"
|
|
||||||
height="300"
|
|
||||||
alt="Destination"
|
|
||||||
class="aspect-[4/3] overflow-hidden rounded-t-xl object-cover"
|
|
||||||
/>
|
|
||||||
<div class="space-y-2 p-4">
|
|
||||||
<h3 class="text-xl font-bold">Banff, Canada</h3>
|
|
||||||
<p class="text-gray-500 dark:text-gray-400"></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
class="inline-flex items-center justify-center whitespace-nowrap text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground absolute h-8 w-8 rounded-full -left-12 top-1/2 -translate-y-1/2"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="24"
|
|
||||||
height="24"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
stroke-width="2"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
class="h-4 w-4"
|
|
||||||
>
|
|
||||||
<path d="m12 19-7-7 7-7"></path>
|
|
||||||
<path d="M19 12H5"></path>
|
|
||||||
</svg>
|
|
||||||
<span class="sr-only">Previous slide</span>
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="inline-flex items-center justify-center whitespace-nowrap text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground absolute h-8 w-8 rounded-full -right-12 top-1/2 -translate-y-1/2"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="24"
|
|
||||||
height="24"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
stroke-width="2"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
class="h-4 w-4"
|
|
||||||
>
|
|
||||||
<path d="M5 12h14"></path>
|
|
||||||
<path d="m12 5 7 7-7 7"></path>
|
|
||||||
</svg>
|
|
||||||
<span class="sr-only">Next slide</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section> -->
|
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>Home | AdventureLog</title>
|
<title>Home | AdventureLog</title>
|
||||||
<meta
|
<meta
|
||||||
|
|
94
src/routes/api/trips/+server.ts
Normal file
94
src/routes/api/trips/+server.ts
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
import { db } from "$lib/db/db.server";
|
||||||
|
import { userPlannedTrips } from "$lib/db/schema";
|
||||||
|
import { error, type RequestEvent } from "@sveltejs/kit";
|
||||||
|
import { eq } from "drizzle-orm";
|
||||||
|
|
||||||
|
export async function POST(event: RequestEvent): Promise<Response> {
|
||||||
|
if (!event.locals.user) {
|
||||||
|
return new Response(JSON.stringify({ error: "No user found" }), {
|
||||||
|
status: 401,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const body = await event.request.json();
|
||||||
|
if (!body.newTrip) {
|
||||||
|
return error(400, {
|
||||||
|
message: "No adventure data provided",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const { name, description, startDate, endDate } = body.newTrip;
|
||||||
|
|
||||||
|
if (!name) {
|
||||||
|
return error(400, {
|
||||||
|
message: "Name field is required!",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert the adventure to the user's visited list
|
||||||
|
let res = await db
|
||||||
|
.insert(userPlannedTrips)
|
||||||
|
.values({
|
||||||
|
userId: event.locals.user.id,
|
||||||
|
name: name,
|
||||||
|
description: description || null,
|
||||||
|
startDate: startDate || null,
|
||||||
|
endDate: endDate || null,
|
||||||
|
adventures: JSON.stringify([]),
|
||||||
|
})
|
||||||
|
.returning({ insertedId: userPlannedTrips.id })
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
let insertedId = res[0].insertedId;
|
||||||
|
console.log(insertedId);
|
||||||
|
|
||||||
|
body.newTrip.id = insertedId;
|
||||||
|
|
||||||
|
return new Response(
|
||||||
|
JSON.stringify({
|
||||||
|
trip: body.newTrip,
|
||||||
|
message: { message: "Trip added" },
|
||||||
|
id: insertedId,
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
status: 200,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function GET(event: RequestEvent): Promise<Response> {
|
||||||
|
if (!event.locals.user) {
|
||||||
|
return new Response(JSON.stringify({ error: "No user found" }), {
|
||||||
|
status: 401,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let trips = await db
|
||||||
|
.select()
|
||||||
|
.from(userPlannedTrips)
|
||||||
|
.where(eq(userPlannedTrips.userId, event.locals.user.id))
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
// json parse the adventures into an Adventure array
|
||||||
|
for (let trip of trips) {
|
||||||
|
if (trip.adventures) {
|
||||||
|
trip.adventures = JSON.parse(trip.adventures as unknown as string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Response(JSON.stringify(trips), {
|
||||||
|
status: 200,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,39 +0,0 @@
|
||||||
import { lucia } from "$lib/server/auth";
|
|
||||||
import type { RequestEvent } from "@sveltejs/kit";
|
|
||||||
|
|
||||||
export async function GET(event: RequestEvent): Promise<Response> {
|
|
||||||
if (!event.locals.user) {
|
|
||||||
return new Response(JSON.stringify({ error: "No user found" }), {
|
|
||||||
status: 401,
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return new Response(
|
|
||||||
JSON.stringify({
|
|
||||||
message: "Welcome user info page!",
|
|
||||||
userId: event.locals.user.id,
|
|
||||||
username: event.locals.user.username,
|
|
||||||
firstName: event.locals.user.first_name,
|
|
||||||
lastName: event.locals.user.last_name,
|
|
||||||
}),
|
|
||||||
{
|
|
||||||
status: 200,
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
return new Response(JSON.stringify({ error: "Internal server error" }), {
|
|
||||||
status: 500,
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
import type { RequestEvent } from "@sveltejs/kit";
|
|
||||||
import { count } from "drizzle-orm";
|
|
||||||
import { eq } from "drizzle-orm";
|
|
||||||
import { adventureTable } from "$lib/db/schema";
|
|
||||||
import { db } from "$lib/db/db.server";
|
|
||||||
|
|
||||||
export async function GET(event: RequestEvent): Promise<Response> {
|
|
||||||
if (!event.locals.user) {
|
|
||||||
return new Response(JSON.stringify({ error: "No user found" }), {
|
|
||||||
status: 401,
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// get the count of the number of adventures the user has visited
|
|
||||||
let result = await db
|
|
||||||
.select({ count: count() })
|
|
||||||
.from(adventureTable)
|
|
||||||
.where(eq(adventureTable.userId, event.locals.user.id))
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
return new Response(
|
|
||||||
JSON.stringify({
|
|
||||||
visitCount: result[0].count,
|
|
||||||
}),
|
|
||||||
{
|
|
||||||
status: 200,
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -2,14 +2,8 @@
|
||||||
export let data;
|
export let data;
|
||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
import AdventureCard from "$lib/components/AdventureCard.svelte";
|
import AdventureCard from "$lib/components/AdventureCard.svelte";
|
||||||
import { visitCount } from "$lib/utils/stores/visitCountStore.js";
|
|
||||||
import type { Adventure } from "$lib/utils/types.js";
|
import type { Adventure } from "$lib/utils/types.js";
|
||||||
|
|
||||||
let count = 0;
|
|
||||||
visitCount.subscribe((value) => {
|
|
||||||
count = value;
|
|
||||||
});
|
|
||||||
|
|
||||||
async function add(event: CustomEvent<Adventure>) {
|
async function add(event: CustomEvent<Adventure>) {
|
||||||
let detailAdventure = event.detail;
|
let detailAdventure = event.detail;
|
||||||
|
|
||||||
|
@ -25,8 +19,6 @@
|
||||||
|
|
||||||
if (response.status === 401) {
|
if (response.status === 401) {
|
||||||
goto("/login");
|
goto("/login");
|
||||||
} else {
|
|
||||||
visitCount.update((n) => n + 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
import mapDrawing from "$lib/assets/adventure_map.svg";
|
import mapDrawing from "$lib/assets/adventure_map.svg";
|
||||||
import EditModal from "$lib/components/EditModal.svelte";
|
import EditModal from "$lib/components/EditModal.svelte";
|
||||||
import { generateRandomString } from "$lib";
|
import { generateRandomString } from "$lib";
|
||||||
import { visitCount } from "$lib/utils/stores/visitCountStore";
|
|
||||||
import MoreFieldsInput from "$lib/components/CreateNewAdventure.svelte";
|
import MoreFieldsInput from "$lib/components/CreateNewAdventure.svelte";
|
||||||
import {
|
import {
|
||||||
addAdventure,
|
addAdventure,
|
||||||
|
@ -36,11 +35,6 @@
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
let count = 0;
|
|
||||||
visitCount.subscribe((value) => {
|
|
||||||
count = value;
|
|
||||||
});
|
|
||||||
|
|
||||||
function showToast(action: string) {
|
function showToast(action: string) {
|
||||||
toastAction = action;
|
toastAction = action;
|
||||||
isShowingToast = true;
|
isShowingToast = true;
|
||||||
|
@ -141,7 +135,6 @@
|
||||||
// remove adventure from array where id matches
|
// remove adventure from array where id matches
|
||||||
adventures = [];
|
adventures = [];
|
||||||
showToast("Adventure removed successfully!");
|
showToast("Adventure removed successfully!");
|
||||||
visitCount.set(0);
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("Error:", error);
|
console.error("Error:", error);
|
||||||
|
@ -165,20 +158,30 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex justify-center items-center w-full mt-4 mb-4">
|
<div class="fixed bottom-4 right-4">
|
||||||
<article class="prose">
|
<div class="flex flex-row items-center justify-center gap-4">
|
||||||
<h2 class="text-center">Add new Location</h2>
|
<div class="dropdown dropdown-top dropdown-end">
|
||||||
</article>
|
<div tabindex="0" role="button" class="btn m-1 size-16 btn-primary">
|
||||||
</div>
|
<iconify-icon icon="mdi:plus" class="text-2xl"></iconify-icon>
|
||||||
|
</div>
|
||||||
<div class="flex flex-row items-center justify-center gap-4">
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||||
<button
|
<ul
|
||||||
type="button"
|
tabindex="0"
|
||||||
class="btn btn-secondary"
|
class="dropdown-content z-[1] menu p-4 shadow bg-base-300 text-base-content rounded-box w-52 gap-4"
|
||||||
on:click={() => (isShowingMoreFields = !isShowingMoreFields)}
|
>
|
||||||
>
|
<p class="text-center font-bold text-lg">Create new...</p>
|
||||||
<iconify-icon icon="mdi:plus" class="text-2xl"></iconify-icon>
|
<button
|
||||||
</button>
|
class="btn btn-primary"
|
||||||
|
on:click={() => (isShowingMoreFields = true)}
|
||||||
|
>Visited Adventure</button
|
||||||
|
>
|
||||||
|
<!-- <button
|
||||||
|
class="btn btn-primary"
|
||||||
|
on:click={() => (isShowingNewTrip = true)}>Trip Planner</button
|
||||||
|
> -->
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{#if adventures.length != 0}
|
{#if adventures.length != 0}
|
||||||
<div class="flex justify-center items-center w-full mt-4 mb-4">
|
<div class="flex justify-center items-center w-full mt-4 mb-4">
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
<!-- routes/login/+page.svelte -->
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { enhance } from "$app/forms";
|
import { enhance } from "$app/forms";
|
||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
|
@ -7,9 +6,12 @@
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
let quote: string = "";
|
let quote: string = "";
|
||||||
let errors: { message?: string } = {};
|
let errors: { message?: string } = {};
|
||||||
|
let backgroundImageUrl = "https://source.unsplash.com/random/?mountains";
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
quote = getRandomQuote();
|
quote = getRandomQuote();
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleSubmit: SubmitFunction = async ({ formData, action, cancel }) => {
|
const handleSubmit: SubmitFunction = async ({ formData, action, cancel }) => {
|
||||||
const response = await fetch(action, {
|
const response = await fetch(action, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -31,42 +33,49 @@
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<article class="text-center text-4xl font-extrabold">
|
<div
|
||||||
<h1>Sign in</h1>
|
class="min-h-screen bg-no-repeat bg-cover flex items-center justify-center"
|
||||||
</article>
|
style="background-image: url('{backgroundImageUrl}')"
|
||||||
|
>
|
||||||
|
<div class="card card-compact w-96 bg-base-100 shadow-xl p-6">
|
||||||
|
<article class="text-center text-4xl font-extrabold">
|
||||||
|
<h1>Sign in</h1>
|
||||||
|
</article>
|
||||||
|
|
||||||
<div class="flex justify-center">
|
<div class="flex justify-center">
|
||||||
<form method="post" use:enhance={handleSubmit} class="w-full max-w-xs">
|
<form method="post" use:enhance={handleSubmit} class="w-full max-w-xs">
|
||||||
<label for="username">Username</label>
|
<label for="username">Username</label>
|
||||||
<input
|
<input
|
||||||
name="username"
|
name="username"
|
||||||
id="username"
|
id="username"
|
||||||
class="block mb-2 input input-bordered w-full max-w-xs"
|
class="block mb-2 input input-bordered w-full max-w-xs"
|
||||||
/><br />
|
/><br />
|
||||||
<label for="password">Password</label>
|
<label for="password">Password</label>
|
||||||
<input
|
<input
|
||||||
type="password"
|
type="password"
|
||||||
name="password"
|
name="password"
|
||||||
id="password"
|
id="password"
|
||||||
class="block mb-2 input input-bordered w-full max-w-xs"
|
class="block mb-2 input input-bordered w-full max-w-xs"
|
||||||
/><br />
|
/><br />
|
||||||
<button class="py-2 px-4 btn btn-primary">Login</button>
|
<button class="py-2 px-4 btn btn-primary">Login</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if errors.message}
|
{#if errors.message}
|
||||||
<div class="text-center text-error mt-4">
|
<div class="text-center text-error mt-4">
|
||||||
{errors.message}
|
{errors.message}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
|
||||||
|
|
||||||
<div class="flex justify-center mt-12 mr-25 ml-25">
|
|
||||||
<blockquote class="w-80 text-center text-lg break-words">
|
|
||||||
{#if quote != ""}
|
|
||||||
{quote}
|
|
||||||
{/if}
|
{/if}
|
||||||
<!-- <footer class="text-sm">- Steve Jobs</footer> -->
|
|
||||||
</blockquote>
|
<div class="flex justify-center mt-12 mr-25 ml-25">
|
||||||
|
<blockquote class="w-80 text-center text-lg break-words">
|
||||||
|
{#if quote != ""}
|
||||||
|
{quote}
|
||||||
|
{/if}
|
||||||
|
<!-- <footer class="text-sm">- Steve Jobs</footer> -->
|
||||||
|
</blockquote>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { Adventure } from "$lib/utils/types.js";
|
import type { Adventure, Trip } from "$lib/utils/types";
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import AdventureCard from "$lib/components/AdventureCard.svelte";
|
import AdventureCard from "$lib/components/AdventureCard.svelte";
|
||||||
import EditModal from "$lib/components/EditModal.svelte";
|
import EditModal from "$lib/components/EditModal.svelte";
|
||||||
|
@ -9,20 +9,28 @@
|
||||||
removeAdventure,
|
removeAdventure,
|
||||||
addAdventure,
|
addAdventure,
|
||||||
changeType,
|
changeType,
|
||||||
} from "../../services/adventureService.js";
|
} from "../../services/adventureService";
|
||||||
import SucessToast from "$lib/components/SucessToast.svelte";
|
import SucessToast from "$lib/components/SucessToast.svelte";
|
||||||
import mapDrawing from "$lib/assets/adventure_map.svg";
|
import mapDrawing from "$lib/assets/adventure_map.svg";
|
||||||
|
import CreateNewTripPlan from "$lib/components/CreateNewTripPlan.svelte";
|
||||||
export let data;
|
export let data;
|
||||||
let plans: Adventure[] = [];
|
|
||||||
let isLoading = true;
|
let adventuresPlans: Adventure[] = [];
|
||||||
|
let tripPlans: Trip[] = [];
|
||||||
|
|
||||||
|
let isLoadingIdeas: boolean = true;
|
||||||
|
let isLoadingTrips: boolean = true;
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
plans = data.result;
|
getAllTrips();
|
||||||
isLoading = false;
|
console.log(tripPlans);
|
||||||
|
adventuresPlans = data.result;
|
||||||
|
isLoadingIdeas = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
let isShowingMoreFields: boolean = false;
|
let isShowingMoreFields: boolean = false;
|
||||||
|
let isShowingNewTrip: boolean = false;
|
||||||
|
|
||||||
let isShowingToast: boolean = false;
|
let isShowingToast: boolean = false;
|
||||||
let toastAction: string = "";
|
let toastAction: string = "";
|
||||||
|
@ -42,7 +50,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function editPlan(event: { detail: number }) {
|
function editPlan(event: { detail: number }) {
|
||||||
const adventure = plans.find((adventure) => adventure.id === event.detail);
|
const adventure = adventuresPlans.find(
|
||||||
|
(adventure) => adventure.id === event.detail
|
||||||
|
);
|
||||||
if (adventure) {
|
if (adventure) {
|
||||||
adventureToEdit = adventure;
|
adventureToEdit = adventure;
|
||||||
}
|
}
|
||||||
|
@ -54,9 +64,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
async function savePlan(event: { detail: Adventure }) {
|
async function savePlan(event: { detail: Adventure }) {
|
||||||
let newArray = await saveAdventure(event.detail, plans);
|
let newArray = await saveAdventure(event.detail, adventuresPlans);
|
||||||
if (newArray.length > 0) {
|
if (newArray.length > 0) {
|
||||||
plans = newArray;
|
adventuresPlans = newArray;
|
||||||
showToast("Adventure updated successfully!");
|
showToast("Adventure updated successfully!");
|
||||||
} else {
|
} else {
|
||||||
showToast("Failed to update adventure");
|
showToast("Failed to update adventure");
|
||||||
|
@ -65,12 +75,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
async function remove(event: { detail: number }) {
|
async function remove(event: { detail: number }) {
|
||||||
let initialLength: number = plans.length;
|
let initialLength: number = adventuresPlans.length;
|
||||||
let theAdventure = plans.find((adventure) => adventure.id === event.detail);
|
let theAdventure = adventuresPlans.find(
|
||||||
|
(adventure) => adventure.id === event.detail
|
||||||
|
);
|
||||||
if (theAdventure) {
|
if (theAdventure) {
|
||||||
let newArray = await removeAdventure(theAdventure, plans);
|
let newArray = await removeAdventure(theAdventure, adventuresPlans);
|
||||||
if (newArray.length === initialLength - 1) {
|
if (newArray.length === initialLength - 1) {
|
||||||
plans = newArray;
|
adventuresPlans = newArray;
|
||||||
showToast("Adventure removed successfully!");
|
showToast("Adventure removed successfully!");
|
||||||
} else {
|
} else {
|
||||||
showToast("Failed to remove adventure");
|
showToast("Failed to remove adventure");
|
||||||
|
@ -80,9 +92,9 @@
|
||||||
|
|
||||||
const createNewAdventure = async (event: { detail: Adventure }) => {
|
const createNewAdventure = async (event: { detail: Adventure }) => {
|
||||||
isShowingMoreFields = false;
|
isShowingMoreFields = false;
|
||||||
let newArray = await addAdventure(event.detail, plans);
|
let newArray = await addAdventure(event.detail, adventuresPlans);
|
||||||
if (newArray.length > 0) {
|
if (newArray.length > 0) {
|
||||||
plans = newArray;
|
adventuresPlans = newArray;
|
||||||
showToast("Adventure added successfully!");
|
showToast("Adventure added successfully!");
|
||||||
} else {
|
} else {
|
||||||
showToast("Failed to add adventure");
|
showToast("Failed to add adventure");
|
||||||
|
@ -90,46 +102,98 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
async function markVisited(event: { detail: Adventure }) {
|
async function markVisited(event: { detail: Adventure }) {
|
||||||
let initialLength: number = plans.length;
|
let initialLength: number = adventuresPlans.length;
|
||||||
let newArray = await changeType(event.detail, "mylog", plans);
|
let newArray = await changeType(event.detail, "mylog", adventuresPlans);
|
||||||
if (newArray.length + 1 == initialLength) {
|
if (newArray.length + 1 == initialLength) {
|
||||||
plans = newArray;
|
adventuresPlans = newArray;
|
||||||
showToast("Adventure moved to visit log!");
|
showToast("Adventure moved to visit log!");
|
||||||
} else {
|
} else {
|
||||||
showToast("Failed to moves adventure");
|
showToast("Failed to moves adventure");
|
||||||
}
|
}
|
||||||
adventureToEdit = undefined;
|
adventureToEdit = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function createNewTrip(event: { detail: Trip }) {
|
||||||
|
isShowingNewTrip = false;
|
||||||
|
let newTrip: Trip = event.detail;
|
||||||
|
// post the trip object to /api/trips
|
||||||
|
// if successful, add the trip to the tripPlans array
|
||||||
|
const response = await fetch("/api/trips", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ newTrip }),
|
||||||
|
})
|
||||||
|
.then((response) => response.json())
|
||||||
|
.then((data) => {
|
||||||
|
console.log("Success:", data);
|
||||||
|
newTrip = data.trip;
|
||||||
|
console.log(newTrip);
|
||||||
|
tripPlans = [...tripPlans, newTrip];
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Error:", error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getAllTrips() {
|
||||||
|
const response = await fetch("/api/trips", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((response) => response.json())
|
||||||
|
.then((data) => {
|
||||||
|
console.log("Success:", data);
|
||||||
|
tripPlans = data;
|
||||||
|
isLoadingTrips = false;
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
showToast("Failed to get trips");
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if isShowingToast}
|
{#if isShowingToast}
|
||||||
<SucessToast action={toastAction} />
|
<SucessToast action={toastAction} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="flex justify-center items-center w-full mt-4 mb-4">
|
<div class="fixed bottom-4 right-4">
|
||||||
<article class="prose">
|
<div class="flex flex-row items-center justify-center gap-4">
|
||||||
<h2 class="text-center">Add new Plan</h2>
|
<div class="dropdown dropdown-top dropdown-end">
|
||||||
</article>
|
<div tabindex="0" role="button" class="btn m-1 size-16 btn-primary">
|
||||||
|
<iconify-icon icon="mdi:plus" class="text-2xl"></iconify-icon>
|
||||||
|
</div>
|
||||||
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||||
|
<ul
|
||||||
|
tabindex="0"
|
||||||
|
class="dropdown-content z-[1] menu p-4 shadow bg-base-300 text-base-content rounded-box w-52 gap-4"
|
||||||
|
>
|
||||||
|
<p class="text-center font-bold text-lg">Create new...</p>
|
||||||
|
<button
|
||||||
|
class="btn btn-primary"
|
||||||
|
on:click={() => (isShowingMoreFields = true)}>Adventure Idea</button
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
class="btn btn-primary"
|
||||||
|
on:click={() => (isShowingNewTrip = true)}>Trip Planner</button
|
||||||
|
>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-row items-center justify-center gap-4">
|
{#if adventuresPlans.length != 0}
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="btn btn-secondary"
|
|
||||||
on:click={() => (isShowingMoreFields = !isShowingMoreFields)}
|
|
||||||
>
|
|
||||||
<iconify-icon icon="mdi:plus" class="text-2xl"></iconify-icon>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{#if plans.length != 0}
|
|
||||||
<div class="flex justify-center items-center w-full mt-4 mb-4">
|
<div class="flex justify-center items-center w-full mt-4 mb-4">
|
||||||
<article class="prose">
|
<article class="prose">
|
||||||
<h1 class="text-center">My Adventure Plans</h1>
|
<h1 class="text-center">My Adventure Ideas</h1>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if isLoading}
|
{#if isLoadingIdeas && isLoadingTrips}
|
||||||
<div class="flex justify-center items-center w-full mt-16">
|
<div class="flex justify-center items-center w-full mt-16">
|
||||||
<span class="loading loading-spinner w-24 h-24"></span>
|
<span class="loading loading-spinner w-24 h-24"></span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -138,7 +202,7 @@
|
||||||
<div
|
<div
|
||||||
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"
|
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 plans as adventure (adventure.id)}
|
{#each adventuresPlans as adventure (adventure.id)}
|
||||||
<AdventureCard
|
<AdventureCard
|
||||||
{adventure}
|
{adventure}
|
||||||
type="planner"
|
type="planner"
|
||||||
|
@ -149,7 +213,7 @@
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if plans.length == 0 && !isLoading}
|
{#if adventuresPlans.length == 0 && !isLoadingIdeas && !isLoadingTrips && !isShowingMoreFields && !isShowingNewTrip && tripPlans.length == 0}
|
||||||
<div class="flex flex-col items-center justify-center mt-16">
|
<div class="flex flex-col items-center justify-center mt-16">
|
||||||
<article class="prose mb-4"><h2>Add some plans!</h2></article>
|
<article class="prose mb-4"><h2>Add some plans!</h2></article>
|
||||||
<img src={mapDrawing} width="25%" alt="Logo" />
|
<img src={mapDrawing} width="25%" alt="Logo" />
|
||||||
|
@ -168,46 +232,34 @@
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<!-- ----------------------- -->
|
{#if isShowingNewTrip}
|
||||||
|
<CreateNewTripPlan
|
||||||
<!-- {#if plans.length == 0 && !isLoading}
|
on:close={() => (isShowingNewTrip = false)}
|
||||||
<div class="flex flex-col items-center justify-center mt-16">
|
on:create={createNewTrip}
|
||||||
<article class="prose mb-4"><h2>Add some adventures!</h2></article>
|
/>
|
||||||
<img src={mapDrawing} width="25%" alt="Logo" />
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if plans.length != 0 && !isLoading}
|
{#if tripPlans.length !== 0}
|
||||||
<div class="flex justify-center items-center w-full mt-4">
|
<div class="flex justify-center items-center w-full mt-4 mb-4">
|
||||||
<article class="prose">
|
<article class="prose">
|
||||||
<h2 class="text-center">Actions</h2>
|
<h1 class="text-center">My Trip Plans</h1>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
<div
|
|
||||||
class="flex flex-row items-center justify-center mt-2 gap-4 mb-4 flex-wrap"
|
|
||||||
>
|
|
||||||
<button class="btn btn-neutral" on:click={exportData}>
|
|
||||||
<img src={exportFile} class="inline-block -mt-1" alt="Logo" /> Save as File
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-neutral" on:click={() => (confirmModalOpen = true)}>
|
|
||||||
<img src={deleteIcon} class="inline-block -mt-1" alt="Logo" /> Delete Data
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-neutral" on:click={shareLink}>
|
|
||||||
<iconify-icon icon="mdi:share-variant" class="text-xl"></iconify-icon> Share
|
|
||||||
as Link
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if confirmModalOpen}
|
{#each tripPlans as trip (trip.id)}
|
||||||
<ConfirmModal
|
<div class="flex justify-center items-center w-full mt-4 mb-4">
|
||||||
on:close={handleClose}
|
<article class="prose">
|
||||||
on:confirm={deleteData}
|
<h2>{trip.name}</h2>
|
||||||
title="Delete all Adventures"
|
<p>{trip.description}</p>
|
||||||
isWarning={false}
|
<p>
|
||||||
message="Are you sure you want to delete all adventures?"
|
<strong>Start Date:</strong>
|
||||||
/>
|
{trip.startDate} <strong>End Date:</strong>
|
||||||
{/if} -->
|
{trip.endDate}
|
||||||
|
</p>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>My Plans | AdventureLog</title>
|
<title>My Plans | AdventureLog</title>
|
||||||
|
|
|
@ -3,54 +3,64 @@
|
||||||
import { enhance } from "$app/forms";
|
import { enhance } from "$app/forms";
|
||||||
import { getRandomQuote } from "$lib";
|
import { getRandomQuote } from "$lib";
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
|
|
||||||
|
let backgroundImageUrl = "https://source.unsplash.com/random/?mountains";
|
||||||
|
|
||||||
let quote: string = "";
|
let quote: string = "";
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
quote = getRandomQuote();
|
quote = getRandomQuote();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<article class="text-center text-4xl font-extrabold">
|
<div
|
||||||
<h1>Signup</h1>
|
class="min-h-screen bg-no-repeat bg-cover flex items-center justify-center"
|
||||||
</article>
|
style="background-image: url('{backgroundImageUrl}')"
|
||||||
|
>
|
||||||
|
<div class="card card-compact w-96 bg-base-100 shadow-xl p-6">
|
||||||
|
<article class="text-center text-4xl font-extrabold">
|
||||||
|
<h1>Signup</h1>
|
||||||
|
</article>
|
||||||
|
|
||||||
<div class="flex justify-center">
|
<div class="flex justify-center">
|
||||||
<form method="post" use:enhance class="w-full max-w-xs">
|
<form method="post" use:enhance class="w-full max-w-xs">
|
||||||
<label for="username">Username</label>
|
<label for="username">Username</label>
|
||||||
<input
|
<input
|
||||||
name="username"
|
name="username"
|
||||||
id="username"
|
id="username"
|
||||||
class="block mb-2 input input-bordered w-full max-w-xs"
|
class="block mb-2 input input-bordered w-full max-w-xs"
|
||||||
/><br />
|
/><br />
|
||||||
<label for="first_name">First Name</label>
|
<label for="first_name">First Name</label>
|
||||||
<input
|
<input
|
||||||
name="first_name"
|
name="first_name"
|
||||||
id="first_name"
|
id="first_name"
|
||||||
class="block mb-2 input input-bordered w-full max-w-xs"
|
class="block mb-2 input input-bordered w-full max-w-xs"
|
||||||
/><br />
|
/><br />
|
||||||
<label for="last_name">Last Name</label>
|
<label for="last_name">Last Name</label>
|
||||||
<input
|
<input
|
||||||
name="last_name"
|
name="last_name"
|
||||||
id="last_name"
|
id="last_name"
|
||||||
class="block mb-2 input input-bordered w-full max-w-xs"
|
class="block mb-2 input input-bordered w-full max-w-xs"
|
||||||
/><br />
|
/><br />
|
||||||
<label for="password">Password</label>
|
<label for="password">Password</label>
|
||||||
<input
|
<input
|
||||||
type="password"
|
type="password"
|
||||||
name="password"
|
name="password"
|
||||||
id="password"
|
id="password"
|
||||||
class="block mb-2 input input-bordered w-full max-w-xs"
|
class="block mb-2 input input-bordered w-full max-w-xs"
|
||||||
/><br />
|
/><br />
|
||||||
<button class="py-2 px-4 btn btn-primary">Signup</button>
|
<button class="py-2 px-4 btn btn-primary">Signup</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex justify-center mt-12 mr-25 ml-25">
|
<div class="flex justify-center mt-12 mr-25 ml-25">
|
||||||
<blockquote class="w-80 text-center text-lg break-words">
|
<blockquote class="w-80 text-center text-lg break-words">
|
||||||
{#if quote != ""}
|
{#if quote != ""}
|
||||||
{quote}
|
{quote}
|
||||||
{/if}
|
{/if}
|
||||||
<!-- <footer class="text-sm">- Steve Jobs</footer> -->
|
<!-- <footer class="text-sm">- Steve Jobs</footer> -->
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- username first last pass -->
|
<!-- username first last pass -->
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { visitCount } from "$lib/utils/stores/visitCountStore";
|
|
||||||
import type { Adventure } from "$lib/utils/types";
|
import type { Adventure } from "$lib/utils/types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,9 +111,6 @@ export async function addAdventure(
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
adventureArray.push(data.adventure);
|
adventureArray.push(data.adventure);
|
||||||
if (data.adventure.type === "mylog") {
|
|
||||||
incrementVisitCount(1);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("Error:", error);
|
console.error("Error:", error);
|
||||||
|
@ -155,10 +151,3 @@ export async function changeType(
|
||||||
|
|
||||||
return adventureArray;
|
return adventureArray;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Increments the visit count by the specified amount.
|
|
||||||
* @param {number} amount - The amount to increment the visit count by.
|
|
||||||
*/
|
|
||||||
export function incrementVisitCount(amount: number) {
|
|
||||||
visitCount.update((n) => n + 1);
|
|
||||||
}
|
|
||||||
|
|
25
startup.sh
25
startup.sh
|
@ -9,22 +9,6 @@ wait_for_db() {
|
||||||
echo "Database is now available."
|
echo "Database is now available."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to run SQL scripts
|
|
||||||
run_sql_scripts() {
|
|
||||||
echo "Running SQL scripts..."
|
|
||||||
|
|
||||||
# Define the path to your SQL scripts
|
|
||||||
SQL_SCRIPTS_PATH="/sql" # Replace with the path to your SQL scripts
|
|
||||||
|
|
||||||
# Run each SQL script in the directory using the DATABASE_URL
|
|
||||||
for sql_script in "$SQL_SCRIPTS_PATH"/*.sql; do
|
|
||||||
echo "Running script: $sql_script"
|
|
||||||
psql "$DATABASE_URL" -f "$sql_script"
|
|
||||||
done
|
|
||||||
echo "Finished running SQL scripts."
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Start your application here
|
# Start your application here
|
||||||
# Print message
|
# Print message
|
||||||
echo "Starting AdventureLog"
|
echo "Starting AdventureLog"
|
||||||
|
@ -34,18 +18,9 @@ if [ -z "$SKIP_DB_WAIT" ] || [ "$SKIP_DB_WAIT" = "false" ]; then
|
||||||
wait_for_db
|
wait_for_db
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Wait for the database to start up
|
|
||||||
|
|
||||||
|
|
||||||
# generate the schema
|
|
||||||
# npm run generate
|
|
||||||
|
|
||||||
# Run database migration
|
# Run database migration
|
||||||
npm run migrate
|
npm run migrate
|
||||||
|
|
||||||
# Run SQL scripts
|
|
||||||
# run_sql_scripts
|
|
||||||
|
|
||||||
echo "The origin to be set is: $ORIGIN"
|
echo "The origin to be set is: $ORIGIN"
|
||||||
# Start the application
|
# Start the application
|
||||||
ORIGIN=$ORIGIN node build
|
ORIGIN=$ORIGIN node build
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue