diff --git a/src/components/JournalView/DriverStats.vue b/src/components/JournalView/DriverStats.vue index 91ad2fb..5b06849 100644 --- a/src/components/JournalView/DriverStats.vue +++ b/src/components/JournalView/DriverStats.vue @@ -48,44 +48,15 @@ import { URLs } from '../../scripts/utils/apiURLs'; import { useStore } from '../../store/store'; export default defineComponent({ - emits: ['closeCard'], - - setup() { - const store = useStore(); - return { - store, - driverStatsName: computed(() => store.driverStatsName), - }; - }, - data() { return { test: Math.random(), lastDispatcherName: '', + store: useStore(), lastTimetables: [] as TimetableHistory[], }; }, - - watch: { - driverStatsName(value: string) { - this.fetchDispatcherStats(); - }, - }, - - methods: { - async fetchDispatcherStats() { - this.store.driverStatsData = undefined; - - if (!this.store.driverStatsName) return; - - const statsData: DriverStatsAPIData = await ( - await axios.get(`${URLs.stacjownikAPI}/api/getDriverInfo?name=${this.store.driverStatsName}`) - ).data; - - this.store.driverStatsData = statsData; - }, - }, }); diff --git a/src/components/JournalView/JournalOptions.vue b/src/components/JournalView/JournalOptions.vue index 6ad364a..76aa189 100644 --- a/src/components/JournalView/JournalOptions.vue +++ b/src/components/JournalView/JournalOptions.vue @@ -89,7 +89,9 @@ import { defineComponent, inject, PropType } from 'vue'; import imageMixin from '../../mixins/imageMixin'; import keyMixin from '../../mixins/keyMixin'; import { DataStatus } from '../../scripts/enums/DataStatus'; +import { DriverStatsAPIData } from '../../scripts/interfaces/api/DriverStatsAPIData'; import { URLs } from '../../scripts/utils/apiURLs'; +import { useStore } from '../../store/store'; import { JournalTimetableFilter } from '../../types/Journal/JournalTimetablesTypes'; import ActionButton from '../Global/ActionButton.vue'; import SelectBox from '../Global/SelectBox.vue'; @@ -124,6 +126,7 @@ export default defineComponent({ dispatcherSuggestions: [] as string[], searchTimeout: 0, + store: useStore(), DataStatus, }; @@ -138,6 +141,10 @@ export default defineComponent({ }, computed: { + driverStatsName() { + return this.store.driverStatsName; + }, + translatedSorterOptions() { return this.$props.sorterOptionIds.map((id) => ({ id, @@ -147,6 +154,11 @@ export default defineComponent({ }, watch: { + async driverStatsName(value: string) { + await this.fetchDispatcherStats(); + this.store.currentStatsTab = value ? 'driver' : 'daily'; + }, + async 'searchersValues.search-driver'(value: string | undefined) { clearTimeout(this.searchTimeout); @@ -192,6 +204,18 @@ export default defineComponent({ }, methods: { + async fetchDispatcherStats() { + this.store.driverStatsData = undefined; + + if (!this.store.driverStatsName) return; + + const statsData: DriverStatsAPIData = await ( + await axios.get(`${URLs.stacjownikAPI}/api/getDriverInfo?name=${this.store.driverStatsName}`) + ).data; + + this.store.driverStatsData = statsData; + }, + // Override keyMixin function onKeyDownFunction() { this.showOptions = !this.showOptions; diff --git a/src/components/JournalView/JournalTimetables.vue b/src/components/JournalView/JournalTimetables.vue index 5392736..791a02b 100644 --- a/src/components/JournalView/JournalTimetables.vue +++ b/src/components/JournalView/JournalTimetables.vue @@ -1,6 +1,8 @@