Display concerts with card views on "All concerts" page, adding image property for tours
This commit is contained in:
7
software/src/data/api/concertApi.ts
Normal file
7
software/src/data/api/concertApi.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import axios from "axios"
|
||||
|
||||
let BASE_URL = "http://localhost:3000/concerts"
|
||||
|
||||
export async function getAllConcerts() {
|
||||
return await axios.get(BASE_URL)
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import axios from "axios"
|
||||
|
||||
let BASE_URL = "http://localhost:3000/shows"
|
||||
|
||||
export async function getAllShows() {
|
||||
return await axios.get(BASE_URL)
|
||||
}
|
||||
@@ -12,7 +12,7 @@ export class BandModel {
|
||||
logo: string
|
||||
ratings: Array<RatingModel>
|
||||
members: Array<MemberModel>
|
||||
genre: {
|
||||
genres: {
|
||||
name: string
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
import { ShowModel } from "./showModel"
|
||||
import { ConcertModel } from "./concertModel"
|
||||
|
||||
export class BasketItemModel {
|
||||
id: number = -1
|
||||
quantity: number = 1
|
||||
product: ShowModel = new ShowModel()
|
||||
concert: ConcertModel = new ConcertModel()
|
||||
|
||||
constructor(quantity: number, product: ShowModel) {
|
||||
constructor(quantity: number, concert: ConcertModel) {
|
||||
this.quantity = quantity
|
||||
this.product = product
|
||||
this.concert = concert
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LocationModel } from "./locationModel"
|
||||
|
||||
export class ShowModel {
|
||||
export class ConcertModel {
|
||||
id: number
|
||||
inStock: number
|
||||
date: string
|
||||
@@ -1,8 +1,8 @@
|
||||
import { ShowModel } from "./showModel"
|
||||
import { ConcertModel } from "./concertModel"
|
||||
|
||||
export class OrderItemModel {
|
||||
orderId: number = -1
|
||||
quantity: number = 1
|
||||
orderPrice: number = 0
|
||||
product: ShowModel
|
||||
product: ConcertModel
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import { AccountModel } from "./accountModel"
|
||||
import { BandModel } from "./bandModel"
|
||||
|
||||
export class RatingModel {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { BandModel } from "./bandModel"
|
||||
import { ShowModel } from "./showModel"
|
||||
import { ConcertModel } from "./concertModel"
|
||||
|
||||
export class TourModel {
|
||||
id: number
|
||||
name: string
|
||||
offered: boolean
|
||||
band: BandModel
|
||||
shows: Array<ShowModel>
|
||||
image: string
|
||||
shows: Array<ConcertModel>
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import { useFeedbackStore } from "./feedbackStore";
|
||||
import { BannerStateEnum } from "../enums/bannerStateEnum";
|
||||
import { addOrder } from "../api/orderApi";
|
||||
import { useAccountStore } from "./accountStore";
|
||||
import { ShowModel } from "../models/showModel";
|
||||
import { ConcertModel } from "../models/concertModel";
|
||||
import { AddressModel } from "../models/addressModel";
|
||||
import { PaymentModel } from "../models/paymentModel";
|
||||
|
||||
@@ -44,28 +44,28 @@ export const useBasketStore = defineStore('basketStore', {
|
||||
feedbackStore.changeBanner(BannerStateEnum.BASKETPRODUCTREMOVED)
|
||||
|
||||
this.itemsInBasket = this.itemsInBasket.filter((basketItemModel: BasketItemModel) =>
|
||||
basketItemModel.product.id != item.product.id
|
||||
basketItemModel.concert.id != item.concert.id
|
||||
)
|
||||
},
|
||||
|
||||
/**
|
||||
* Add an item to the basket. If the product is already in the basket, the quantity will increase
|
||||
*
|
||||
* @param show Show to add
|
||||
* @param concert Concert to add
|
||||
* @param quantity Quantity of the product
|
||||
*/
|
||||
addItemToBasket(show: ShowModel, quantity: number) {
|
||||
addItemToBasket(concert: ConcertModel, quantity: number) {
|
||||
const feedbackStore = useFeedbackStore()
|
||||
feedbackStore.changeBanner(BannerStateEnum.BASKETPRODUCTADDED)
|
||||
|
||||
// Product is already in the basket, increase number of items
|
||||
if (this.itemsInBasket.find((basketItem: BasketItemModel) =>
|
||||
basketItem.product.id == show.id))
|
||||
basketItem.concert.id == concert.id))
|
||||
{
|
||||
this.itemsInBasket.find((basketItem: BasketItemModel) =>
|
||||
basketItem.product.id == show.id).quantity += quantity
|
||||
basketItem.concert.id == concert.id).quantity += quantity
|
||||
} else {
|
||||
this.itemsInBasket.push(new BasketItemModel(quantity, show))
|
||||
this.itemsInBasket.push(new BasketItemModel(quantity, concert))
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -11,13 +11,13 @@ import { getAllGenres } from "../api/genreApi";
|
||||
import { CityModel } from "../models/cityModel";
|
||||
import { getAllCities } from "../api/cityApi";
|
||||
|
||||
export const useShowStore = defineStore("showStore", {
|
||||
export const useConcertStore = defineStore("concertStore", {
|
||||
state: () => ({
|
||||
tours: useLocalStorage<Array<TourModel>>("hackmycart/showStore/tours", []),
|
||||
bands: useLocalStorage<Array<BandModel>>("hackmycart/showStore/bands", []),
|
||||
locations: useLocalStorage<Array<LocationModel>>("hackmycart/showStore/locations", []),
|
||||
cities: useLocalStorage<Array<CityModel>>("hackmycart/showStore/cities", []),
|
||||
genres: useLocalStorage<Array<GenreModel>>("hackmycart/showStore/genres", [])
|
||||
tours: useLocalStorage<Array<TourModel>>("hackmycart/concertStore/tours", []),
|
||||
bands: useLocalStorage<Array<BandModel>>("hackmycart/concertStore/bands", []),
|
||||
locations: useLocalStorage<Array<LocationModel>>("hackmycart/concertStore/locations", []),
|
||||
cities: useLocalStorage<Array<CityModel>>("hackmycart/concertStore/cities", []),
|
||||
genres: useLocalStorage<Array<GenreModel>>("hackmycart/concertStore/genres", [])
|
||||
}),
|
||||
|
||||
actions: {
|
||||
@@ -25,6 +25,10 @@ export const useShowStore = defineStore("showStore", {
|
||||
await getAllTours()
|
||||
.then(result => {
|
||||
this.tours = result.data
|
||||
|
||||
this.tours.sort((a, b) => {
|
||||
return new Date(a.shows[0].date) < new Date(b.shows[0].date) ? -1 : 1
|
||||
})
|
||||
})
|
||||
|
||||
await getAllBands()
|
||||
@@ -5,7 +5,7 @@ import { LanguageEnum } from "../enums/languageEnum";
|
||||
|
||||
export const usePreferencesStore = defineStore('preferencesStore', {
|
||||
state: () => ({
|
||||
theme: useLocalStorage<ThemeEnum>("hackmycart/preferencesStore/theme", ThemeEnum.DARKRED),
|
||||
theme: useLocalStorage<ThemeEnum>("hackmycart/preferencesStore/theme", ThemeEnum.DARKBLUE),
|
||||
language: useLocalStorage<LanguageEnum>("hackmycart/preferencesStore/language", LanguageEnum.GERMAN)
|
||||
}),
|
||||
})
|
||||
Reference in New Issue
Block a user