diff --git a/README.md b/README.md index 1ded0c2..44da621 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,20 @@ The application host it's data in a SQLite database. The access is managed by an > | `200` | `application/json` | `Array` | + +
+GET /brands (Get all Brands) + + +##### Parameters +> None + +##### Responses +> | http code | content-type | response | +> | :---: | --- | --- | +> | `200` | `application/json` | `Array` | +
+ --- #### Creating new diff --git a/misc/database.drawio b/misc/database.drawio index b0def35..12d4739 100644 --- a/misc/database.drawio +++ b/misc/database.drawio @@ -1,6 +1,6 @@ - + @@ -214,10 +214,10 @@ - + - + @@ -350,30 +350,30 @@ - + - + - + - + - + - + @@ -383,17 +383,17 @@ - + - + - + @@ -403,34 +403,37 @@ - + - + - + - + - + - + - + - + + + + diff --git a/misc/images/database.png b/misc/images/database.png index 685edf4..c06f97a 100644 Binary files a/misc/images/database.png and b/misc/images/database.png differ diff --git a/software/backend/data/accounts.json b/software/backend/data/accounts.json index 094d628..8bd5fa8 100644 --- a/software/backend/data/accounts.json +++ b/software/backend/data/accounts.json @@ -122,7 +122,7 @@ "iban": "DE41500105172184936679" } ], - "accountRoleId": 1 + "accountRoleId": 2 }, { "id": 4, diff --git a/software/backend/data/products.json b/software/backend/data/products.json index 4249766..c02684b 100644 --- a/software/backend/data/products.json +++ b/software/backend/data/products.json @@ -27,7 +27,8 @@ "thinkpad-t14s-6.avif", "thinkpad-t14s-7.avif" ], - "inStock": 5 + "inStock": 5, + "offered": true }, { "id": 1, @@ -52,7 +53,8 @@ "puma-t-shirt-men-4.jpg", "puma-t-shirt-men-5.jpg" ], - "inStock": 30 + "inStock": 30, + "offered": true }, { "id": 2, @@ -78,7 +80,8 @@ "puma-t-shirt-woman-5.jpg", "puma-t-shirt-woman-6.jpg" ], - "inStock": 30 + "inStock": 30, + "offered": true }, { "id": 3, @@ -108,7 +111,8 @@ "1984-2.webp", "1984-3.webp" ], - "inStock": 30 + "inStock": 30, + "offered": true }, { "id": 4, @@ -135,7 +139,8 @@ "brave-new-world-1.jpg", "brave-new-world-2.jpg" ], - "inStock": 30 + "inStock": 30, + "offered": true }, { "id": 5, @@ -160,7 +165,8 @@ "dell-xps-desktop-5.jpg", "dell-xps-desktop-6.jpg" ], - "inStock": 10 + "inStock": 10, + "offered": true }, { "id": 6, @@ -198,7 +204,8 @@ "fender-player-ii-jazz-bass-rw-3ts-4.jpg", "fender-player-ii-jazz-bass-rw-3ts-5.jpg" ], - "inStock": 15 + "inStock": 15, + "offered": true }, { "id": 7, @@ -239,7 +246,8 @@ "esp-lts-iron-cross-sw-5.jpg", "esp-lts-iron-cross-sw-6.jpg" ], - "inStock": 0 + "inStock": 0, + "offered": true }, { "id": 8, @@ -273,7 +281,8 @@ "pearl-decade-maple-standard-black-5.jpg", "pearl-decade-maple-standard-black-6.jpg" ], - "inStock": 4 + "inStock": 4, + "offered": true }, { "id": 9, @@ -299,7 +308,8 @@ "macbook-air-4.avif", "macbook-air-5.avif" ], - "inStock": 18 + "inStock": 18, + "offered": false } ] } \ No newline at end of file diff --git a/software/backend/models/product.model.ts b/software/backend/models/product.model.ts index cd47e72..c314c5e 100644 --- a/software/backend/models/product.model.ts +++ b/software/backend/models/product.model.ts @@ -31,6 +31,9 @@ export class Product extends Model { @Column inStock: number + @Column + offered: boolean + @Column({ type: DataType.STRING, get(): Array { diff --git a/software/backend/routes/brand.routes.ts b/software/backend/routes/brand.routes.ts new file mode 100644 index 0000000..99dbcad --- /dev/null +++ b/software/backend/routes/brand.routes.ts @@ -0,0 +1,12 @@ +import { Brand } from "../models/brand.model" +import { Request, Router, Response } from "express" + +export const brand = Router() + +// Get all brands +brand.get("/", (req: Request, res: Response) => { + Brand.findAll() + .then(brands => { + res.status(200).json(brands) + }) +}) \ No newline at end of file diff --git a/software/backend/server.ts b/software/backend/server.ts index bec88e1..910ea54 100644 --- a/software/backend/server.ts +++ b/software/backend/server.ts @@ -7,6 +7,7 @@ import { category } from './routes/category.routes' import { product } from './routes/product.routes' import { order } from './routes/order.routes' import { account } from './routes/account.routes' +import { brand } from './routes/brand.routes' const app = express() const port = 3000 @@ -35,6 +36,7 @@ app.use("/categories", category) app.use("/products", product) app.use("/orders", order) app.use("/accounts", account) +app.use("/brands", brand) // Start server diff --git a/software/src/App.vue b/software/src/App.vue index 28e0c1b..07e5fdf 100644 --- a/software/src/App.vue +++ b/software/src/App.vue @@ -5,13 +5,11 @@ import { ref, watch } from 'vue'; import vuetify from './plugins/vuetify'; import navigationItems from './components/navigationItems.vue'; import { useProductStore } from './data/stores/productStore'; -import { useCategoryStore } from './data/stores/categoryStore'; import { usePreferencesStore } from './data/stores/preferencesStore'; import { useFeedbackStore } from './data/stores/feedbackStore'; const preferencesStore = usePreferencesStore() const productStore = useProductStore() -const categoryStore = useCategoryStore() const feedbackStore = useFeedbackStore() const theme = useTheme() const navRail = ref(vuetify.display.mobile) @@ -19,7 +17,8 @@ const navRail = ref(vuetify.display.mobile) theme.global.name.value = preferencesStore.theme productStore.fetchAllProducts() -categoryStore.fetchAllCategories() +productStore.fetchAllCategories() +productStore.fetchAllBrands() // Global watcher watch(() => preferencesStore.language, () => { diff --git a/software/src/components/navigationItems.vue b/software/src/components/navigationItems.vue index 745f273..fcb3e01 100644 --- a/software/src/components/navigationItems.vue +++ b/software/src/components/navigationItems.vue @@ -61,5 +61,21 @@ const navRail = defineModel("navRail", { type: Boolean }) + + +
+ + + +
{{ $t('menu.admin.admin') }}
+
+
+ + + + + +
+ \ No newline at end of file diff --git a/software/src/data/api/brandApi.ts b/software/src/data/api/brandApi.ts new file mode 100644 index 0000000..09556dd --- /dev/null +++ b/software/src/data/api/brandApi.ts @@ -0,0 +1,7 @@ +import axios from "axios"; + +let BASE_URL = "http://localhost:3000/brands" + +export async function getAllBrands() { + return await axios.get(BASE_URL) +} diff --git a/software/src/data/models/productModel.ts b/software/src/data/models/productModel.ts index 825cd63..dce0d9a 100644 --- a/software/src/data/models/productModel.ts +++ b/software/src/data/models/productModel.ts @@ -10,7 +10,8 @@ export class ProductModel { price: number = 0 discount: number = 0 rating: number = 1 - inStock: number + inStock: number = 0 + offered: boolean = true specs: Array = [] images: Array = [""] } \ No newline at end of file diff --git a/software/src/data/stores/brandStore.ts b/software/src/data/stores/brandStore.ts new file mode 100644 index 0000000..e69de29 diff --git a/software/src/data/stores/categoryStore.ts b/software/src/data/stores/categoryStore.ts deleted file mode 100644 index 2f82935..0000000 --- a/software/src/data/stores/categoryStore.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { useLocalStorage } from "@vueuse/core"; -import { defineStore } from "pinia"; -import { CategoryModel } from "../models/categoryModel"; -import { getAllCategories } from "../api/categoryApi"; - -export const useCategoryStore = defineStore("categoryStore", { - state: () => ({ - categories: useLocalStorage>("hackmycart/categoryStore/categories", []) - }), - - actions: { - async fetchAllCategories() { - await getAllCategories() - .then(categories => { - this.categories = categories.data - }) - }, - - getProductById(id: number): CategoryModel { - return this.categories.find(category => - category.id === id - ) - } - } -}) \ No newline at end of file diff --git a/software/src/data/stores/productStore.ts b/software/src/data/stores/productStore.ts index 6ab31d5..70cfa20 100644 --- a/software/src/data/stores/productStore.ts +++ b/software/src/data/stores/productStore.ts @@ -4,6 +4,9 @@ import { getAllProducts } from "../api/productApi"; import { SortOrder } from "../enums/sortOrderEnum"; import { CategoryModel } from "../models/categoryModel"; import { ProductModel } from "../models/productModel"; +import { BrandModel } from "../models/brandModel"; +import { getAllCategories } from "../api/categoryApi"; +import { getAllBrands } from "../api/brandApi"; export const useProductStore = defineStore("productStore", { @@ -12,7 +15,9 @@ export const useProductStore = defineStore("productStore", { filteredProducts: useLocalStorage>("hackmycart/productStore/filteredProducts", []), sortOrder: useLocalStorage("hackmycart/productStore/sortOrder", SortOrder.NAMEATOZ), filteredCategory: useLocalStorage("hackmycart/productStore/filteredCategory", new CategoryModel()), - onlyDiscounts: useLocalStorage("hackmycart/productStore/onlyDiscounts", false) + onlyDiscounts: useLocalStorage("hackmycart/productStore/onlyDiscounts", false), + brands: useLocalStorage>("hackmycart/productStore/brands", []), + categories: useLocalStorage>("hackmycart/productStore/categories", []) }), actions: { @@ -24,6 +29,20 @@ export const useProductStore = defineStore("productStore", { }) }, + async fetchAllCategories() { + await getAllCategories() + .then(categories => { + this.categories = categories.data + }) + }, + + async fetchAllBrands() { + await getAllBrands() + .then(brands => { + this.brands = brands.data + }) + }, + async filterProducts() { if (this.filteredCategory.id == -1 || this.filteredCategory.id == 0) { this.filteredProducts = this.products diff --git a/software/src/locales/de.json b/software/src/locales/de.json index a88b97e..0fa315b 100644 --- a/software/src/locales/de.json +++ b/software/src/locales/de.json @@ -10,7 +10,14 @@ "helpInstructions": "Hilfestellung", "preferences": "Einstellungen", "logout": "Ausloggen", - "scoreBoard": "Score Board" + "scoreBoard": "Score Board", + "admin": { + "admin": "Administration", + "dashboard": "Dashboard", + "categories": "Kategorien", + "products": "Produkte", + "accounts": "Accounts" + } }, "preferences": { "pageSetup": "Seiteneinstellungen", @@ -29,10 +36,12 @@ "category": "Kategorie", "description": "Beschreibung", "storedItemsAvailable": "{0} verfügbar", - "soldOut": "Ausverkauft" + "soldOut": "Ausverkauft", + "discount": "Rabatt", + "inStock": "Warenbestand" }, "offers": "Angebote", - "categories": "Kategorien", + "category": "Kategorie | Kategorien", "sortBy": "Sortieren nach", "quantity": "Anzahl", "addToBasket": "Zum Warenkorb hinzufügen", @@ -133,5 +142,8 @@ "emailRequired": "E-Mail-Adresse benötigt", "tooMuchChars": "Zu lang", "digitsAtStartNeeded": "Muss mit einer Zahl beginnen", - "wrongIban": "Falsches IBAN Format, nur deutsche IBAN-Nummern erlaubt!" + "wrongIban": "Falsches IBAN Format, nur deutsche IBAN-Nummern erlaubt!", + "save": "Speichern", + "editProduct": "Produkt bearbeiten", + "brand": "Marke | Marken" } diff --git a/software/src/locales/en.json b/software/src/locales/en.json index 6fc8482..658e5be 100644 --- a/software/src/locales/en.json +++ b/software/src/locales/en.json @@ -10,7 +10,14 @@ "helpInstructions": "Help instructions", "preferences": "Preferences", "logout": "Logout", - "scoreBoard": "Score Board" + "scoreBoard": "Score Board", + "admin": { + "admin": "Administration", + "dashboard": "Dashboard", + "categories": "Categories", + "products": "Products", + "accounts": "Accounts" + } }, "preferences": { "pageSetup": "Page setup", @@ -29,10 +36,12 @@ "category": "Category", "description": "Description", "storedItemsAvailable": "{0} items available", - "soldOut": "Sold Out" + "soldOut": "Sold Out", + "discount": "Discount", + "inStock": "In Stock" }, "offers": "Offers", - "categories": "Categories", + "category": "Category | Categories", "sortBy": "Sort by", "quantity": "Quantity", "addToBasket": "Add to basket", @@ -133,5 +142,8 @@ "emailRequired": "E-Mail is required", "tooMuchChars": "Too long", "digitsAtStartNeeded": "Has to beginn with a number", - "wrongIban": "Wrong IBAN format, only German IBANs are allowed!" + "wrongIban": "Wrong IBAN format, only German IBANs are allowed!", + "save": "Save", + "editProduct": "Edit product", + "brand": "Brand | Brands" } diff --git a/software/src/pages/accountPage/addressesCard.vue b/software/src/pages/accountPage/addressesCard.vue index 8c5fe8d..d50f526 100644 --- a/software/src/pages/accountPage/addressesCard.vue +++ b/software/src/pages/accountPage/addressesCard.vue @@ -12,7 +12,7 @@ const accountStore = useAccountStore()