From 9140765772b1dfb63a8e9ab9395f9016f61a63ae Mon Sep 17 00:00:00 2001 From: TobiZog Date: Tue, 22 Oct 2024 18:47:27 +0200 Subject: [PATCH] Streamlined stores --- software/backend/routes/concert.routes.ts | 17 ++++ software/backend/routes/location.routes.ts | 18 +++- software/src/App.vue | 4 +- software/src/data/api/bandApi.ts | 4 +- software/src/data/api/cityApi.ts | 7 -- software/src/data/api/concertApi.ts | 6 +- software/src/data/api/genreApi.ts | 7 -- software/src/data/api/locationApi.ts | 4 +- software/src/data/api/mainApi.ts | 3 +- software/src/data/api/orderApi.ts | 4 +- software/src/main.ts | 2 +- .../accountDataPage/accountDataCard.vue | 2 +- .../accountDataPage/accountManagingCard.vue | 19 +--- .../src/pages/account/loginPage/loginForm.vue | 45 ++------- .../pages/account/loginPage/registerForm.vue | 26 ++--- .../bandDetailPage/bandMemberSection.vue | 6 +- .../bands/bandDetailPage/concertSection.vue | 2 +- .../bands/bandDetailPage/gallerySection.vue | 2 +- .../src/pages/bands/bandDetailPage/index.vue | 2 +- software/src/pages/bands/bandsPage/index.vue | 2 +- .../concerts/concertBookingPage/index.vue | 4 +- .../src/pages/concerts/concertsPage/index.vue | 2 +- .../src/pages/homePage/highlightCarousel.vue | 3 - software/src/pages/homePage/index.vue | 7 +- .../locations/locationDetailPage/index.vue | 42 ++++---- .../pages/locations/locationsPage/index.vue | 6 +- .../pages/misc/basketPage/orderingDialog.vue | 1 - software/src/pages/misc/helpPage/index.vue | 9 +- .../pages/misc/preferencesPage/pageSetup.vue | 2 +- .../misc/preferencesPage/systemSetup.vue | 6 +- software/src/pages/misc/searchPage/index.vue | 97 +++++++++---------- .../src/pages/misc/searchPage/searchBar.vue | 2 +- software/src/scripts/validationRules.ts | 2 +- software/src/stores/account.store.ts | 79 ++++++++++++--- .../stores/{bandStore.ts => band.store.ts} | 9 +- software/src/stores/basket.store.ts | 32 ++++-- .../{concertStore.ts => concert.store.ts} | 21 +++- .../{feedbackStore.ts => feedback.store.ts} | 21 +++- .../{locationStore.ts => location.store.ts} | 26 ++++- ...eferencesStore.ts => preferences.store.ts} | 9 +- software/src/stores/search.store.ts | 55 +++++++++++ software/src/stores/searchStore.ts | 43 -------- software/src/stores/shopStore.ts | 60 ------------ software/src/stores/shoppingStore.ts | 48 --------- software/tsconfig.web.json | 3 +- 45 files changed, 384 insertions(+), 387 deletions(-) rename software/src/stores/{bandStore.ts => band.store.ts} (77%) rename software/src/stores/{concertStore.ts => concert.store.ts} (69%) rename software/src/stores/{feedbackStore.ts => feedback.store.ts} (98%) rename software/src/stores/{locationStore.ts => location.store.ts} (65%) rename software/src/stores/{preferencesStore.ts => preferences.store.ts} (65%) create mode 100644 software/src/stores/search.store.ts delete mode 100644 software/src/stores/searchStore.ts delete mode 100644 software/src/stores/shopStore.ts delete mode 100644 software/src/stores/shoppingStore.ts diff --git a/software/backend/routes/concert.routes.ts b/software/backend/routes/concert.routes.ts index fe83466..91bac10 100644 --- a/software/backend/routes/concert.routes.ts +++ b/software/backend/routes/concert.routes.ts @@ -7,6 +7,7 @@ import { SeatRow } from "../models/locations/seatRow.model"; import { Seat } from "../models/locations/seat.model"; import { Ticket } from "../models/ordering/ticket.model"; import { Band } from "../models/acts/band.model"; +import { Op } from "sequelize"; export const concert = Router() @@ -95,3 +96,19 @@ concert.get("/concert/:id", (req: Request, res: Response) => { res.status(200).json(concert) }) }) + + +// Concert search +concert.get("/search", (req: Request, res: Response) => { + Concert.findAll({ + where: { + name: { + [Op.substring]: req.query.value + } + }, + include: [ Band, Location ] + }) + .then(concerts => { + res.status(200).json(concerts) + }) +}) \ No newline at end of file diff --git a/software/backend/routes/location.routes.ts b/software/backend/routes/location.routes.ts index b8e19d1..b0ea789 100644 --- a/software/backend/routes/location.routes.ts +++ b/software/backend/routes/location.routes.ts @@ -93,13 +93,23 @@ location.get("/location/:urlName", (req: Request, res: Response) => { location.get("/search", (req: Request, res: Response) => { Location.findAll({ where: { - name: { - [Op.substring]: req.query.value - } + [Op.or]: [ + { + name: { + [Op.substring]: req.query.value + }, + }, + { + "$city.name$": { + [Op.substring]: req.query.value + } + } + ] }, - include: [ Concert ] + include: [ City, Concert ] }) .then(locations => { + console.log(locations) res.status(200).json(locations) }) }) \ No newline at end of file diff --git a/software/src/App.vue b/software/src/App.vue index ba9b22e..cd493f8 100644 --- a/software/src/App.vue +++ b/software/src/App.vue @@ -4,8 +4,8 @@ import { i18n } from './plugins/i18n'; import { watch } from 'vue'; import navigationAppendItems from './components/navigation/navigationAppendItems.vue'; import navigationPrependItems from './components/navigation/navigationPrependItems.vue'; -import { usePreferencesStore } from './stores/preferencesStore'; -import { useFeedbackStore } from './stores/feedbackStore'; +import { usePreferencesStore } from './stores/preferences.store'; +import { useFeedbackStore } from './stores/feedback.store'; import footerItems from './components/navigation/footerItems.vue'; import urlBar from './components/navigation/urlBar.vue'; diff --git a/software/src/data/api/bandApi.ts b/software/src/data/api/bandApi.ts index 2d54ce9..79aeddd 100644 --- a/software/src/data/api/bandApi.ts +++ b/software/src/data/api/bandApi.ts @@ -6,10 +6,10 @@ export async function fetchAllBands() { return await axios.get(BASE_URL) } -export async function getBand(bandName: string) { +export async function fetchBandByName(bandName: string) { return await axios.get(BASE_URL + '/band/' + bandName) } -export async function searchBand(searchTerm: string) { +export async function fetchBandsBySearchTerm(searchTerm: string) { return await axios.get(BASE_URL + '/search?value=' + searchTerm) } \ No newline at end of file diff --git a/software/src/data/api/cityApi.ts b/software/src/data/api/cityApi.ts index c3a0369..6b3e9d3 100644 --- a/software/src/data/api/cityApi.ts +++ b/software/src/data/api/cityApi.ts @@ -2,13 +2,6 @@ import axios from "axios" const BASE_URL = "http://localhost:3000/cities" -/** - * @deprecated Use fetchAllCities - */ -export async function getAllCities() { - return await axios.get(BASE_URL) -} - export async function fetchAllCities() { return await axios.get(BASE_URL) } \ No newline at end of file diff --git a/software/src/data/api/concertApi.ts b/software/src/data/api/concertApi.ts index ce3f194..f60bdbe 100644 --- a/software/src/data/api/concertApi.ts +++ b/software/src/data/api/concertApi.ts @@ -2,11 +2,11 @@ import axios from "axios" let BASE_URL = "http://localhost:3000/concerts" -export async function fetchConcerts() { +export async function fetchAllConcerts() { return await axios.get(BASE_URL) } -export async function fetchConcert(id: number) { +export async function fetchConcertById(id: number) { if (id != undefined) { return await axios.get(BASE_URL + "/concert/" + id) } else { @@ -27,6 +27,6 @@ export async function fetchUpcomingConcerts(nrOfConcerts: number) { return await axios.get(url) } -export async function searchConcert(searchTerm: string) { +export async function fetchConcertsBySearchTerm(searchTerm: string) { return await axios.get(BASE_URL + '/search?value=' + searchTerm) } \ No newline at end of file diff --git a/software/src/data/api/genreApi.ts b/software/src/data/api/genreApi.ts index 95258fb..395a7ae 100644 --- a/software/src/data/api/genreApi.ts +++ b/software/src/data/api/genreApi.ts @@ -2,13 +2,6 @@ import axios from "axios" let BASE_URL = "http://localhost:3000/genres" -/** - * @deprecated Use fetchAllGenres() - */ -export async function getAllGenres() { - return await axios.get(BASE_URL) -} - export async function fetchAllGenres() { return await axios.get(BASE_URL) } \ No newline at end of file diff --git a/software/src/data/api/locationApi.ts b/software/src/data/api/locationApi.ts index 27e9803..827a72b 100644 --- a/software/src/data/api/locationApi.ts +++ b/software/src/data/api/locationApi.ts @@ -6,7 +6,7 @@ export async function fetchAllLocations() { return await axios.get(BASE_URL) } -export async function getLocation(locationName: string) { +export async function fetchLocationByName(locationName: string) { return await axios.get(BASE_URL + "/location/" + locationName) } @@ -16,6 +16,6 @@ export async function fetchTopLocations(nrOfLocations: number) { return await axios.get(url) } -export async function searchLocation(searchTerm: string) { +export async function fetchLocationsBySearchTerm(searchTerm: string) { return await axios.get(BASE_URL + "/search?value=" + searchTerm) } \ No newline at end of file diff --git a/software/src/data/api/mainApi.ts b/software/src/data/api/mainApi.ts index 2371d89..be98a47 100644 --- a/software/src/data/api/mainApi.ts +++ b/software/src/data/api/mainApi.ts @@ -2,9 +2,8 @@ import axios from "axios" const BASE_URL = "http://localhost:3000/api" -export function getServerState() { +export function fetchServerState() { return axios.get(BASE_URL) - } export function resetDatabase() { diff --git a/software/src/data/api/orderApi.ts b/software/src/data/api/orderApi.ts index 407c423..2109f94 100644 --- a/software/src/data/api/orderApi.ts +++ b/software/src/data/api/orderApi.ts @@ -3,7 +3,7 @@ import { BasketItemModel } from "../models/ordering/basketItemModel" const BASE_URL = "http://localhost:3000/orders" -export async function getUserOrders(userId: number) { +export async function fetchUserOrders(userId: number) { return axios.get(BASE_URL + "/" + userId) } @@ -25,8 +25,6 @@ export async function createOrder( } } - console.log(tickets) - return axios.post(BASE_URL, { accountId: accountId, tickets: tickets, diff --git a/software/src/main.ts b/software/src/main.ts index 87abf91..fa320c1 100644 --- a/software/src/main.ts +++ b/software/src/main.ts @@ -5,7 +5,7 @@ import vuetify from './plugins/vuetify' import router from './plugins/router' import pinia from './plugins/pinia' import { i18n } from './plugins/i18n' -import { useFeedbackStore } from './stores/feedbackStore' +import { useFeedbackStore } from './stores/feedback.store' createApp(App) .use(vuetify) diff --git a/software/src/pages/account/accountDataPage/accountDataCard.vue b/software/src/pages/account/accountDataPage/accountDataCard.vue index 0823e6a..63cf581 100644 --- a/software/src/pages/account/accountDataPage/accountDataCard.vue +++ b/software/src/pages/account/accountDataPage/accountDataCard.vue @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/software/src/pages/account/loginPage/loginForm.vue b/software/src/pages/account/loginPage/loginForm.vue index e6d1f4b..8d05327 100644 --- a/software/src/pages/account/loginPage/loginForm.vue +++ b/software/src/pages/account/loginPage/loginForm.vue @@ -1,5 +1,4 @@ @@ -52,8 +29,7 @@ async function startLogin() { @@ -65,8 +41,7 @@ async function startLogin() { :label="$t('account.password')" prepend-icon="mdi-key" type="password" - v-model="password" - :error="passwordWrong" + v-model="accountStore.loginData.password" clearable /> @@ -76,7 +51,7 @@ async function startLogin() { {{ $t('account.noAccountRegister') }} @@ -84,7 +59,7 @@ async function startLogin() { {{ $t('login') }} diff --git a/software/src/pages/account/loginPage/registerForm.vue b/software/src/pages/account/loginPage/registerForm.vue index 40df432..e359b57 100644 --- a/software/src/pages/account/loginPage/registerForm.vue +++ b/software/src/pages/account/loginPage/registerForm.vue @@ -1,21 +1,21 @@ @@ -29,7 +29,7 @@ async function registerAccount() { @@ -42,7 +42,7 @@ async function registerAccount() { :label="$t('account.password')" prepend-icon="mdi-key" type="password" - v-model="newUser.password" + v-model="accountStore.registerData.password" clearable :rules="getPasswordRules()" /> @@ -54,7 +54,7 @@ async function registerAccount() { @@ -65,7 +65,7 @@ async function registerAccount() { {{ $t('account.backToLogin') }} @@ -73,7 +73,7 @@ async function registerAccount() { {{ $t('account.register') }} diff --git a/software/src/pages/bands/bandDetailPage/bandMemberSection.vue b/software/src/pages/bands/bandDetailPage/bandMemberSection.vue index 5f301cb..7d5f6f7 100644 --- a/software/src/pages/bands/bandDetailPage/bandMemberSection.vue +++ b/software/src/pages/bands/bandDetailPage/bandMemberSection.vue @@ -1,9 +1,9 @@