diff --git a/.env.example b/.env.example index d84d274..efae49e 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,3 @@ PUBLIC_SUPABASE_URL=http://127.0.0.1:54321 -PUBLIC_SUPABASE_ANON_KEY=your-anon-key-here \ No newline at end of file +PUBLIC_SUPABASE_ANON_KEY=your-anon-key-here +PUBLIC_GMAPS_API_KEY=your-google-maps-api-key-here \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d9978e4..226ba79 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,6 +21,7 @@ check_types: variables: PUBLIC_SUPABASE_URL: $SUPABASE_URL PUBLIC_SUPABASE_ANON_KEY: $SUPABASE_ANON_KEY + PUBLIC_GMAPS_API_KEY: $GMAPS_API_KEY script: - npm run check @@ -72,6 +73,7 @@ build: variables: PUBLIC_SUPABASE_URL: $SUPABASE_URL PUBLIC_SUPABASE_ANON_KEY: $SUPABASE_ANON_KEY + PUBLIC_GMAPS_API_KEY: $GMAPS_API_KEY script: - npm run build artifacts: diff --git a/package-lock.json b/package-lock.json index a224f91..6da5e80 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,18 +8,22 @@ "name": "drp-48", "version": "0.0.1", "dependencies": { + "@googlemaps/js-api-loader": "^1.16.8", "@supabase/ssr": "^0.6.1", - "@supabase/supabase-js": "^2.49.8" + "@supabase/supabase-js": "^2.49.8", + "posthog-js": "^1.250.1" }, "devDependencies": { "@eslint/compat": "^1.2.5", "@eslint/js": "^9.18.0", + "@googlemaps/typescript-guards": "^2.0.3", "@playwright/test": "^1.49.1", "@sveltejs/adapter-node": "^5.2.12", "@sveltejs/kit": "^2.16.0", "@sveltejs/vite-plugin-svelte": "^5.0.0", "@testing-library/jest-dom": "^6.6.3", "@testing-library/svelte": "^5.2.4", + "@types/google.maps": "^3.58.1", "eslint": "^9.18.0", "eslint-config-prettier": "^10.0.1", "eslint-plugin-svelte": "^3.0.0", @@ -818,6 +822,19 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/@googlemaps/js-api-loader": { + "version": "1.16.8", + "resolved": "https://registry.npmjs.org/@googlemaps/js-api-loader/-/js-api-loader-1.16.8.tgz", + "integrity": "sha512-CROqqwfKotdO6EBjZO/gQGVTbeDps5V7Mt9+8+5Q+jTg5CRMi3Ii/L9PmV3USROrt2uWxtGzJHORmByxyo9pSQ==", + "license": "Apache-2.0" + }, + "node_modules/@googlemaps/typescript-guards": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@googlemaps/typescript-guards/-/typescript-guards-2.0.3.tgz", + "integrity": "sha512-3iHuO8H0jPehftsMK0kgyJzPYU/g/oiTRw+wu/yltqSZ7wJPt3vfsJHkPiuRpQjbnnWygX+T3mkRGyK/eyZ/lw==", + "dev": true, + "license": "Apache-2.0" + }, "node_modules/@humanfs/core": { "version": "0.19.1", "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", @@ -1724,6 +1741,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/google.maps": { + "version": "3.58.1", + "resolved": "https://registry.npmjs.org/@types/google.maps/-/google.maps-3.58.1.tgz", + "integrity": "sha512-X9QTSvGJ0nCfMzYOnaVs/k6/4L+7F5uCS+4iUmkLEls6J9S/Phv+m/i3mDeyc49ZBgwab3EFO1HEoBY7k98EGQ==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -2451,6 +2475,17 @@ "node": ">= 0.6" } }, + "node_modules/core-js": { + "version": "3.43.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.43.0.tgz", + "integrity": "sha512-N6wEbTTZSYOY2rYAn85CuvWWkCK6QweMn7/4Nr3w+gDBeBhk/x4EJeY6FPo4QzDoJZxVTv8U7CMvgWk6pOHHqA==", + "hasInstallScript": true, + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -3030,6 +3065,12 @@ "node": "^12.20 || >= 14.13" } }, + "node_modules/fflate": { + "version": "0.4.8", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.4.8.tgz", + "integrity": "sha512-FJqqoDBR00Mdj9ppamLa/Y7vxm+PRmNWA67N846RvsoYVMKB4q3y/de5PA7gUmRMYK/8CMz2GDZQmCRN1wBcWA==", + "license": "MIT" + }, "node_modules/file-entry-cache": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", @@ -4090,6 +4131,40 @@ "node": ">=4" } }, + "node_modules/posthog-js": { + "version": "1.250.1", + "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.250.1.tgz", + "integrity": "sha512-Dl9BQjPa5FFVUauLSX/8HP6naRfU605GQYq+oAHFqwyv20NQDCHT0uRtFT1x2EYrY0kIQdd0d/rOY6Tg4wgqEg==", + "license": "SEE LICENSE IN LICENSE", + "dependencies": { + "core-js": "^3.38.1", + "fflate": "^0.4.8", + "preact": "^10.19.3", + "web-vitals": "^4.2.4" + }, + "peerDependencies": { + "@rrweb/types": "2.0.0-alpha.17", + "rrweb-snapshot": "2.0.0-alpha.17" + }, + "peerDependenciesMeta": { + "@rrweb/types": { + "optional": true + }, + "rrweb-snapshot": { + "optional": true + } + } + }, + "node_modules/preact": { + "version": "10.26.8", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.26.8.tgz", + "integrity": "sha512-1nMfdFjucm5hKvq0IClqZwK4FJkGXhRrQstOQ3P4vp8HxKrJEMFcY6RdBRVTdfQS/UlnX6gfbPuTvaqx/bDoeQ==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/preact" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -5117,6 +5192,12 @@ "node": ">= 8" } }, + "node_modules/web-vitals": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-4.2.4.tgz", + "integrity": "sha512-r4DIlprAGwJ7YM11VZp4R884m0Vmgr6EAKe3P+kO0PPj3Unqyvv59rczf6UiGcb9Z8QxZVcqKNwv/g0WNdWwsw==", + "license": "Apache-2.0" + }, "node_modules/webidl-conversions": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", diff --git a/package.json b/package.json index 74b26fa..3513623 100644 --- a/package.json +++ b/package.json @@ -20,12 +20,14 @@ "devDependencies": { "@eslint/compat": "^1.2.5", "@eslint/js": "^9.18.0", + "@googlemaps/typescript-guards": "^2.0.3", "@playwright/test": "^1.49.1", "@sveltejs/adapter-node": "^5.2.12", "@sveltejs/kit": "^2.16.0", "@sveltejs/vite-plugin-svelte": "^5.0.0", "@testing-library/jest-dom": "^6.6.3", "@testing-library/svelte": "^5.2.4", + "@types/google.maps": "^3.58.1", "eslint": "^9.18.0", "eslint-config-prettier": "^10.0.1", "eslint-plugin-svelte": "^3.0.0", @@ -42,7 +44,9 @@ "vitest": "^3.0.0" }, "dependencies": { + "@googlemaps/js-api-loader": "^1.16.8", "@supabase/ssr": "^0.6.1", - "@supabase/supabase-js": "^2.49.8" + "@supabase/supabase-js": "^2.49.8", + "posthog-js": "^1.250.1" } } diff --git a/src/lib/components/CompulsoryTags.svelte b/src/lib/components/CompulsoryTags.svelte index e6a1228..ba5a23b 100644 --- a/src/lib/components/CompulsoryTags.svelte +++ b/src/lib/components/CompulsoryTags.svelte @@ -33,7 +33,7 @@ background-color: #eaffeb; color: #2e4653; cursor: pointer; - padding: 0.2rem 0.6rem; + padding: 0.2rem 0.2rem; } .compulsoryTagYellow { display: flex; @@ -45,7 +45,7 @@ background-color: #ffffd4; color: #534b2e; cursor: pointer; - padding: 0.2rem 0.6rem; + padding: 0.2rem 0.2rem; } .compulsoryTagRed { display: flex; @@ -57,6 +57,6 @@ background-color: #ffcece; color: #532e2e; cursor: pointer; - padding: 0.2rem 0.6rem; + padding: 0.2rem 0.2rem; } diff --git a/src/lib/components/Report.svelte b/src/lib/components/Report.svelte new file mode 100644 index 0000000..6322b9b --- /dev/null +++ b/src/lib/components/Report.svelte @@ -0,0 +1,140 @@ + + +
+ + diff --git a/src/lib/components/SpaceCard.svelte b/src/lib/components/SpaceCard.svelte index e845299..0c1bf04 100644 --- a/src/lib/components/SpaceCard.svelte +++ b/src/lib/components/SpaceCard.svelte @@ -77,8 +77,8 @@ .compulsoryContainer { display: grid; - grid-template-columns: repeat(3, 1fr); - gap: 0.5rem; - font-size: 0.875rem; + grid-template-columns: repeat(auto-fit, minmax(3.75rem, 1fr)); + gap: 0.3rem; + font-size: 0.8rem; } diff --git a/src/lib/components/inputs/Text.svelte b/src/lib/components/inputs/Text.svelte index 8488479..cb9b9bc 100644 --- a/src/lib/components/inputs/Text.svelte +++ b/src/lib/components/inputs/Text.svelte @@ -1,15 +1,16 @@ - + diff --git a/supabase/migrations/20250609142130_add-compulsory-tags.sql b/supabase/migrations/20250609142130_add-compulsory-tags.sql index 5355520..485144c 100644 --- a/supabase/migrations/20250609142130_add-compulsory-tags.sql +++ b/supabase/migrations/20250609142130_add-compulsory-tags.sql @@ -2,9 +2,9 @@ alter table "public"."study_spaces" add column "power" text; alter table "public"."study_spaces" add column "volume" text; alter table "public"."study_spaces" add column "wifi" text; -update "public"."study_spaces" set "power" = 'Many' where "power" is null; +update "public"."study_spaces" set "power" = 'Many Outlets' where "power" is null; update "public"."study_spaces" set "volume" = 'Quiet' where "volume" is null; -update "public"."study_spaces" set "wifi" = 'Good' where "wifi" is null; +update "public"."study_spaces" set "wifi" = 'Good WiFi' where "wifi" is null; alter table "public"."study_spaces" alter column "power" set not null; alter table "public"."study_spaces" alter column "volume" set not null; diff --git a/supabase/migrations/20250609145614_gmaps_location.sql b/supabase/migrations/20250609145614_gmaps_location.sql new file mode 100644 index 0000000..a7d1a43 --- /dev/null +++ b/supabase/migrations/20250609145614_gmaps_location.sql @@ -0,0 +1,3 @@ +-- rename old colum nto building_location_old and create a new column instead of altering +alter table "public"."study_spaces" rename column "building_location" to "building_location_old"; +alter table "public"."study_spaces" add column "building_location" jsonb; \ No newline at end of file diff --git a/supabase/migrations/20250610163930_add_report_table.sql b/supabase/migrations/20250610163930_add_report_table.sql new file mode 100644 index 0000000..0ac16d0 --- /dev/null +++ b/supabase/migrations/20250610163930_add_report_table.sql @@ -0,0 +1,12 @@ +CREATE TABLE reports ( + id uuid PRIMARY KEY DEFAULT gen_random_uuid(), + study_space_id uuid REFERENCES study_spaces(id) ON DELETE CASCADE, + created_at timestamp with time zone DEFAULT now(), + updated_at timestamp with time zone DEFAULT now(), + type text NOT NULL, + content text +); + +CREATE TRIGGER reports_updated_at +AFTER UPDATE ON reports +FOR EACH ROW EXECUTE FUNCTION handle_updated_at(); diff --git a/supabase/schemas/0001_study_spaces.sql b/supabase/schemas/0001_study_spaces.sql index 9d97101..134ff96 100644 --- a/supabase/schemas/0001_study_spaces.sql +++ b/supabase/schemas/0001_study_spaces.sql @@ -11,7 +11,9 @@ CREATE TABLE study_spaces ( description text, -- Location within building, e.g., "Room 101" location text, - building_location text, + -- Not bothered to write a proper data migration + building_location_old text, + building_location jsonb, tags text[] NOT NULL DEFAULT array[]::text[], volume text NOT NULL, wifi text NOT NULL, @@ -28,6 +30,14 @@ CREATE TABLE study_space_images ( PRIMARY KEY (study_space_id, image_path) ); +CREATE TABLE reports ( + id uuid PRIMARY KEY DEFAULT gen_random_uuid(), + study_space_id uuid REFERENCES study_spaces(id) ON DELETE CASCADE, + created_at timestamp with time zone DEFAULT now(), + updated_at timestamp with time zone DEFAULT now(), + type text NOT NULL, + content text +); -- Triggers CREATE TRIGGER study_spaces_updated_at @@ -37,3 +47,7 @@ FOR EACH ROW EXECUTE FUNCTION handle_updated_at(); CREATE TRIGGER study_space_images_updated_at AFTER UPDATE ON study_space_images FOR EACH ROW EXECUTE FUNCTION handle_updated_at(); + +CREATE TRIGGER reports_updated_at +AFTER UPDATE ON reports +FOR EACH ROW EXECUTE FUNCTION handle_updated_at();