From 3100a050eac6df4863198797ef4625d08f698d24 Mon Sep 17 00:00:00 2001 From: arthur Date: Tue, 29 Oct 2024 17:41:19 +0100 Subject: [PATCH] feat: update trainings pages Signed-off-by: Arthur Broudoux --- package.json | 2 +- pnpm-lock.yaml | 100 +++++++++--------- src/components/global/MenuItemSidebar.svelte | 3 +- src/components/global/Sidebar.svelte | 8 +- ...ning.svelte => CreateTrainingModal.svelte} | 5 +- .../trainings/SectionTrainings.svelte | 11 +- src/routes/trainings/+page.svelte | 6 +- src/services/users.services.ts | 16 --- src/utils/constants.ts | 10 +- src/utils/types/services.ts | 5 - 10 files changed, 75 insertions(+), 91 deletions(-) rename src/components/trainings/{AddTraining.svelte => CreateTrainingModal.svelte} (89%) delete mode 100644 src/services/users.services.ts diff --git a/package.json b/package.json index d550e89..b2d3b6d 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "postcss": "^8.4.47", "prettier": "^3.3.3", "prettier-plugin-svelte": "^3.2.6", - "svelte": "5.0.0-next.259", + "svelte": "5.0.0-next.270", "svelte-check": "^4.0.2", "tailwindcss": "^3.4.13", "typescript": "^5.6.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ace5e33..e588b45 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,7 +7,7 @@ settings: dependencies: bits-ui: specifier: ^0.21.15 - version: 0.21.15(svelte@5.0.0-next.259) + version: 0.21.15(svelte@5.0.0-next.270) clsx: specifier: ^2.1.1 version: 2.1.1 @@ -19,19 +19,19 @@ dependencies: version: 0.33.0(pg@8.13.0)(postgres@3.4.4) embla-carousel-svelte: specifier: ^8.3.0 - version: 8.3.0(svelte@5.0.0-next.259) + version: 8.3.0(svelte@5.0.0-next.270) lucia: specifier: ^3.2.0 version: 3.2.0 mode-watcher: specifier: ^0.4.1 - version: 0.4.1(svelte@5.0.0-next.259) + version: 0.4.1(svelte@5.0.0-next.270) postgres: specifier: ^3.4.4 version: 3.4.4 svelte-sonner: specifier: ^0.3.28 - version: 0.3.28(svelte@5.0.0-next.259) + version: 0.3.28(svelte@5.0.0-next.270) tailwind-merge: specifier: ^2.5.2 version: 2.5.2 @@ -57,10 +57,10 @@ devDependencies: version: 5.2.6(@sveltejs/kit@2.5.28) '@sveltejs/kit': specifier: ^2.5.28 - version: 2.5.28(@sveltejs/vite-plugin-svelte@4.0.0-next.7)(svelte@5.0.0-next.259)(vite@5.4.8) + version: 2.5.28(@sveltejs/vite-plugin-svelte@4.0.0-next.7)(svelte@5.0.0-next.270)(vite@5.4.8) '@sveltejs/vite-plugin-svelte': specifier: 4.0.0-next.7 - version: 4.0.0-next.7(svelte@5.0.0-next.259)(vite@5.4.8) + version: 4.0.0-next.7(svelte@5.0.0-next.270)(vite@5.4.8) '@types/eslint': specifier: ^9.6.1 version: 9.6.1 @@ -84,16 +84,16 @@ devDependencies: version: 9.1.0(eslint@9.11.1) eslint-plugin-svelte: specifier: ^2.44.0 - version: 2.44.0(eslint@9.11.1)(svelte@5.0.0-next.259) + version: 2.44.0(eslint@9.11.1)(svelte@5.0.0-next.270) globals: specifier: ^15.9.0 version: 15.9.0 lucide-svelte: specifier: ^0.441.0 - version: 0.441.0(svelte@5.0.0-next.259) + version: 0.441.0(svelte@5.0.0-next.270) paneforge: specifier: ^0.0.6 - version: 0.0.6(svelte@5.0.0-next.259) + version: 0.0.6(svelte@5.0.0-next.270) pg: specifier: ^8.13.0 version: 8.13.0 @@ -105,13 +105,13 @@ devDependencies: version: 3.3.3 prettier-plugin-svelte: specifier: ^3.2.6 - version: 3.2.6(prettier@3.3.3)(svelte@5.0.0-next.259) + version: 3.2.6(prettier@3.3.3)(svelte@5.0.0-next.270) svelte: - specifier: 5.0.0-next.259 - version: 5.0.0-next.259 + specifier: 5.0.0-next.270 + version: 5.0.0-next.270 svelte-check: specifier: ^4.0.2 - version: 4.0.2(svelte@5.0.0-next.259)(typescript@5.6.2) + version: 4.0.2(svelte@5.0.0-next.270)(typescript@5.6.2) tailwindcss: specifier: ^3.4.13 version: 3.4.13 @@ -1137,7 +1137,7 @@ packages: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.0 - /@melt-ui/svelte@0.76.2(svelte@5.0.0-next.259): + /@melt-ui/svelte@0.76.2(svelte@5.0.0-next.270): resolution: {integrity: sha512-7SbOa11tXUS95T3fReL+dwDs5FyJtCEqrqG3inRziDws346SYLsxOQ6HmX+4BkIsQh1R8U3XNa+EMmdMt38lMA==} peerDependencies: svelte: '>=3 <5' @@ -1148,7 +1148,7 @@ packages: dequal: 2.0.3 focus-trap: 7.6.0 nanoid: 5.0.7 - svelte: 5.0.0-next.259 + svelte: 5.0.0-next.270 dev: false /@node-rs/argon2-android-arm-eabi@1.7.0: @@ -1684,7 +1684,7 @@ packages: peerDependencies: '@sveltejs/kit': ^2.0.0 dependencies: - '@sveltejs/kit': 2.5.28(@sveltejs/vite-plugin-svelte@4.0.0-next.7)(svelte@5.0.0-next.259)(vite@5.4.8) + '@sveltejs/kit': 2.5.28(@sveltejs/vite-plugin-svelte@4.0.0-next.7)(svelte@5.0.0-next.270)(vite@5.4.8) import-meta-resolve: 4.1.0 dev: true @@ -1696,11 +1696,11 @@ packages: '@rollup/plugin-commonjs': 28.0.0(rollup@4.22.4) '@rollup/plugin-json': 6.1.0(rollup@4.22.4) '@rollup/plugin-node-resolve': 15.3.0(rollup@4.22.4) - '@sveltejs/kit': 2.5.28(@sveltejs/vite-plugin-svelte@4.0.0-next.7)(svelte@5.0.0-next.259)(vite@5.4.8) + '@sveltejs/kit': 2.5.28(@sveltejs/vite-plugin-svelte@4.0.0-next.7)(svelte@5.0.0-next.270)(vite@5.4.8) rollup: 4.22.4 dev: true - /@sveltejs/kit@2.5.28(@sveltejs/vite-plugin-svelte@4.0.0-next.7)(svelte@5.0.0-next.259)(vite@5.4.8): + /@sveltejs/kit@2.5.28(@sveltejs/vite-plugin-svelte@4.0.0-next.7)(svelte@5.0.0-next.270)(vite@5.4.8): resolution: {integrity: sha512-/O7pvFGBsQPcFa9UrW8eUC5uHTOXLsUp3SN0dY6YmRAL9nfPSrJsSJk//j5vMpinSshzUjteAFcfQTU+04Ka1w==} engines: {node: '>=18.13'} hasBin: true @@ -1710,7 +1710,7 @@ packages: svelte: ^4.0.0 || ^5.0.0-next.0 vite: ^5.0.3 dependencies: - '@sveltejs/vite-plugin-svelte': 4.0.0-next.7(svelte@5.0.0-next.259)(vite@5.4.8) + '@sveltejs/vite-plugin-svelte': 4.0.0-next.7(svelte@5.0.0-next.270)(vite@5.4.8) '@types/cookie': 0.6.0 cookie: 0.6.0 devalue: 5.1.1 @@ -1722,12 +1722,12 @@ packages: sade: 1.8.1 set-cookie-parser: 2.7.0 sirv: 2.0.4 - svelte: 5.0.0-next.259 + svelte: 5.0.0-next.270 tiny-glob: 0.2.9 vite: 5.4.8(@types/node@22.7.2) dev: true - /@sveltejs/vite-plugin-svelte-inspector@3.0.0-next.3(@sveltejs/vite-plugin-svelte@4.0.0-next.7)(svelte@5.0.0-next.259)(vite@5.4.8): + /@sveltejs/vite-plugin-svelte-inspector@3.0.0-next.3(@sveltejs/vite-plugin-svelte@4.0.0-next.7)(svelte@5.0.0-next.270)(vite@5.4.8): resolution: {integrity: sha512-kuGJ2CZ5lAw3gKF8Kw0AfKtUJWbwdlDHY14K413B0MCyrzvQvsKTorwmwZcky0+QqY6RnVIZ/5FttB9bQmkLXg==} engines: {node: ^18.0.0 || ^20.0.0 || >=22} peerDependencies: @@ -1735,27 +1735,27 @@ packages: svelte: ^5.0.0-next.96 || ^5.0.0 vite: ^5.0.0 dependencies: - '@sveltejs/vite-plugin-svelte': 4.0.0-next.7(svelte@5.0.0-next.259)(vite@5.4.8) + '@sveltejs/vite-plugin-svelte': 4.0.0-next.7(svelte@5.0.0-next.270)(vite@5.4.8) debug: 4.3.7 - svelte: 5.0.0-next.259 + svelte: 5.0.0-next.270 vite: 5.4.8(@types/node@22.7.2) transitivePeerDependencies: - supports-color dev: true - /@sveltejs/vite-plugin-svelte@4.0.0-next.7(svelte@5.0.0-next.259)(vite@5.4.8): + /@sveltejs/vite-plugin-svelte@4.0.0-next.7(svelte@5.0.0-next.270)(vite@5.4.8): resolution: {integrity: sha512-yMUnAqquoayvBDztk1rWUgdtvjv7YcHgopCAB7sWl9SQht8U/7lqwTlJU0ZTAY09pFFRe6bbakd7YoiyyIvJiA==} engines: {node: ^18.0.0 || ^20.0.0 || >=22} peerDependencies: svelte: ^5.0.0-next.96 || ^5.0.0 vite: ^5.0.0 dependencies: - '@sveltejs/vite-plugin-svelte-inspector': 3.0.0-next.3(@sveltejs/vite-plugin-svelte@4.0.0-next.7)(svelte@5.0.0-next.259)(vite@5.4.8) + '@sveltejs/vite-plugin-svelte-inspector': 3.0.0-next.3(@sveltejs/vite-plugin-svelte@4.0.0-next.7)(svelte@5.0.0-next.270)(vite@5.4.8) debug: 4.3.7 deepmerge: 4.3.1 kleur: 4.1.5 magic-string: 0.30.11 - svelte: 5.0.0-next.259 + svelte: 5.0.0-next.270 vite: 5.4.8(@types/node@22.7.2) vitefu: 1.0.2(vite@5.4.8) transitivePeerDependencies: @@ -2100,15 +2100,15 @@ packages: resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} engines: {node: '>=8'} - /bits-ui@0.21.15(svelte@5.0.0-next.259): + /bits-ui@0.21.15(svelte@5.0.0-next.270): resolution: {integrity: sha512-+m5WSpJnFdCcNdXSTIVC1WYBozipO03qRh03GFWgrdxoHiolCfwW71EYG4LPCWYPG6KcTZV0Cj6iHSiZ7cdKdg==} peerDependencies: svelte: ^4.0.0 || ^5.0.0-next.118 dependencies: '@internationalized/date': 3.5.5 - '@melt-ui/svelte': 0.76.2(svelte@5.0.0-next.259) + '@melt-ui/svelte': 0.76.2(svelte@5.0.0-next.270) nanoid: 5.0.7 - svelte: 5.0.0-next.259 + svelte: 5.0.0-next.270 dev: false /brace-expansion@1.1.11: @@ -2410,14 +2410,14 @@ packages: embla-carousel: 8.3.0 dev: false - /embla-carousel-svelte@8.3.0(svelte@5.0.0-next.259): + /embla-carousel-svelte@8.3.0(svelte@5.0.0-next.270): resolution: {integrity: sha512-FW5fYpY8V2/2zkqaDv3v+Hw+c1tD0B00oK3YfZhnDggTwjt/rvv45muv2tbKrLkpLrW0+4s8UNAWscKiXJRETg==} peerDependencies: svelte: ^3.49.0 || ^4.0.0 || ^5.0.0 dependencies: embla-carousel: 8.3.0 embla-carousel-reactive-utils: 8.3.0(embla-carousel@8.3.0) - svelte: 5.0.0-next.259 + svelte: 5.0.0-next.270 dev: false /embla-carousel@8.3.0: @@ -2594,7 +2594,7 @@ packages: eslint: 9.11.1 dev: true - /eslint-plugin-svelte@2.44.0(eslint@9.11.1)(svelte@5.0.0-next.259): + /eslint-plugin-svelte@2.44.0(eslint@9.11.1)(svelte@5.0.0-next.270): resolution: {integrity: sha512-wav4MOs02vBb1WjvTCYItwJCxMkuk2Z4p+K/eyjL0N/z7ahXLP+0LtQQjiKc2ezuif7GnZLbD1F3o1VHzSvdVg==} engines: {node: ^14.17.0 || >=16.0.0} peerDependencies: @@ -2615,8 +2615,8 @@ packages: postcss-safe-parser: 6.0.0(postcss@8.4.47) postcss-selector-parser: 6.1.2 semver: 7.6.3 - svelte: 5.0.0-next.259 - svelte-eslint-parser: 0.41.1(svelte@5.0.0-next.259) + svelte: 5.0.0-next.270 + svelte-eslint-parser: 0.41.1(svelte@5.0.0-next.270) transitivePeerDependencies: - ts-node dev: true @@ -3104,12 +3104,12 @@ packages: oslo: 1.2.0 dev: false - /lucide-svelte@0.441.0(svelte@5.0.0-next.259): + /lucide-svelte@0.441.0(svelte@5.0.0-next.270): resolution: {integrity: sha512-lwckKpu4KNth7EBPWUdx7dvRaBrFC173JSdioN2WILol7nwFAPfvbGLeez8ZlnT31boj7pNT7hjvBz3ZJfmUbQ==} peerDependencies: svelte: ^3 || ^4 || ^5.0.0-next.42 dependencies: - svelte: 5.0.0-next.259 + svelte: 5.0.0-next.270 dev: true /magic-string@0.30.11: @@ -3161,12 +3161,12 @@ packages: resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==} engines: {node: '>=16 || 14 >=14.17'} - /mode-watcher@0.4.1(svelte@5.0.0-next.259): + /mode-watcher@0.4.1(svelte@5.0.0-next.270): resolution: {integrity: sha512-bNC+1NXmwEFZtziCdZSgP7HFQTpqJPcQn9GwwJQGSf6SBF3neEPYV1uRwkYuAQwbsvsXIYtzaqgedDzJ7D1mhg==} peerDependencies: svelte: ^4.0.0 || ^5.0.0-next.1 dependencies: - svelte: 5.0.0-next.259 + svelte: 5.0.0-next.270 dev: false /mri@1.2.0: @@ -3261,13 +3261,13 @@ packages: /package-json-from-dist@1.0.0: resolution: {integrity: sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==} - /paneforge@0.0.6(svelte@5.0.0-next.259): + /paneforge@0.0.6(svelte@5.0.0-next.270): resolution: {integrity: sha512-jYeN/wdREihja5c6nK3S5jritDQ+EbCqC5NrDo97qCZzZ9GkmEcN5C0ZCjF4nmhBwkDKr6tLIgz4QUKWxLXjAw==} peerDependencies: svelte: ^4.0.0 || ^5.0.0-next.1 dependencies: nanoid: 5.0.7 - svelte: 5.0.0-next.259 + svelte: 5.0.0-next.270 dev: true /parent-module@1.0.1: @@ -3516,14 +3516,14 @@ packages: engines: {node: '>= 0.8.0'} dev: true - /prettier-plugin-svelte@3.2.6(prettier@3.3.3)(svelte@5.0.0-next.259): + /prettier-plugin-svelte@3.2.6(prettier@3.3.3)(svelte@5.0.0-next.270): resolution: {integrity: sha512-Y1XWLw7vXUQQZmgv1JAEiLcErqUniAF2wO7QJsw8BVMvpLET2dI5WpEIEJx1r11iHVdSMzQxivyfrH9On9t2IQ==} peerDependencies: prettier: ^3.0.0 svelte: ^3.2.0 || ^4.0.0-next.0 || ^5.0.0-next.0 dependencies: prettier: 3.3.3 - svelte: 5.0.0-next.259 + svelte: 5.0.0-next.270 dev: true /prettier@3.3.3: @@ -3731,7 +3731,7 @@ packages: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} - /svelte-check@4.0.2(svelte@5.0.0-next.259)(typescript@5.6.2): + /svelte-check@4.0.2(svelte@5.0.0-next.270)(typescript@5.6.2): resolution: {integrity: sha512-w2yqcG9ELJe2RJCnAvB7v0OgkHhL3czzz/tVoxGFfO6y4mOrF6QHCDhXijeXzsU7LVKEwWS3Qd9tza4JBuDxqA==} engines: {node: '>= 18.0.0'} hasBin: true @@ -3744,13 +3744,13 @@ packages: fdir: 6.3.0(picomatch@2.3.1) picocolors: 1.1.0 sade: 1.8.1 - svelte: 5.0.0-next.259 + svelte: 5.0.0-next.270 typescript: 5.6.2 transitivePeerDependencies: - picomatch dev: true - /svelte-eslint-parser@0.41.1(svelte@5.0.0-next.259): + /svelte-eslint-parser@0.41.1(svelte@5.0.0-next.270): resolution: {integrity: sha512-08ndI6zTghzI8SuJAFpvMbA/haPSGn3xz19pjre19yYMw8Nw/wQJ2PrZBI/L8ijGTgtkWCQQiLLy+Z1tfaCwNA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -3764,19 +3764,19 @@ packages: espree: 9.6.1 postcss: 8.4.47 postcss-scss: 4.0.9(postcss@8.4.47) - svelte: 5.0.0-next.259 + svelte: 5.0.0-next.270 dev: true - /svelte-sonner@0.3.28(svelte@5.0.0-next.259): + /svelte-sonner@0.3.28(svelte@5.0.0-next.270): resolution: {integrity: sha512-K3AmlySeFifF/cKgsYNv5uXqMVNln0NBAacOYgmkQStLa/UoU0LhfAACU6Gr+YYC8bOCHdVmFNoKuDbMEsppJg==} peerDependencies: svelte: ^3.0.0 || ^4.0.0 || ^5.0.0-next.1 dependencies: - svelte: 5.0.0-next.259 + svelte: 5.0.0-next.270 dev: false - /svelte@5.0.0-next.259: - resolution: {integrity: sha512-trRFSjKD+11KbXerGmBT0Uc+ZSNUhxn0aQ02q9tjtig/FV24dpZlXmCrcZTZliOLS0P8JWjw6xaWgNheZZoYOg==} + /svelte@5.0.0-next.270: + resolution: {integrity: sha512-1PPYfFECNuEtltTZf6FbcjBz5T9Uv0HGbDSdjzGnGfnZoXmoAf24pPqlocJiu+JhZTdymfRZ9GFJRjCiGwzISQ==} engines: {node: '>=18'} dependencies: '@ampproject/remapping': 2.3.0 diff --git a/src/components/global/MenuItemSidebar.svelte b/src/components/global/MenuItemSidebar.svelte index e7281fa..d0dc53e 100644 --- a/src/components/global/MenuItemSidebar.svelte +++ b/src/components/global/MenuItemSidebar.svelte @@ -5,7 +5,8 @@ export let menu: MenuItemSidebar; - $: isActive = $page.url.pathname === menu.url; + $: isActive = + menu.url === "/" ? $page.url.pathname === menu.url : $page.url.pathname.startsWith(menu.url);
  • diff --git a/src/components/trainings/AddTraining.svelte b/src/components/trainings/CreateTrainingModal.svelte similarity index 89% rename from src/components/trainings/AddTraining.svelte rename to src/components/trainings/CreateTrainingModal.svelte index 8362e0f..6308eb6 100644 --- a/src/components/trainings/AddTraining.svelte +++ b/src/components/trainings/CreateTrainingModal.svelte @@ -30,8 +30,9 @@
    - v +
    diff --git a/src/components/trainings/SectionTrainings.svelte b/src/components/trainings/SectionTrainings.svelte index 8092dfe..90636de 100644 --- a/src/components/trainings/SectionTrainings.svelte +++ b/src/components/trainings/SectionTrainings.svelte @@ -1,20 +1,19 @@ -
    +
    -

    Trainings

    +

    Trainings

    - +
    -
    + diff --git a/src/routes/trainings/+page.svelte b/src/routes/trainings/+page.svelte index 3618648..bd8fb05 100644 --- a/src/routes/trainings/+page.svelte +++ b/src/routes/trainings/+page.svelte @@ -1,5 +1,3 @@ - + -
    page trainings
    +
    page trainings
    diff --git a/src/services/users.services.ts b/src/services/users.services.ts deleted file mode 100644 index be99b13..0000000 --- a/src/services/users.services.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { User } from "$utils/types/entities"; - -export async function getUser(fetch: typeof global.fetch): Promise { - try { - const response = await fetch("/api/users"); - - if (!response.ok) throw new Error("Failed to fetch user informations"); - - const user: User = await response.json(); - - return user; - } catch (error: any) { - console.error(error.message); - throw new Error("Failed during getUserInformations service"); - } -} diff --git a/src/utils/constants.ts b/src/utils/constants.ts index ea1f425..3b8f006 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -9,12 +9,12 @@ export const menuItemsSidebar: MenuItemSidebar[] = [ label: "Dashboard", url: "/", icon: House as typeof SvelteComponent + }, + { + label: "Trainings", + url: "/trainings", + icon: Medal as typeof SvelteComponent } - // { - // label: "Trainings", - // url: "/trainings", - // icon: Medal as typeof SvelteComponent - // } ]; export const habitsDataTest: Habit[] = [ diff --git a/src/utils/types/services.ts b/src/utils/types/services.ts index 7c6ca3a..66c8b6d 100644 --- a/src/utils/types/services.ts +++ b/src/utils/types/services.ts @@ -1,10 +1,5 @@ import type { Habit } from "$utils/types/entities"; -export interface ServiceResponse { - data: T | null; - error: string | null; -} - export type HabitRequest = Pick; export type IsNewDayResponse = {