From d2ab3159788d38218a70047072b706ede14f4fc2 Mon Sep 17 00:00:00 2001 From: Bradley Shellnut Date: Fri, 13 Jan 2023 21:13:59 -0800 Subject: [PATCH 001/141] Introduce custom media queries and add iconify icons. --- environmentVariables.js | 10 -- environmentVariables.json | 10 ++ package.json | 13 +- pnpm-lock.yaml | 184 +++++++++++++------------ postcss.config.cjs | 18 +-- src/lib/components/button/index.svelte | 1 + src/lib/stores/search.ts | 6 +- src/routes/+layout.svelte | 4 + src/routes/collection/+page.server.ts | 12 ++ src/routes/collection/+page.svelte | 7 +- src/routes/game/[id]/+page.svelte | 14 +- src/routes/wishlist/+page.svelte | 3 +- 12 files changed, 161 insertions(+), 121 deletions(-) delete mode 100644 environmentVariables.js create mode 100644 environmentVariables.json create mode 100644 src/routes/collection/+page.server.ts diff --git a/environmentVariables.js b/environmentVariables.js deleted file mode 100644 index 825ed8d..0000000 --- a/environmentVariables.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - environmentVariables: { - '--xsmall-viewport': '480px', - '--small-viewport': '640px', - '--medium-viewport': '768px', - '--large-viewport': '1024px', - '--xlarge-viewport': '1280px', - '--xxlarge-viewport': '1536px', - } -} \ No newline at end of file diff --git a/environmentVariables.json b/environmentVariables.json new file mode 100644 index 0000000..9f739bf --- /dev/null +++ b/environmentVariables.json @@ -0,0 +1,10 @@ +{ + "environment-variables": { + "--xsmall-viewport": "480px", + "--small-viewport": "640px", + "--medium-viewport": "768px", + "--large-viewport": "1024px", + "--xlarge-viewport": "1280px", + "--xxlarge-viewport": "1536px" + } +} diff --git a/package.json b/package.json index da4ad35..06db873 100644 --- a/package.json +++ b/package.json @@ -17,12 +17,12 @@ "@rgossiaux/svelte-headlessui": "1.0.2", "@rgossiaux/svelte-heroicons": "^0.1.2", "@sveltejs/adapter-auto": "^1.0.0", - "@sveltejs/adapter-vercel": "^1.0.1", - "@sveltejs/kit": "^1.0.7", + "@sveltejs/adapter-vercel": "^1.0.2", + "@sveltejs/kit": "^1.0.13", "@types/cookie": "^0.5.1", "@types/node": "^18.11.18", - "@typescript-eslint/eslint-plugin": "^5.48.0", - "@typescript-eslint/parser": "^5.48.0", + "@typescript-eslint/eslint-plugin": "^5.48.1", + "@typescript-eslint/parser": "^5.48.1", "autoprefixer": "^10.4.13", "eslint": "^8.31.0", "eslint-config-prettier": "^8.6.0", @@ -40,7 +40,7 @@ "prettier": "^2.8.2", "prettier-plugin-svelte": "^2.9.0", "sass": "^1.57.1", - "svelte": "^3.55.0", + "svelte": "^3.55.1", "svelte-check": "^2.10.3", "svelte-preprocess": "^4.10.7", "tslib": "^2.4.1", @@ -57,8 +57,9 @@ "@types/feather-icons": "^4.29.1", "cookie": "^0.5.0", "feather-icons": "^4.29.0", + "iconify-icon": "^1.0.2", "svelte-lazy-loader": "^1.0.0", "zod": "^3.20.2", - "zod-to-json-schema": "^3.20.1" + "zod-to-json-schema": "^3.20.2" } } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 67a2e1f..3f42555 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,19 +9,20 @@ specifiers: '@rgossiaux/svelte-headlessui': 1.0.2 '@rgossiaux/svelte-heroicons': ^0.1.2 '@sveltejs/adapter-auto': ^1.0.0 - '@sveltejs/adapter-vercel': ^1.0.1 - '@sveltejs/kit': ^1.0.7 + '@sveltejs/adapter-vercel': ^1.0.2 + '@sveltejs/kit': ^1.0.13 '@types/cookie': ^0.5.1 '@types/feather-icons': ^4.29.1 '@types/node': ^18.11.18 - '@typescript-eslint/eslint-plugin': ^5.48.0 - '@typescript-eslint/parser': ^5.48.0 + '@typescript-eslint/eslint-plugin': ^5.48.1 + '@typescript-eslint/parser': ^5.48.1 autoprefixer: ^10.4.13 cookie: ^0.5.0 eslint: ^8.31.0 eslint-config-prettier: ^8.6.0 eslint-plugin-svelte3: ^4.0.0 feather-icons: ^4.29.0 + iconify-icon: ^1.0.2 just-clone: ^6.2.0 just-debounce-it: ^3.2.0 postcss: ^8.4.21 @@ -35,7 +36,7 @@ specifiers: prettier: ^2.8.2 prettier-plugin-svelte: ^2.9.0 sass: ^1.57.1 - svelte: ^3.55.0 + svelte: ^3.55.1 svelte-check: ^2.10.3 svelte-lazy-loader: ^1.0.0 svelte-preprocess: ^4.10.7 @@ -44,7 +45,7 @@ specifiers: vite: ^4.0.4 vitest: ^0.25.3 zod: ^3.20.2 - zod-to-json-schema: ^3.20.1 + zod-to-json-schema: ^3.20.2 dependencies: '@fontsource/fira-mono': 4.5.10 @@ -54,25 +55,26 @@ dependencies: '@types/feather-icons': 4.29.1 cookie: 0.5.0 feather-icons: 4.29.0 + iconify-icon: 1.0.2 svelte-lazy-loader: 1.0.0 zod: 3.20.2 - zod-to-json-schema: 3.20.1_zod@3.20.2 + zod-to-json-schema: 3.20.2_zod@3.20.2 devDependencies: '@playwright/test': 1.29.2 - '@rgossiaux/svelte-headlessui': 1.0.2_svelte@3.55.0 - '@rgossiaux/svelte-heroicons': 0.1.2_svelte@3.55.0 - '@sveltejs/adapter-auto': 1.0.0_@sveltejs+kit@1.0.7 - '@sveltejs/adapter-vercel': 1.0.1_@sveltejs+kit@1.0.7 - '@sveltejs/kit': 1.0.7_svelte@3.55.0+vite@4.0.4 + '@rgossiaux/svelte-headlessui': 1.0.2_svelte@3.55.1 + '@rgossiaux/svelte-heroicons': 0.1.2_svelte@3.55.1 + '@sveltejs/adapter-auto': 1.0.0_@sveltejs+kit@1.0.13 + '@sveltejs/adapter-vercel': 1.0.2_@sveltejs+kit@1.0.13 + '@sveltejs/kit': 1.0.13_svelte@3.55.1+vite@4.0.4 '@types/cookie': 0.5.1 '@types/node': 18.11.18 - '@typescript-eslint/eslint-plugin': 5.48.0_k73wpmdolxikpyqun3p36akaaq - '@typescript-eslint/parser': 5.48.0_iukboom6ndih5an6iafl45j2fe + '@typescript-eslint/eslint-plugin': 5.48.1_3jon24igvnqaqexgwtxk6nkpse + '@typescript-eslint/parser': 5.48.1_iukboom6ndih5an6iafl45j2fe autoprefixer: 10.4.13_postcss@8.4.21 eslint: 8.31.0 eslint-config-prettier: 8.6.0_eslint@8.31.0 - eslint-plugin-svelte3: 4.0.0_6go7qzsvzihesfwmyvq3tnl5qq + eslint-plugin-svelte3: 4.0.0_btuntbn75dxkba3nofpps2nvzm just-clone: 6.2.0 just-debounce-it: 3.2.0 postcss: 8.4.21 @@ -84,11 +86,11 @@ devDependencies: postcss-media-minmax: 5.0.0_postcss@8.4.21 postcss-nested: 6.0.0_postcss@8.4.21 prettier: 2.8.2 - prettier-plugin-svelte: 2.9.0_74vfyr7qjo56zgjcvkwi6gyjxm + prettier-plugin-svelte: 2.9.0_y74x4qymbshr6ujrzcfe2sydsa sass: 1.57.1 - svelte: 3.55.0 - svelte-check: 2.10.3_2ucm3gises2g7s47d5nd3e3tqa - svelte-preprocess: 4.10.7_vsntmwrrlk5avk6zexsfqc76hy + svelte: 3.55.1 + svelte-check: 2.10.3_mraflicfyjy3x4taxigiwsr23i + svelte-preprocess: 4.10.7_kmnkm63hwcse26ffcjvrch7uda tslib: 2.4.1 typescript: 4.9.4 vite: 4.0.4_ovmyjmuuyckt3r3gpaexj2onji @@ -360,6 +362,10 @@ packages: resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==} dev: true + /@iconify/types/2.0.0: + resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==} + dev: false + /@jridgewell/resolve-uri/3.1.0: resolution: {integrity: sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==} engines: {node: '>=6.0.0'} @@ -450,20 +456,20 @@ packages: resolution: {integrity: sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==} dev: true - /@rgossiaux/svelte-headlessui/1.0.2_svelte@3.55.0: + /@rgossiaux/svelte-headlessui/1.0.2_svelte@3.55.1: resolution: {integrity: sha512-sauopYTSivhzXe1kAvgawkhyYJcQlK8Li3p0d2OtcCIVprOzdbard5lbqWB4xHDv83zAobt2mR08oizO2poHLQ==} peerDependencies: svelte: ^3.44.0 dependencies: - svelte: 3.55.0 + svelte: 3.55.1 dev: true - /@rgossiaux/svelte-heroicons/0.1.2_svelte@3.55.0: + /@rgossiaux/svelte-heroicons/0.1.2_svelte@3.55.1: resolution: {integrity: sha512-c5Ep1QDvBo9HD/P0AxbXItDbn6x77fldCjjL0aBjNseUntV4fkdHkBde1IaLr8i0kmrhTSovjkIen8W83jUPzg==} peerDependencies: svelte: ^3.44.0 dependencies: - svelte: 3.55.0 + svelte: 3.55.1 dev: true /@rollup/pluginutils/4.2.1: @@ -474,21 +480,21 @@ packages: picomatch: 2.3.1 dev: true - /@sveltejs/adapter-auto/1.0.0_@sveltejs+kit@1.0.7: + /@sveltejs/adapter-auto/1.0.0_@sveltejs+kit@1.0.13: resolution: {integrity: sha512-yKyPvlLVua1bJ/42FrR3X041mFGdB4GzTZOAEoHUcNBRE5Mhx94+eqHpC3hNvAOiLEDcKfVO0ObyKSu7qldU+w==} peerDependencies: '@sveltejs/kit': ^1.0.0 dependencies: - '@sveltejs/kit': 1.0.7_svelte@3.55.0+vite@4.0.4 + '@sveltejs/kit': 1.0.13_svelte@3.55.1+vite@4.0.4 import-meta-resolve: 2.2.0 dev: true - /@sveltejs/adapter-vercel/1.0.1_@sveltejs+kit@1.0.7: - resolution: {integrity: sha512-2v06K1dKC8VmQnB8P/dAdBuNSQYvJbhBkCFpiBptkptoYMcSZnT2fYqsmtoUJDn13ACDQttorcFIQkf0BeFMQw==} + /@sveltejs/adapter-vercel/1.0.2_@sveltejs+kit@1.0.13: + resolution: {integrity: sha512-Ms2cTlqpA8Rf6Pl8GuqC6bLoMdA30W688+wV8i6DcHlLO3Z9NBEZET2jF+tEmRF1jrxxAWEDngdQBfs25eOBxw==} peerDependencies: '@sveltejs/kit': ^1.0.0 dependencies: - '@sveltejs/kit': 1.0.7_svelte@3.55.0+vite@4.0.4 + '@sveltejs/kit': 1.0.13_svelte@3.55.1+vite@4.0.4 '@vercel/nft': 0.22.6 esbuild: 0.16.8 transitivePeerDependencies: @@ -496,8 +502,8 @@ packages: - supports-color dev: true - /@sveltejs/kit/1.0.7_svelte@3.55.0+vite@4.0.4: - resolution: {integrity: sha512-u8JS4aXFWlrnu/tjl+EhJ/FvBEjLYDyMaLe7EAU4sW+PfDqnqyHBAPg/IQi5JuBg6l+Z816F4WrTe+zplUTQDg==} + /@sveltejs/kit/1.0.13_svelte@3.55.1+vite@4.0.4: + resolution: {integrity: sha512-AuHqAojgg+tL9lXSQKkB1VjadFDW+vwOoWLq+BU8pAgFvZMlh3rGCyEdPbEgE3V6pwWn/+37AOrA8fILMHWzRQ==} engines: {node: ^16.14 || >=18} hasBin: true requiresBuild: true @@ -505,7 +511,7 @@ packages: svelte: ^3.54.0 vite: ^4.0.0 dependencies: - '@sveltejs/vite-plugin-svelte': 2.0.2_svelte@3.55.0+vite@4.0.4 + '@sveltejs/vite-plugin-svelte': 2.0.2_svelte@3.55.1+vite@4.0.4 '@types/cookie': 0.5.1 cookie: 0.5.0 devalue: 4.2.0 @@ -516,15 +522,15 @@ packages: sade: 1.8.1 set-cookie-parser: 2.5.1 sirv: 2.0.2 - svelte: 3.55.0 + svelte: 3.55.1 tiny-glob: 0.2.9 - undici: 5.14.0 + undici: 5.15.0 vite: 4.0.4_ovmyjmuuyckt3r3gpaexj2onji transitivePeerDependencies: - supports-color dev: true - /@sveltejs/vite-plugin-svelte/2.0.2_svelte@3.55.0+vite@4.0.4: + /@sveltejs/vite-plugin-svelte/2.0.2_svelte@3.55.1+vite@4.0.4: resolution: {integrity: sha512-xCEan0/NNpQuL0l5aS42FjwQ6wwskdxC3pW1OeFtEKNZwRg7Evro9lac9HesGP6TdFsTv2xMes5ASQVKbCacxg==} engines: {node: ^14.18.0 || >= 16} peerDependencies: @@ -535,8 +541,8 @@ packages: deepmerge: 4.2.2 kleur: 4.1.5 magic-string: 0.27.0 - svelte: 3.55.0 - svelte-hmr: 0.15.1_svelte@3.55.0 + svelte: 3.55.1 + svelte-hmr: 0.15.1_svelte@3.55.1 vite: 4.0.4_ovmyjmuuyckt3r3gpaexj2onji vitefu: 0.2.4_vite@4.0.4 transitivePeerDependencies: @@ -583,8 +589,8 @@ packages: resolution: {integrity: sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==} dev: true - /@typescript-eslint/eslint-plugin/5.48.0_k73wpmdolxikpyqun3p36akaaq: - resolution: {integrity: sha512-SVLafp0NXpoJY7ut6VFVUU9I+YeFsDzeQwtK0WZ+xbRN3mtxJ08je+6Oi2N89qDn087COdO0u3blKZNv9VetRQ==} + /@typescript-eslint/eslint-plugin/5.48.1_3jon24igvnqaqexgwtxk6nkpse: + resolution: {integrity: sha512-9nY5K1Rp2ppmpb9s9S2aBiF3xo5uExCehMDmYmmFqqyxgenbHJ3qbarcLt4ITgaD6r/2ypdlcFRdcuVPnks+fQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: '@typescript-eslint/parser': ^5.0.0 @@ -594,10 +600,10 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.48.0_iukboom6ndih5an6iafl45j2fe - '@typescript-eslint/scope-manager': 5.48.0 - '@typescript-eslint/type-utils': 5.48.0_iukboom6ndih5an6iafl45j2fe - '@typescript-eslint/utils': 5.48.0_iukboom6ndih5an6iafl45j2fe + '@typescript-eslint/parser': 5.48.1_iukboom6ndih5an6iafl45j2fe + '@typescript-eslint/scope-manager': 5.48.1 + '@typescript-eslint/type-utils': 5.48.1_iukboom6ndih5an6iafl45j2fe + '@typescript-eslint/utils': 5.48.1_iukboom6ndih5an6iafl45j2fe debug: 4.3.4 eslint: 8.31.0 ignore: 5.2.1 @@ -610,8 +616,8 @@ packages: - supports-color dev: true - /@typescript-eslint/parser/5.48.0_iukboom6ndih5an6iafl45j2fe: - resolution: {integrity: sha512-1mxNA8qfgxX8kBvRDIHEzrRGrKHQfQlbW6iHyfHYS0Q4X1af+S6mkLNtgCOsGVl8+/LUPrqdHMssAemkrQ01qg==} + /@typescript-eslint/parser/5.48.1_iukboom6ndih5an6iafl45j2fe: + resolution: {integrity: sha512-4yg+FJR/V1M9Xoq56SF9Iygqm+r5LMXvheo6DQ7/yUWynQ4YfCRnsKuRgqH4EQ5Ya76rVwlEpw4Xu+TgWQUcdA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 @@ -620,9 +626,9 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 5.48.0 - '@typescript-eslint/types': 5.48.0 - '@typescript-eslint/typescript-estree': 5.48.0_typescript@4.9.4 + '@typescript-eslint/scope-manager': 5.48.1 + '@typescript-eslint/types': 5.48.1 + '@typescript-eslint/typescript-estree': 5.48.1_typescript@4.9.4 debug: 4.3.4 eslint: 8.31.0 typescript: 4.9.4 @@ -630,16 +636,16 @@ packages: - supports-color dev: true - /@typescript-eslint/scope-manager/5.48.0: - resolution: {integrity: sha512-0AA4LviDtVtZqlyUQnZMVHydDATpD9SAX/RC5qh6cBd3xmyWvmXYF+WT1oOmxkeMnWDlUVTwdODeucUnjz3gow==} + /@typescript-eslint/scope-manager/5.48.1: + resolution: {integrity: sha512-S035ueRrbxRMKvSTv9vJKIWgr86BD8s3RqoRZmsSh/s8HhIs90g6UlK8ZabUSjUZQkhVxt7nmZ63VJ9dcZhtDQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.48.0 - '@typescript-eslint/visitor-keys': 5.48.0 + '@typescript-eslint/types': 5.48.1 + '@typescript-eslint/visitor-keys': 5.48.1 dev: true - /@typescript-eslint/type-utils/5.48.0_iukboom6ndih5an6iafl45j2fe: - resolution: {integrity: sha512-vbtPO5sJyFjtHkGlGK4Sthmta0Bbls4Onv0bEqOGm7hP9h8UpRsHJwsrCiWtCUndTRNQO/qe6Ijz9rnT/DB+7g==} + /@typescript-eslint/type-utils/5.48.1_iukboom6ndih5an6iafl45j2fe: + resolution: {integrity: sha512-Hyr8HU8Alcuva1ppmqSYtM/Gp0q4JOp1F+/JH5D1IZm/bUBrV0edoewQZiEc1r6I8L4JL21broddxK8HAcZiqQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: '*' @@ -648,8 +654,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 5.48.0_typescript@4.9.4 - '@typescript-eslint/utils': 5.48.0_iukboom6ndih5an6iafl45j2fe + '@typescript-eslint/typescript-estree': 5.48.1_typescript@4.9.4 + '@typescript-eslint/utils': 5.48.1_iukboom6ndih5an6iafl45j2fe debug: 4.3.4 eslint: 8.31.0 tsutils: 3.21.0_typescript@4.9.4 @@ -658,13 +664,13 @@ packages: - supports-color dev: true - /@typescript-eslint/types/5.48.0: - resolution: {integrity: sha512-UTe67B0Ypius0fnEE518NB2N8gGutIlTojeTg4nt0GQvikReVkurqxd2LvYa9q9M5MQ6rtpNyWTBxdscw40Xhw==} + /@typescript-eslint/types/5.48.1: + resolution: {integrity: sha512-xHyDLU6MSuEEdIlzrrAerCGS3T7AA/L8Hggd0RCYBi0w3JMvGYxlLlXHeg50JI9Tfg5MrtsfuNxbS/3zF1/ATg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/typescript-estree/5.48.0_typescript@4.9.4: - resolution: {integrity: sha512-7pjd94vvIjI1zTz6aq/5wwE/YrfIyEPLtGJmRfyNR9NYIW+rOvzzUv3Cmq2hRKpvt6e9vpvPUQ7puzX7VSmsEw==} + /@typescript-eslint/typescript-estree/5.48.1_typescript@4.9.4: + resolution: {integrity: sha512-Hut+Osk5FYr+sgFh8J/FHjqX6HFcDzTlWLrFqGoK5kVUN3VBHF/QzZmAsIXCQ8T/W9nQNBTqalxi1P3LSqWnRA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: typescript: '*' @@ -672,8 +678,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 5.48.0 - '@typescript-eslint/visitor-keys': 5.48.0 + '@typescript-eslint/types': 5.48.1 + '@typescript-eslint/visitor-keys': 5.48.1 debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 @@ -684,17 +690,17 @@ packages: - supports-color dev: true - /@typescript-eslint/utils/5.48.0_iukboom6ndih5an6iafl45j2fe: - resolution: {integrity: sha512-x2jrMcPaMfsHRRIkL+x96++xdzvrdBCnYRd5QiW5Wgo1OB4kDYPbC1XjWP/TNqlfK93K/lUL92erq5zPLgFScQ==} + /@typescript-eslint/utils/5.48.1_iukboom6ndih5an6iafl45j2fe: + resolution: {integrity: sha512-SmQuSrCGUOdmGMwivW14Z0Lj8dxG1mOFZ7soeJ0TQZEJcs3n5Ndgkg0A4bcMFzBELqLJ6GTHnEU+iIoaD6hFGA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: '@types/json-schema': 7.0.11 '@types/semver': 7.3.13 - '@typescript-eslint/scope-manager': 5.48.0 - '@typescript-eslint/types': 5.48.0 - '@typescript-eslint/typescript-estree': 5.48.0_typescript@4.9.4 + '@typescript-eslint/scope-manager': 5.48.1 + '@typescript-eslint/types': 5.48.1 + '@typescript-eslint/typescript-estree': 5.48.1_typescript@4.9.4 eslint: 8.31.0 eslint-scope: 5.1.1 eslint-utils: 3.0.0_eslint@8.31.0 @@ -704,11 +710,11 @@ packages: - typescript dev: true - /@typescript-eslint/visitor-keys/5.48.0: - resolution: {integrity: sha512-5motVPz5EgxQ0bHjut3chzBkJ3Z3sheYVcSwS5BpHZpLqSptSmELNtGixmgj65+rIfhvtQTz5i9OP2vtzdDH7Q==} + /@typescript-eslint/visitor-keys/5.48.1: + resolution: {integrity: sha512-Ns0XBwmfuX7ZknznfXozgnydyR8F6ev/KEGePP4i74uL3ArsKbEhJ7raeKr1JSa997DBDwol/4a0Y+At82c9dA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.48.0 + '@typescript-eslint/types': 5.48.1 eslint-visitor-keys: 3.3.0 dev: true @@ -1117,14 +1123,14 @@ packages: eslint: 8.31.0 dev: true - /eslint-plugin-svelte3/4.0.0_6go7qzsvzihesfwmyvq3tnl5qq: + /eslint-plugin-svelte3/4.0.0_btuntbn75dxkba3nofpps2nvzm: resolution: {integrity: sha512-OIx9lgaNzD02+MDFNLw0GEUbuovNcglg+wnd/UY0fbZmlQSz7GlQiQ1f+yX0XvC07XPcDOnFcichqI3xCwp71g==} peerDependencies: eslint: '>=8.0.0' svelte: ^3.2.0 dependencies: eslint: 8.31.0 - svelte: 3.55.0 + svelte: 3.55.1 dev: true /eslint-scope/5.1.1: @@ -1463,6 +1469,12 @@ packages: - supports-color dev: true + /iconify-icon/1.0.2: + resolution: {integrity: sha512-mehAvz2a4eUAlPo76Wul4zzsPNr3hbOHiauMhPrTVIdLOt0AnccnNloh1EeTO3tYeBv7iaJZfdCPHczvi+CkXQ==} + dependencies: + '@iconify/types': 2.0.0 + dev: false + /ignore/5.2.1: resolution: {integrity: sha512-d2qQLzTJ9WxQftPAuEQpSPmKqzxePjzVbpAVv62AQ64NTL+wR4JkrVqR/LqFsFEUsHDAiId52mJteHDFuDkElA==} engines: {node: '>= 4'} @@ -1990,14 +2002,14 @@ packages: engines: {node: '>= 0.8.0'} dev: true - /prettier-plugin-svelte/2.9.0_74vfyr7qjo56zgjcvkwi6gyjxm: + /prettier-plugin-svelte/2.9.0_y74x4qymbshr6ujrzcfe2sydsa: resolution: {integrity: sha512-3doBi5NO4IVgaNPtwewvrgPpqAcvNv0NwJNflr76PIGgi9nf1oguQV1Hpdm9TI2ALIQVn/9iIwLpBO5UcD2Jiw==} peerDependencies: prettier: ^1.16.4 || ^2.0.0 svelte: ^3.2.0 dependencies: prettier: 2.8.2 - svelte: 3.55.0 + svelte: 3.55.1 dev: true /prettier/2.8.2: @@ -2257,7 +2269,7 @@ packages: engines: {node: '>= 0.4'} dev: true - /svelte-check/2.10.3_2ucm3gises2g7s47d5nd3e3tqa: + /svelte-check/2.10.3_mraflicfyjy3x4taxigiwsr23i: resolution: {integrity: sha512-Nt1aWHTOKFReBpmJ1vPug0aGysqPwJh2seM1OvICfM2oeyaA62mOiy5EvkXhltGfhCcIQcq2LoE0l1CwcWPjlw==} hasBin: true peerDependencies: @@ -2269,8 +2281,8 @@ packages: import-fresh: 3.3.0 picocolors: 1.0.0 sade: 1.8.1 - svelte: 3.55.0 - svelte-preprocess: 4.10.7_vsntmwrrlk5avk6zexsfqc76hy + svelte: 3.55.1 + svelte-preprocess: 4.10.7_kmnkm63hwcse26ffcjvrch7uda typescript: 4.9.4 transitivePeerDependencies: - '@babel/core' @@ -2285,20 +2297,20 @@ packages: - sugarss dev: true - /svelte-hmr/0.15.1_svelte@3.55.0: + /svelte-hmr/0.15.1_svelte@3.55.1: resolution: {integrity: sha512-BiKB4RZ8YSwRKCNVdNxK/GfY+r4Kjgp9jCLEy0DuqAKfmQtpL38cQK3afdpjw4sqSs4PLi3jIPJIFp259NkZtA==} engines: {node: ^12.20 || ^14.13.1 || >= 16} peerDependencies: svelte: '>=3.19.0' dependencies: - svelte: 3.55.0 + svelte: 3.55.1 dev: true /svelte-lazy-loader/1.0.0: resolution: {integrity: sha512-AZD6R60vksyojn21FgXLglmBiBB9K5Dkdu0hdGrLbCaRCYT68IsWkZfRUqKhMx1IfzqWcZQ8X9y/f+Ih0oNQkQ==} dev: false - /svelte-preprocess/4.10.7_vsntmwrrlk5avk6zexsfqc76hy: + /svelte-preprocess/4.10.7_kmnkm63hwcse26ffcjvrch7uda: resolution: {integrity: sha512-sNPBnqYD6FnmdBrUmBCaqS00RyCsCpj2BG58A1JBswNF7b0OKviwxqVrOL/CKyJrLSClrSeqQv5BXNg2RUbPOw==} engines: {node: '>= 9.11.2'} requiresBuild: true @@ -2348,12 +2360,12 @@ packages: sass: 1.57.1 sorcery: 0.10.0 strip-indent: 3.0.0 - svelte: 3.55.0 + svelte: 3.55.1 typescript: 4.9.4 dev: true - /svelte/3.55.0: - resolution: {integrity: sha512-uGu2FVMlOuey4JoKHKrpZFkoYyj0VLjJdz47zX5+gVK5odxHM40RVhar9/iK2YFRVxvfg9FkhfVlR0sjeIrOiA==} + /svelte/3.55.1: + resolution: {integrity: sha512-S+87/P0Ve67HxKkEV23iCdAh/SX1xiSfjF1HOglno/YTbSTW7RniICMCofWGdJJbdjw3S+0PfFb1JtGfTXE0oQ==} engines: {node: '>= 8'} dev: true @@ -2451,8 +2463,8 @@ packages: hasBin: true dev: true - /undici/5.14.0: - resolution: {integrity: sha512-yJlHYw6yXPPsuOH0x2Ib1Km61vu4hLiRRQoafs+WUgX1vO64vgnxiCEN9dpIrhZyHFsai3F0AEj4P9zy19enEQ==} + /undici/5.15.0: + resolution: {integrity: sha512-wCAZJDyjw9Myv+Ay62LAoB+hZLPW9SmKbQkbHIhMw/acKSlpn7WohdMUc/Vd4j1iSMBO0hWwU8mjB7a5p5bl8g==} engines: {node: '>=12.18'} dependencies: busboy: 1.6.0 @@ -2618,8 +2630,8 @@ packages: engines: {node: '>=10'} dev: true - /zod-to-json-schema/3.20.1_zod@3.20.2: - resolution: {integrity: sha512-U+zmNJUKqzv92E+LdEYv0g2LxBLks4HAwfC6cue8jXby5PAeSEPGO4xV9Sl4zmLYyFvJkm0FOfOs6orUO+AI1w==} + /zod-to-json-schema/3.20.2_zod@3.20.2: + resolution: {integrity: sha512-qka3UAXmVXD8z5SHkRU89UyHp8JHJW7zc8RQCpt7QloJOn6uijwkjUm8o+M/cF1IysmKc5gxac/QeDikaQMdzQ==} peerDependencies: zod: ^3.20.0 dependencies: diff --git a/postcss.config.cjs b/postcss.config.cjs index 01f5c21..ef732c8 100644 --- a/postcss.config.cjs +++ b/postcss.config.cjs @@ -6,14 +6,16 @@ const postcssNested = require('postcss-nested'); const postcssEnvFunction = require('postcss-env-function'); const config = { - plugins: [ - autoprefixer(), - postcssMediaMinmax, - customMedia, - atImport(), - postcssNested, - postcssEnvFunction(), - ] + plugins: [ + autoprefixer(), + postcssMediaMinmax, + customMedia, + atImport(), + postcssNested, + postcssEnvFunction({ + importFrom: './environmentVariables.json' + }) + ] }; module.exports = config; diff --git a/src/lib/components/button/index.svelte b/src/lib/components/button/index.svelte index 482acd5..9d977ce 100644 --- a/src/lib/components/button/index.svelte +++ b/src/lib/components/button/index.svelte @@ -17,6 +17,7 @@ border-radius: 4px; margin: 0; padding: 1rem; + min-width: 20rem; max-width: 30rem; background-color: var(--color-btn-primary-active); } diff --git a/src/lib/stores/search.ts b/src/lib/stores/search.ts index 6f0ecb1..49c85b3 100644 --- a/src/lib/stores/search.ts +++ b/src/lib/stores/search.ts @@ -1,4 +1,4 @@ -import { writable } from 'svelte/store'; +import { writable, type Writable } from 'svelte/store'; import type { SavedGameType } from '../types'; export const createSearchStore = (data: SavedGameType[]) => { @@ -16,8 +16,10 @@ export const createSearchStore = (data: SavedGameType[]) => { }; export const searchHandler = (store) => { + console.log(`Store value: ${JSON.stringify(store)}`); + const searchTerm = store.search.toLowerCase() || ''; - store.filtered = store.data.filter((item) => { + store.filtered = store.data.filter((item: SavedGameType) => { return item.searchTerms.toLowerCase().includes(searchTerm); }); }; diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 6e95385..bdbbbeb 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -4,6 +4,7 @@ import debounce from 'just-debounce-it'; import clone from 'just-clone'; import { Toy } from '@leveluptuts/svelte-toy'; + import 'iconify-icon'; // import '../app.postcss'; import Analytics from '$lib/components/analytics.svelte'; import Header from '$lib/components/header/Header.svelte'; @@ -42,6 +43,9 @@ if (!item?.searchTerms) { item.searchTerms = `${item?.name?.toLowerCase()}`; } + if (!item?.includeInRandom) { + item.includeInRandom = false; + } } wishlistStore.addAll(wishlist); } diff --git a/src/routes/collection/+page.server.ts b/src/routes/collection/+page.server.ts new file mode 100644 index 0000000..02aeef0 --- /dev/null +++ b/src/routes/collection/+page.server.ts @@ -0,0 +1,12 @@ +export const load: PageServerLoad = async ({ fetch, url }) => { + const searchParams = Object.fromEntries(url?.searchParams); + const q = searchParams?.q; + const limit = parseInt(searchParams?.limit) || 10; + const skip = parseInt(searchParams?.skip) || 0; + + return { + q, + limit, + skip + }; +}; diff --git a/src/routes/collection/+page.svelte b/src/routes/collection/+page.svelte index 0e58f5c..ae89c03 100644 --- a/src/routes/collection/+page.svelte +++ b/src/routes/collection/+page.svelte @@ -8,6 +8,10 @@ import RemoveCollectionDialog from '$root/lib/components/dialog/RemoveCollectionDialog.svelte'; import RemoveWishlistDialog from '$root/lib/components/dialog/RemoveWishlistDialog.svelte'; import { createSearchStore, searchHandler } from '$root/lib/stores/search'; + import type { PageData } from './$types'; + + export let data: PageData; + console.log(`Page data: ${JSON.stringify(data)}`) let gameToRemove: GameType | SavedGameType; let pageSize = 10; @@ -76,7 +80,7 @@

Your Collection

- +
@@ -109,6 +113,7 @@ From c088048411b0e38888ded56238815890b6efb2f4 Mon Sep 17 00:00:00 2001 From: Bradley Shellnut Date: Sun, 15 Jan 2023 13:38:13 -0800 Subject: [PATCH 003/141] Simplify buttons on game page and reactive button text. --- .vscode/settings.json | 2 +- package.json | 1 + pnpm-lock.yaml | 12 +++++- src/routes/+layout.svelte | 2 +- src/routes/game/[id]/+page.svelte | 69 ++++++++++++++++--------------- 5 files changed, 50 insertions(+), 36 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index fbad5ce..f995fd8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "cSpell.words": ["kickstarter", "msrp"] + "cSpell.words": ["iconify", "kickstarter", "msrp"] } diff --git a/package.json b/package.json index 06db873..e4e4a99 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "format": "prettier --write --plugin-search-dir=. ." }, "devDependencies": { + "@iconify/svelte": "^3.0.1", "@playwright/test": "^1.29.2", "@rgossiaux/svelte-headlessui": "1.0.2", "@rgossiaux/svelte-heroicons": "^0.1.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3f42555..d2684ce 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2,6 +2,7 @@ lockfileVersion: 5.4 specifiers: '@fontsource/fira-mono': ^4.5.10 + '@iconify/svelte': ^3.0.1 '@leveluptuts/svelte-side-menu': ^1.0.5 '@leveluptuts/svelte-toy': ^2.0.3 '@lukeed/uuid': ^2.0.0 @@ -61,6 +62,7 @@ dependencies: zod-to-json-schema: 3.20.2_zod@3.20.2 devDependencies: + '@iconify/svelte': 3.0.1_svelte@3.55.1 '@playwright/test': 1.29.2 '@rgossiaux/svelte-headlessui': 1.0.2_svelte@3.55.1 '@rgossiaux/svelte-heroicons': 0.1.2_svelte@3.55.1 @@ -362,9 +364,17 @@ packages: resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==} dev: true + /@iconify/svelte/3.0.1_svelte@3.55.1: + resolution: {integrity: sha512-onjjl496hTXUBWJxeCxo/c5zmVHS3HnKUQv5Cqf1ZsUbY4d0wVJfSDaV1hw1m6b0BNlJCOmbpc23Q6AOO5qqKg==} + peerDependencies: + svelte: '>=3' + dependencies: + '@iconify/types': 2.0.0 + svelte: 3.55.1 + dev: true + /@iconify/types/2.0.0: resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==} - dev: false /@jridgewell/resolve-uri/3.1.0: resolution: {integrity: sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==} diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index bdbbbeb..2a6b3a6 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -4,7 +4,7 @@ import debounce from 'just-debounce-it'; import clone from 'just-clone'; import { Toy } from '@leveluptuts/svelte-toy'; - import 'iconify-icon'; + // import 'iconify-icon'; // import '../app.postcss'; import Analytics from '$lib/components/analytics.svelte'; import Header from '$lib/components/header/Header.svelte'; diff --git a/src/routes/game/[id]/+page.svelte b/src/routes/game/[id]/+page.svelte index 96647c9..f2fb8c9 100644 --- a/src/routes/game/[id]/+page.svelte +++ b/src/routes/game/[id]/+page.svelte @@ -1,6 +1,7 @@
@@ -70,50 +97,22 @@
- {#if existsInCollection} - - {:else} - - {/if} - {#if existsInWishlist} - - {:else} - - {/if} + +
diff --git a/src/lib/components/preferences/profile.svelte b/src/lib/components/preferences/profile.svelte index a2aa539..b3a35f2 100644 --- a/src/lib/components/preferences/profile.svelte +++ b/src/lib/components/preferences/profile.svelte @@ -1,7 +1,8 @@
- + \ No newline at end of file diff --git a/src/routes/search/+page.server.ts b/src/routes/search/+page.server.ts index c87f0a4..da8e3a5 100644 --- a/src/routes/search/+page.server.ts +++ b/src/routes/search/+page.server.ts @@ -6,7 +6,7 @@ import type { GameType, SearchQuery } from '$lib/types'; import { mapAPIGameToBoredGame } from '$lib/util/gameMapper'; import { search_schema } from '$lib/zodValidation'; -async function searchForGames(urlQueryParams) { +async function searchForGames(urlQueryParams: SearchQuery) { try { const url = `https://api.boardgameatlas.com/api/search${ urlQueryParams ? `?${urlQueryParams}` : '' @@ -27,7 +27,7 @@ async function searchForGames(urlQueryParams) { let totalCount = 0; if (response.ok) { const gameResponse = await response.json(); - const gameList = gameResponse?.games; + const gameList: GameType[] = gameResponse?.games; totalCount = gameResponse?.count; console.log('totalCount', totalCount); gameList.forEach((game) => { @@ -110,7 +110,8 @@ export const load = async ({ fetch, url }) => { }; export const actions: Actions = { - random: async ({ request }: RequestEvent): Promise => { + random: async ({ request }): Promise => { + const form = await superValidate(request, search_schema); const queryParams: SearchQuery = { order_by: 'rank', ascending: false, @@ -127,47 +128,9 @@ export const actions: Actions = { const urlQueryParams = new URLSearchParams(newQueryParams); - try { - const url = `https://api.boardgameatlas.com/api/search${ - urlQueryParams ? `?${urlQueryParams}` : '' - }`; - const response = await fetch(url, { - method: 'get', - headers: { - 'content-type': 'application/json' - } - }); - // console.log('board game response', response); - - if (!response.ok) { - console.log('Status not 200', response.status); - throw error(response.status); - } - - if (response.status === 200) { - const gameResponse = await response.json(); - // console.log('gameResponse', gameResponse); - const gameList = gameResponse?.games; - const totalCount = gameResponse?.count; - console.log('totalCount', totalCount); - const games: GameType[] = []; - gameList.forEach((game) => { - game.players = `${game.min_players}-${game.max_players}`; - game.playtime = `${game.min_playtime}-${game.max_playtime}`; - games.push(mapAPIGameToBoredGame(game)); - }); - - // console.log('returning from search', games) - - return { - games - }; - } - } catch (e) { - console.log(`Error searching board games ${e}`); - } return { - games: [] + form, + searchData: await searchForGames(urlQueryParams) }; } }; diff --git a/src/routes/search/+page.svelte b/src/routes/search/+page.svelte index 45839f1..62afc82 100644 --- a/src/routes/search/+page.svelte +++ b/src/routes/search/+page.svelte @@ -4,7 +4,6 @@ import TextSearch from '$lib/components/search/textSearch/index.svelte'; export let data; - const { form, errors, constraints } = superForm(data?.form); $: if (data?.searchData?.games) { gameStore.removeAll(); @@ -13,5 +12,5 @@ From c53e5ffdc0683b3784c5b1f88b638892b7c53b54 Mon Sep 17 00:00:00 2001 From: Bradley Shellnut Date: Tue, 23 May 2023 23:28:23 -0700 Subject: [PATCH 014/141] Fixing auth routes. --- src/lib/components/header/index.svelte | 46 +++---- .../components/search/textSearch/index.svelte | 4 +- src/lib/components/signin.svelte | 0 src/lib/components/signup.svelte | 113 ++++++++++++++++++ src/routes/auth/signin/+page.svelte | 2 +- src/routes/auth/signout/+page.server.ts | 4 +- src/routes/auth/signup/+page.svelte | 6 +- 7 files changed, 140 insertions(+), 35 deletions(-) create mode 100644 src/lib/components/signin.svelte create mode 100644 src/lib/components/signup.svelte diff --git a/src/lib/components/header/index.svelte b/src/lib/components/header/index.svelte index 98995d5..cd7ff9e 100644 --- a/src/lib/components/header/index.svelte +++ b/src/lib/components/header/index.svelte @@ -1,8 +1,10 @@
@@ -15,38 +17,26 @@
diff --git a/src/lib/components/search/textSearch/index.svelte b/src/lib/components/search/textSearch/index.svelte index 94d770b..df958ab 100644 --- a/src/lib/components/search/textSearch/index.svelte +++ b/src/lib/components/search/textSearch/index.svelte @@ -25,7 +25,7 @@ } export let data: Validation; - const { form, constraints, errors, enhance } = superForm(data, { + const { form, constraints, errors } = superForm(data, { onSubmit: () => { boredState.update((n) => ({ ...n, loading: true })); }, @@ -145,7 +145,7 @@ {/if} -
+
- -
-
- - -
-
- - -
-
-
diff --git a/src/lib/components/search/textSearch/index.svelte b/src/lib/components/search/textSearch/index.svelte index 7e64830..1ed169e 100644 --- a/src/lib/components/search/textSearch/index.svelte +++ b/src/lib/components/search/textSearch/index.svelte @@ -1,32 +1,21 @@ + + + +
+ + + +
+ + + \ No newline at end of file diff --git a/src/routes/(protected)/list/[id]/+page.server.ts b/src/routes/(protected)/list/[id]/+page.server.ts new file mode 100644 index 0000000..6c8b491 --- /dev/null +++ b/src/routes/(protected)/list/[id]/+page.server.ts @@ -0,0 +1,126 @@ +import { fail, redirect } from '@sveltejs/kit'; +import { superValidate } from 'sveltekit-superforms/server'; +import prisma from '$lib/prisma.js'; +import { list_game_request_schema } from '$lib/zodValidation'; + +export async function load({ params, locals }) { + const session = await locals.auth.validate(); + if (!session) { + throw redirect(302, '/auth/signin'); + } + + try { + let wishlist = await prisma.wishlist.findUnique({ + where: { + id: params.id, + AND: { + user_id: session.userId + } + }, + include: { + items: { + include: { + game: { + select: { + id: true, + name: true, + thumb_url: true + } + } + } + } + } + }); + + return { + wishlist + }; + } catch (e) { + console.error(e); + return {}; + } +} + +export const actions = { + // Add game to a wishlist + add: async (event) => { + const { params, locals, request } = event; + const form = await superValidate(event, modifyListGameSchema); + + const session = await locals.auth.validate(); + if (!session) { + throw redirect(302, '/auth/signin'); + } + + let game = await prisma.game.findUnique({ + where: { + id: form.id + } + }); + + if (!game) { + // game = await prisma.game.create({ + // data: { + // name: form.name + // } + // }); + return fail(400, { + message: 'Game not found' + }); + } + + const wishlist = await prisma.wishlist.findUnique({ + where: { + id: params.id + } + }); + + if (wishlist?.user_id !== session.userId) { + return fail(401, { + message: 'Unauthorized' + }); + } + + if (!wishlist) { + throw redirect(302, '/404'); + } + + const wishlistItem = await prisma.wishlistItem.create({ + data: { + game_id: game.id, + wishlist_id: wishlist.id + } + }); + + if (!wishlistItem) { + return fail(500, { + message: 'Something went wrong' + }); + } + + return { + form + }; + }, + // Create new wishlist + create: async ({ params, locals, request }) => { + const session = await locals.auth.validate(); + if (!session) { + throw redirect(302, '/auth/signin'); + } + }, + // Delete a wishlist + delete: async ({ params, locals, request }) => { + const session = await locals.auth.validate(); + if (!session) { + throw redirect(302, '/auth/signin'); + } + }, + // Remove game from a wishlist + remove: async ({ params, locals, request }) => { + const session = await locals.auth.validate(); + if (!session) { + throw redirect(302, '/auth/signin'); + } + } +}; diff --git a/src/routes/(protected)/list/[id]/+page.svelte b/src/routes/(protected)/list/[id]/+page.svelte new file mode 100644 index 0000000..00ebcfd --- /dev/null +++ b/src/routes/(protected)/list/[id]/+page.svelte @@ -0,0 +1,24 @@ + + + + {`Wishlist ${wishlist.name} | Bored Game`} + + +

{wishlist.name}

+

Games on your wishlist:

+
+ {#if gamesItems.length > 0} + {#each gamesItems as game (game.id)} + + {/each} + {:else} +

Sorry no games found!

+ {/if} +
\ No newline at end of file diff --git a/src/routes/(protected)/wishlist/+page.server.ts b/src/routes/(protected)/wishlist/+page.server.ts index 8b785a7..195ad65 100644 --- a/src/routes/(protected)/wishlist/+page.server.ts +++ b/src/routes/(protected)/wishlist/+page.server.ts @@ -1,7 +1,8 @@ -import { redirect } from '@sveltejs/kit'; +import { error, redirect } from '@sveltejs/kit'; import { superValidate } from 'sveltekit-superforms/server'; import prisma from '$lib/prisma.js'; import { list_game_request_schema } from '$lib/zodValidation'; +import { modifyListGameSchema } from '$lib/config/zod-schemas.js'; export async function load({ params, locals }) { const session = await locals.auth.validate(); @@ -9,72 +10,98 @@ export async function load({ params, locals }) { throw redirect(302, '/auth/signin'); } + console.log('Wishlist load User id', session.user); + try { - let wishlists = await prisma.wishlist.findMany({ + let wishlist = await prisma.wishlist.findUnique({ where: { - user_id: session.userId + user_id: session?.user?.userId }, include: { - items: true + items: { + include: { + game: { + select: { + id: true, + name: true, + thumb_url: true + } + } + } + } } }); - if (wishlists.length === 0) { - const wishlist = await prisma.wishlist.create({ - data: { - user_id: session.userId, - name: 'My Wishlist' - } - }); - wishlists.push(wishlist); + if (!wishlist) { + throw redirect(302, '/404'); } + console.log('wishlist', wishlist); + return { - wishlists + games: wishlist?.items }; } catch (e) { console.error(e); } + redirect(302, '/404'); } export const actions = { // Add game to a wishlist add: async (event) => { const { params, locals, request } = event; - const form = await superValidate(event, list_game_request_schema); + const form = await superValidate(event, modifyListGameSchema); - const session = await locals.auth.validate(); - if (!session) { - throw redirect(302, '/auth/signin'); - } - - let game = await prisma.game.findUnique({ - where: { - id: form.id + try { + const session = await locals.auth.validate(); + if (!session) { + throw redirect(302, '/auth/signin'); } - }); - if (!game) { - game = await prisma.game.create({ - data: { - name: form.name + let game = await prisma.game.findUnique({ + where: { + id: form.data.id } }); - throw redirect(302, '/404'); - } - if (game) { - const wishlist = await prisma.wishlist.create({ - data: { - user_id: session.userId, - name: form.name + if (!game) { + // game = await prisma.game.create({ + // data: { + // name: form.name + // } + // }); + console.log('game not found'); + throw redirect(302, '/404'); + } + + if (game) { + const wishlist = await prisma.wishlist.findUnique({ + where: { + user_id: session.user.userId + } + }); + + if (!wishlist) { + console.log('Wishlist not found'); + return error(404, 'Wishlist not found'); } - }); - } - return { - form - }; + await prisma.wishlistItem.create({ + data: { + game_id: game.id, + wishlist_id: wishlist.id + } + }); + } + + return { + form + }; + } catch (e) { + console.error(e); + return error(500, 'Something went wrong'); + } }, // Create new wishlist create: async ({ params, locals, request }) => { @@ -91,10 +118,58 @@ export const actions = { } }, // Remove game from a wishlist - remove: async ({ params, locals, request }) => { - const session = await locals.auth.validate(); - if (!session) { - throw redirect(302, '/auth/signin'); + remove: async (event) => { + const { params, locals, request } = event; + const form = await superValidate(event, modifyListGameSchema); + + try { + const session = await locals.auth.validate(); + if (!session) { + throw redirect(302, '/auth/signin'); + } + + let game = await prisma.game.findUnique({ + where: { + id: form.data.id + } + }); + + if (!game) { + // game = await prisma.game.create({ + // data: { + // name: form.name + // } + // }); + console.log('game not found'); + throw redirect(302, '/404'); + } + + if (game) { + const wishlist = await prisma.wishlist.findUnique({ + where: { + user_id: session.user.userId + } + }); + + if (!wishlist) { + console.log('Wishlist not found'); + return error(404, 'Wishlist not found'); + } + + await prisma.wishlistItem.delete({ + where: { + wishlist_id: wishlist.id, + game_id: game.id + } + }); + } + + return { + form + }; + } catch (e) { + console.error(e); + return error(500, 'Something went wrong'); } } }; diff --git a/src/routes/(protected)/wishlist/+page.svelte b/src/routes/(protected)/wishlist/+page.svelte index 635939d..ce6e60b 100644 --- a/src/routes/(protected)/wishlist/+page.svelte +++ b/src/routes/(protected)/wishlist/+page.svelte @@ -1,134 +1,22 @@ - Your Wishlist | Bored Game + {`Your Wishlist | Bored Game`} -

Your Wishlist

-{#each wishlists as wishlist} -

{wishlist.name}

-{/each} - - - + \ No newline at end of file diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 759e737..2aae69e 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -11,7 +11,6 @@ import Header from '$lib/components/header/index.svelte'; import Footer from '$lib/components/footer.svelte'; import Loading from '$lib/components/loading.svelte'; - import Transition from '$lib/components/transition/index.svelte'; import Portal from '$lib/Portal.svelte'; import { boredState } from '$lib/stores/boredState'; import { collectionStore } from '$lib/stores/collectionStore'; @@ -123,9 +122,9 @@
- + - +