From 29e9dd6bdaa9259d6c518663924dd1b42d0e3340 Mon Sep 17 00:00:00 2001 From: Patryk Borowiec <56939183+Zefir12@users.noreply.github.com> Date: Wed, 24 Apr 2024 23:22:42 +0200 Subject: [PATCH] feat(addFood): added uuid's --- package.json | 2 ++ pnpm-lock.yaml | 17 ++++++++++++++++ .../supabase/services/supabaseFoodService.ts | 6 +++--- .../supabase/supabaseSchemas/supaDatabase.ts | 6 ++++++ src/pages/dashboard/store/dashboardStore.ts | 10 +++++++++- src/pages/dashboard/subviews/FoodInfoView.vue | 1 + src/pages/food/store/addFoodStore.ts | 20 ++++++++++++++++--- src/pages/food/store/newFoodStore.ts | 12 +++++------ src/pages/food/subviews/CreateNewFoodView.vue | 8 +++++++- 9 files changed, 68 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 0a5a929..ca7dfdb 100644 --- a/package.json +++ b/package.json @@ -18,10 +18,12 @@ "globals": "^15.0.0", "pinia": "^2.1.7", "primevue": "^3.50.0", + "uuid": "^9.0.1", "vue": "^3.4.21", "vue-router": "^4.3.0" }, "devDependencies": { + "@types/uuid": "^9.0.8", "@typescript-eslint/eslint-plugin": "^7.7.0", "@typescript-eslint/parser": "^7.7.0", "@vitejs/plugin-vue": "^5.0.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d8c017c..9eaa477 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,6 +26,9 @@ importers: primevue: specifier: ^3.50.0 version: 3.50.0(vue@3.4.21(typescript@5.4.3)) + uuid: + specifier: ^9.0.1 + version: 9.0.1 vue: specifier: ^3.4.21 version: 3.4.21(typescript@5.4.3) @@ -33,6 +36,9 @@ importers: specifier: ^4.3.0 version: 4.3.0(vue@3.4.21(typescript@5.4.3)) devDependencies: + '@types/uuid': + specifier: ^9.0.8 + version: 9.0.8 '@typescript-eslint/eslint-plugin': specifier: ^7.7.0 version: 7.7.0(@typescript-eslint/parser@7.7.0(eslint@9.0.0)(typescript@5.4.3))(eslint@9.0.0)(typescript@5.4.3) @@ -395,6 +401,9 @@ packages: '@types/semver@7.5.8': resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==} + '@types/uuid@9.0.8': + resolution: {integrity: sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==} + '@types/ws@8.5.10': resolution: {integrity: sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==} @@ -1074,6 +1083,10 @@ packages: util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} + uuid@9.0.1: + resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==} + hasBin: true + vite@5.2.3: resolution: {integrity: sha512-+i1oagbvkVIhEy9TnEV+fgXsng13nZM90JQbrcPrf6DvW2mXARlz+DK7DLiDP+qeKoD1FCVx/1SpFL1CLq9Mhw==} engines: {node: ^18.0.0 || >=20.0.0} @@ -1415,6 +1428,8 @@ snapshots: '@types/semver@7.5.8': {} + '@types/uuid@9.0.8': {} + '@types/ws@8.5.10': dependencies: '@types/node': 20.11.30 @@ -2138,6 +2153,8 @@ snapshots: util-deprecate@1.0.2: {} + uuid@9.0.1: {} + vite@5.2.3(@types/node@20.11.30): dependencies: esbuild: 0.20.2 diff --git a/src/lib/supabase/services/supabaseFoodService.ts b/src/lib/supabase/services/supabaseFoodService.ts index 9691090..bfadea8 100644 --- a/src/lib/supabase/services/supabaseFoodService.ts +++ b/src/lib/supabase/services/supabaseFoodService.ts @@ -5,9 +5,9 @@ export async function getFoodsWithData(startDate: Date, endDate: Date) { const { error, data } = await supabase .from("food") .select("food_amount, time_of_intake, food_types(*)") - .gt("created_at", startDate.toLocaleDateString()) - .lt("created_at", endDate.toLocaleDateString()) - .order("created_at", { ascending: false }); + .gt("time_of_intake", startDate.toLocaleDateString()) + .lt("time_of_intake", endDate.toLocaleDateString()) + .order("time_of_intake", { ascending: false }); if (error) { console.log(error); throw new Error(); diff --git a/src/lib/supabase/supabase/supabaseSchemas/supaDatabase.ts b/src/lib/supabase/supabase/supabaseSchemas/supaDatabase.ts index a0f06ea..e9e87dc 100644 --- a/src/lib/supabase/supabase/supabaseSchemas/supaDatabase.ts +++ b/src/lib/supabase/supabase/supabaseSchemas/supaDatabase.ts @@ -128,16 +128,19 @@ export type Database = { created_at: string; id: number; price: number | null; + seller_id: number | null; }; Insert: { created_at?: string; id?: number; price?: number | null; + seller_id?: number | null; }; Update: { created_at?: string; id?: number; price?: number | null; + seller_id?: number | null; }; Relationships: []; }; @@ -147,6 +150,7 @@ export type Database = { food_amount: number; food_id: number; id: number; + meal_id: string | null; time_of_intake: string | null; user_id: string | null; }; @@ -155,6 +159,7 @@ export type Database = { food_amount: number; food_id: number; id?: number; + meal_id?: string | null; time_of_intake?: string | null; user_id?: string | null; }; @@ -163,6 +168,7 @@ export type Database = { food_amount?: number; food_id?: number; id?: number; + meal_id?: string | null; time_of_intake?: string | null; user_id?: string | null; }; diff --git a/src/pages/dashboard/store/dashboardStore.ts b/src/pages/dashboard/store/dashboardStore.ts index ad9cbb5..7b5aab3 100644 --- a/src/pages/dashboard/store/dashboardStore.ts +++ b/src/pages/dashboard/store/dashboardStore.ts @@ -48,6 +48,13 @@ export const useDashboardStore = defineStore("dashboardStore", () => { }); return totalCarbs; }); + const kcal = computed(() => { + let totalKcal = 0; + foodData.value.forEach((food) => { + totalKcal += food.food_types.kcal; + }); + return totalKcal; + }); onMounted(() => { changeDay(0); @@ -60,6 +67,7 @@ export const useDashboardStore = defineStore("dashboardStore", () => { foodData, proteins, carbohydrates, - fats + fats, + kcal }; }); diff --git a/src/pages/dashboard/subviews/FoodInfoView.vue b/src/pages/dashboard/subviews/FoodInfoView.vue index 15132d5..b3433a1 100644 --- a/src/pages/dashboard/subviews/FoodInfoView.vue +++ b/src/pages/dashboard/subviews/FoodInfoView.vue @@ -2,6 +2,7 @@