diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a31acb1..885dce7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,7 +5,7 @@ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile "image": "mcr.microsoft.com/devcontainers/base:jammy", "features": { - "ghcr.io/devcontainers-contrib/features/node-asdf:0": {}, + "ghcr.io/devcontainers/features/node:1": {}, "ghcr.io/devcontainers/features/docker-in-docker:2": {} } diff --git a/Dockerfile b/Dockerfile index 97eb7d7..78fe005 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,8 +10,11 @@ WORKDIR /app # Copy all local files into the image COPY . . -# Clean install all node modules -RUN npm ci +# Install pnpm +RUN npm install -g pnpm + +# Clean install all node modules using pnpm +RUN pnpm install # Build SvelteKit app RUN npm run build @@ -19,13 +22,10 @@ RUN npm run build # Expose the port that the app is listening on EXPOSE 3000 - RUN chmod +x ./startup.sh # The USER instruction sets the user name to use as the default user for the remainder of the current stage USER node:node -# get permission to run startup script - # Run startup.sh instead of the default command -CMD ["./startup.sh"] +CMD ["./startup.sh"] \ No newline at end of file diff --git a/src/lib/components/CreateNewAdventure.svelte b/src/lib/components/CreateNewAdventure.svelte index 1636f26..ecadf70 100644 --- a/src/lib/components/CreateNewAdventure.svelte +++ b/src/lib/components/CreateNewAdventure.svelte @@ -9,6 +9,7 @@ location: "", date: "", activityTypes: [], + imageUrl: "", }; import { createEventDispatcher } from "svelte"; @@ -121,6 +122,16 @@ class="input input-bordered w-full max-w-xs" /> +
+ + +
+ diff --git a/src/lib/db/insertData.ts b/src/lib/db/insertData.ts index f6ab875..0cb3ffe 100644 --- a/src/lib/db/insertData.ts +++ b/src/lib/db/insertData.ts @@ -36,7 +36,12 @@ export async function insertData() { ('Australia', 'au', 'Oceania'), ('New Zealand', 'nz', 'Oceania'), ('South Africa', 'za', 'Africa'), - ('Egypt', 'eg', 'Africa') + ('Egypt', 'eg', 'Africa'), + ('Sweden', 'se', 'Europe'), + ('Ireland', 'ie', 'Europe'), + ('Spain', 'es', 'Europe'), + ('Switzerland', 'ch', 'Europe'), + ('Italy', 'it', 'Europe') ON CONFLICT (country_code) DO NOTHING;`); console.log("Inserting regions..."); @@ -94,6 +99,8 @@ export async function insertData() { ON CONFLICT (id) DO NOTHING; `); + console.log("Inserting Canada regions..."); + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) VALUES ('CA-AB', 'Alberta', 'ca'), @@ -113,6 +120,8 @@ ON CONFLICT (id) DO NOTHING; `); + console.log("Inserting Germany regions..."); + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) VALUES ('DE-BW', 'Baden-Württemberg', 'de'), @@ -136,6 +145,8 @@ ON CONFLICT (id) DO NOTHING; `); + console.log("Inserting France regions..."); + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) VALUES ('FR-ARA', 'Auvergne-Rhône-Alpes', 'fr'), @@ -161,6 +172,8 @@ ON CONFLICT (id) DO NOTHING; `); + console.log("Inserting United Kingdom regions..."); + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) VALUES ('GB-ENG', 'England', 'gb'), @@ -172,6 +185,8 @@ ON CONFLICT (id) DO NOTHING; `); + console.log("Inserting Argentina regions..."); + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) VALUES ('AR-C', 'Ciudad Autónoma de Buenos Aires', 'ar'), @@ -203,6 +218,8 @@ ON CONFLICT (id) DO NOTHING; `); + console.log("Inerting Mexico regions..."); + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) VALUES ('MX-AGU', 'Aguascalientes', 'mx'), @@ -241,6 +258,8 @@ ON CONFLICT (id) DO NOTHING; `); + console.log("Inserting Japan regions..."); + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) VALUES ('JP-01', 'Hokkaido', 'jp'), @@ -295,6 +314,8 @@ ON CONFLICT (id) DO NOTHING; `); + console.log("Inserting China regions..."); + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) VALUES ('CN-BJ', 'Beijing', 'cn'), @@ -333,6 +354,8 @@ ON CONFLICT (id) DO NOTHING; `); + console.log("Inserting India regions..."); + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) VALUES ('IN-AN', 'Andaman and Nicobar Islands', 'in'), @@ -376,6 +399,8 @@ ON CONFLICT (id) DO NOTHING; `); + console.log("Inserting Australia regions..."); + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) VALUES ('AU-NSW', 'New South Wales', 'au'), @@ -392,6 +417,8 @@ ON CONFLICT (id) DO NOTHING; `); + console.log("Inserting New Zealand regions..."); + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) VALUES ('NZ-N', 'Northland', 'nz'), @@ -416,6 +443,8 @@ ON CONFLICT (id) DO NOTHING; `); + console.log("Inserting South Africa regions..."); + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) VALUES ('ZA-EC', 'Eastern Cape', 'za'), @@ -433,6 +462,8 @@ ON CONFLICT (id) DO NOTHING; `); + console.log("Inserting Egypt regions..."); + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) VALUES ('EG-ALX', 'Alexandria', 'eg'), @@ -464,10 +495,10 @@ ON CONFLICT (id) DO NOTHING; ('EG-ESI', 'Ismailia', 'eg') ON CONFLICT (id) DO NOTHING; - - `); + console.log("Inserting Brazil regions..."); + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) VALUES ('BR-AC', 'Acre', 'br'), @@ -497,9 +528,129 @@ VALUES ('BR-SP', 'São Paulo', 'br'), ('BR-SE', 'Sergipe', 'br'), ('BR-TO', 'Tocantins', 'br') - ON CONFLICT (id) DO NOTHING; +`); - + console.log("Inserting Sweden regions..."); + + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) + VALUES + ('SE-AB', 'Stockholm', 'se'), + ('SE-AC', 'Västerbotten', 'se'), + ('SE-BD', 'Norrbotten', 'se'), + ('SE-C', 'Uppsala', 'se'), + ('SE-D', 'Södermanland', 'se'), + ('SE-E', 'Östergötland', 'se'), + ('SE-F', 'Jönköping', 'se'), + ('SE-G', 'Kronoberg', 'se'), + ('SE-H', 'Kalmar', 'se'), + ('SE-I', 'Gotland', 'se'), + ('SE-K', 'Blekinge', 'se'), + ('SE-M', 'Skåne', 'se'), + ('SE-N', 'Halland', 'se'), + ('SE-O', 'Västra Götaland', 'se'), + ('SE-S', 'Värmland', 'se'), + ('SE-T', 'Örebro', 'se'), + ('SE-U', 'Västmanland', 'se'), + ('SE-W', 'Dalarna', 'se'), + ('SE-X', 'Gävleborg', 'se'), + ('SE-Y', 'Västernorrland', 'se'), + ('SE-Z', 'Jämtland', 'se') + ON CONFLICT (id) DO NOTHING; +`); + + console.log("Inserting Ireland regions..."); + + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) + VALUES + ('IE-C', 'Connacht', 'ie'), + ('IE-L', 'Leinster', 'ie'), + ('IE-M', 'Munster', 'ie'), + ('IE-U', 'Ulster', 'ie') + ON CONFLICT (id) DO NOTHING; +`); + + console.log("Inserting Spain regions..."); + + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) + VALUES + ('ES-AN', 'Andalucía', 'es'), + ('ES-AR', 'Aragón', 'es'), + ('ES-AS', 'Asturias', 'es'), + ('ES-CB', 'Cantabria', 'es'), + ('ES-CL', 'Castilla y León', 'es'), + ('ES-CM', 'Castilla-La Mancha', 'es'), + ('ES-CN', 'Canarias', 'es'), + ('ES-CT', 'Cataluña', 'es'), + ('ES-EX', 'Extremadura', 'es'), + ('ES-GA', 'Galicia', 'es'), + ('ES-IB', 'Islas Baleares', 'es'), + ('ES-MD', 'Madrid', 'es'), + ('ES-MC', 'Murcia', 'es'), + ('ES-NC', 'Navarra', 'es'), + ('ES-PV', 'País Vasco', 'es'), + ('ES-RI', 'La Rioja', 'es'), + ('ES-VC', 'Comunidad Valenciana', 'es') + ON CONFLICT (id) DO NOTHING; +`); + + console.log("Inserting Switzerland regions..."); + + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) + VALUES + ('CH-AG', 'Aargau', 'ch'), + ('CH-AR', 'Appenzell Ausserrhoden', 'ch'), + ('CH-AI', 'Appenzell Innerrhoden', 'ch'), + ('CH-BL', 'Basel-Landschaft', 'ch'), + ('CH-BS', 'Basel-Stadt', 'ch'), + ('CH-BE', 'Bern', 'ch'), + ('CH-FR', 'Fribourg', 'ch'), + ('CH-GE', 'Genève', 'ch'), + ('CH-GL', 'Glarus', 'ch'), + ('CH-GR', 'Graubünden', 'ch'), + ('CH-JU', 'Jura', 'ch'), + ('CH-LU', 'Luzern', 'ch'), + ('CH-NE', 'Neuchâtel', 'ch'), + ('CH-NW', 'Nidwalden', 'ch'), + ('CH-OW', 'Obwalden', 'ch'), + ('CH-SH', 'Schaffhausen', 'ch'), + ('CH-SZ', 'Schwyz', 'ch'), + ('CH-SO', 'Solothurn', 'ch'), + ('CH-SG', 'St. Gallen', 'ch'), + ('CH-TG', 'Thurgau', 'ch'), + ('CH-TI', 'Ticino', 'ch'), + ('CH-UR', 'Uri', 'ch'), + ('CH-VS', 'Valais', 'ch'), + ('CH-VD', 'Vaud', 'ch'), + ('CH-ZG', 'Zug', 'ch'), + ('CH-ZH', 'Zürich', 'ch') + ON CONFLICT (id) DO NOTHING; +`); + + console.log("Inserting Italy regions..."); + + await db.execute(sql`INSERT INTO "worldTravelCountryRegions" (id, name, country_code) + VALUES + ('IT-65', 'Abruzzo', 'it'), + ('IT-77', 'Basilicata', 'it'), + ('IT-78', 'Calabria', 'it'), + ('IT-72', 'Campania', 'it'), + ('IT-45', 'Emilia-Romagna', 'it'), + ('IT-36', 'Friuli Venezia Giulia', 'it'), + ('IT-62', 'Lazio', 'it'), + ('IT-42', 'Liguria', 'it'), + ('IT-25', 'Lombardia', 'it'), + ('IT-57', 'Marche', 'it'), + ('IT-67', 'Molise', 'it'), + ('IT-21', 'Piemonte', 'it'), + ('IT-75', 'Puglia', 'it'), + ('IT-88', 'Sardegna', 'it'), + ('IT-82', 'Sicilia', 'it'), + ('IT-52', 'Toscana', 'it'), + ('IT-32', 'Trentino-Alto Adige', 'it'), + ('IT-55', 'Umbria', 'it'), + ('IT-23', 'Valle d''Aosta', 'it'), + ('IT-34', 'Veneto', 'it') + ON CONFLICT (id) DO NOTHING; `); } diff --git a/src/lib/index.ts b/src/lib/index.ts index 1d825a7..07c1c49 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -1,20 +1,6 @@ import inspirationalQuotes from "./json/quotes.json"; -import countryCodes from "./json/countries.json"; import type { Adventure } from "./utils/types"; -/** - * Converts a country code to its corresponding country name. - * @param countryCode - The country code to convert. - * @returns The country name if found, otherwise null. - */ -export function countryCodeToName(countryCode: string): string | null { - // Look up the country name using the provided country code - const countryName = - countryCodes[countryCode.toLowerCase() as keyof typeof countryCodes]; - // Return the country name if found, otherwise return null - return countryName || null; -} - /** * Generates the URL for a flag image based on the specified size and country code. * @param size - The desired height of the flag image. Avaliable sizes: 20, 24, 40, 60, 80, 120, 240. diff --git a/src/lib/json/countries.json b/src/lib/json/countries.json deleted file mode 100644 index 8fd4d0d..0000000 --- a/src/lib/json/countries.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "us": "United States", - "de": "Germany", - "fr": "France", - "gb": "United Kingdom", - "ar": "Argentina", - "mx": "Mexico", - "jp": "Japan", - "cn": "China", - "in": "India", - "au": "Australia", - "nz": "New Zealand", - "za": "South Africa", - "eg": "Egypt", - "ca": "Canada", - "br": "Brazil" -} diff --git a/src/routes/api/adventure/+server.ts b/src/routes/api/adventure/+server.ts index 7bfba3e..8dc6837 100644 --- a/src/routes/api/adventure/+server.ts +++ b/src/routes/api/adventure/+server.ts @@ -28,8 +28,8 @@ export const GET: RequestHandler = async ({ url, locals }) => { .where( and( eq(adventureTable.id, Number(id)), // Convert id to number - eq(adventureTable.userId, user.id), - eq(adventureTable.type, "mylog") + eq(adventureTable.userId, user.id) + // eq(adventureTable.type, "mylog") ) ) .limit(1) diff --git a/src/routes/api/planner/+server.ts b/src/routes/api/planner/+server.ts index 2272af7..7bf8fb5 100644 --- a/src/routes/api/planner/+server.ts +++ b/src/routes/api/planner/+server.ts @@ -109,8 +109,16 @@ export async function POST(event: RequestEvent): Promise { }); } - const { name, location, date, description, activityTypes, rating, tripId } = - body.detailAdventure; + const { + name, + location, + date, + description, + activityTypes, + rating, + tripId, + imageUrl, + } = body.detailAdventure; if (!name) { return error(400, { @@ -139,6 +147,7 @@ export async function POST(event: RequestEvent): Promise { description: description || null, activityTypes: JSON.stringify(activityTypes) || null, rating: rating || null, + imageUrl: imageUrl || null, }) .returning({ insertedId: adventureTable.id }) .execute(); @@ -182,8 +191,16 @@ export async function PUT(event: RequestEvent): Promise { }); } - const { name, location, date, description, activityTypes, id, rating } = - body.detailAdventure; + const { + name, + location, + date, + description, + activityTypes, + id, + rating, + imageUrl, + } = body.detailAdventure; if (!name) { return error(400, { @@ -201,6 +218,7 @@ export async function PUT(event: RequestEvent): Promise { description: description, rating: rating, activityTypes: JSON.stringify(activityTypes), + imageUrl: imageUrl, }) .where( and( diff --git a/src/routes/api/visits/+server.ts b/src/routes/api/visits/+server.ts index 5092016..827fb23 100644 --- a/src/routes/api/visits/+server.ts +++ b/src/routes/api/visits/+server.ts @@ -108,7 +108,7 @@ export async function POST(event: RequestEvent): Promise { }); } - const { name, location, date, description, activityTypes, rating } = + const { name, location, date, description, activityTypes, rating, imageUrl } = body.detailAdventure; if (!name) { @@ -137,6 +137,7 @@ export async function POST(event: RequestEvent): Promise { description: description || null, activityTypes: JSON.stringify(activityTypes) || null, rating: rating || null, + imageUrl: imageUrl || null, }) .returning({ insertedId: adventureTable.id }) .execute(); @@ -180,8 +181,17 @@ export async function PUT(event: RequestEvent): Promise { }); } - const { name, location, date, description, activityTypes, id, rating, type } = - body.detailAdventure; + const { + name, + location, + date, + description, + activityTypes, + id, + rating, + type, + imageUrl, + } = body.detailAdventure; if (!name) { return error(400, { @@ -206,6 +216,7 @@ export async function PUT(event: RequestEvent): Promise { description: description, rating: rating, activityTypes: JSON.stringify(activityTypes), + imageUrl: imageUrl, }) .where( and( diff --git a/src/routes/log/+page.svelte b/src/routes/log/+page.svelte index b5a1cdd..0a1493d 100644 --- a/src/routes/log/+page.svelte +++ b/src/routes/log/+page.svelte @@ -158,7 +158,7 @@ } -
+