From c1208b576279e480a019d4a668f0977c91b7ce34 Mon Sep 17 00:00:00 2001 From: TobiZog Date: Fri, 6 Sep 2024 17:10:21 +0200 Subject: [PATCH] Create product cards, display all on products page --- software/backend/models/product.model.ts | 3 + software/backend/routes/api.routes.ts | 14 ++-- software/src/App.vue | 34 +++++--- software/src/data/models/categoryModel.ts | 7 ++ software/src/data/models/filterModel.ts | 4 + software/src/data/models/productModel.ts | 11 +++ software/src/pages/productsPage/filterBar.vue | 81 +++++++++++++++++++ software/src/pages/productsPage/index.vue | 41 ++++++++++ .../src/pages/productsPage/productCard.vue | 67 +++++++++++++++ .../src/pages/productsPage/productDetails.vue | 6 ++ software/src/router/routes.ts | 4 +- 11 files changed, 253 insertions(+), 19 deletions(-) create mode 100644 software/src/data/models/categoryModel.ts create mode 100644 software/src/data/models/filterModel.ts create mode 100644 software/src/data/models/productModel.ts create mode 100644 software/src/pages/productsPage/filterBar.vue create mode 100644 software/src/pages/productsPage/index.vue create mode 100644 software/src/pages/productsPage/productCard.vue create mode 100644 software/src/pages/productsPage/productDetails.vue diff --git a/software/backend/models/product.model.ts b/software/backend/models/product.model.ts index d5a1885..1487157 100644 --- a/software/backend/models/product.model.ts +++ b/software/backend/models/product.model.ts @@ -20,6 +20,9 @@ export class Product extends Model { @Column discount: number + + @Column + rating: number // Relations @BelongsTo(() => Category) diff --git a/software/backend/routes/api.routes.ts b/software/backend/routes/api.routes.ts index 1a00e8b..6513c10 100644 --- a/software/backend/routes/api.routes.ts +++ b/software/backend/routes/api.routes.ts @@ -31,13 +31,13 @@ api.get("/resetdatabase", (req: Request, res: Response, next: NextFunction) => { Product.bulkCreate( [ - { id: 0, brand: "Tuxedo", name: "Hypherion Ultra Max", price: 999.99, categoryId: 0, discount: 0 }, - { id: 1, brand: "Puma", name: "Men's Shirt", price: 14.99, categoryId: 2, discount: 0 }, - { id: 2, brand: "Puma", name: "Woman's Shirt", price: 14.99, categoryId: 2, discount: 0 }, - { id: 3, brand: "George Orwell", name: "1984", price: 9.99, categoryId: 3, discount: 0 }, - { id: 4, brand: "Johann W. Goethe", name: "Faust", price: 4.99, categoryId: 3, discount: 0 }, - { id: 5, brand: "Theodor Sturm", name: "Der Schimmelreiter", price: 4.99, categoryId: 3, discount: 0 }, - { id: 6, brand: "Aldous Huxley", name: "Brave New World", price: 7.99, categoryId: 3, discount: 0 }, + { id: 0, brand: "Tuxedo", name: "Hypherion Ultra Max", price: 999.99, categoryId: 0, discount: 10, rating: 4.6 }, + { id: 1, brand: "Puma", name: "Men's Shirt", price: 14.99, categoryId: 2, discount: 0, rating: 3.8 }, + { id: 2, brand: "Puma", name: "Woman's Shirt", price: 14.99, categoryId: 2, discount: 0, rating: 4.0 }, + { id: 3, brand: "George Orwell", name: "1984", price: 9.99, categoryId: 3, discount: 0, rating: 4.9 }, + { id: 4, brand: "Johann W. Goethe", name: "Faust", price: 4.99, categoryId: 3, discount: 0, rating: 4.2 }, + { id: 5, brand: "Theodor Sturm", name: "Der Schimmelreiter", price: 4.99, categoryId: 3, discount: 0, rating: 3.5 }, + { id: 6, brand: "Aldous Huxley", name: "Brave New World", price: 7.99, categoryId: 3, discount: 0, rating: 4.4 }, ] ) diff --git a/software/src/App.vue b/software/src/App.vue index 49c6038..1fac25f 100644 --- a/software/src/App.vue +++ b/software/src/App.vue @@ -3,17 +3,18 @@ import { ref } from 'vue'; import axios from 'axios'; import { useTheme } from 'vuetify/lib/framework.mjs'; import { useUserStore } from './data/stores/userStore'; +import vuetify from './plugins/vuetify'; const userStore = useUserStore() const categories = ref([]) const theme = useTheme() +const navRail = ref(vuetify.display.mobile) theme.global.name.value = userStore.theme function requestAllCategories() { axios.get('http://127.0.0.1:3000/categories') .then(function (response) { - console.log(response) categories.value = response.data }) } @@ -24,33 +25,46 @@ requestAllCategories()