app pitch types progress

This commit is contained in:
Sascha Kühl 2025-06-12 07:02:46 +02:00
parent 2301b164fa
commit 09cb9dff14
6 changed files with 30 additions and 35 deletions

View File

@ -17,7 +17,6 @@ import {
} from '@ionic/vue'; } from '@ionic/vue';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { useStore } from 'vuex' import { useStore } from 'vuex'
import { AppStore } from '@/store';
import {onMounted, onBeforeUnmount, ref, computed} from "vue"; import {onMounted, onBeforeUnmount, ref, computed} from "vue";
import EventBus from "./common/EventBus"; import EventBus from "./common/EventBus";
import backendService from '@/services/BackendService' import backendService from '@/services/BackendService'
@ -28,7 +27,7 @@ import {
} from 'ionicons/icons'; } from 'ionicons/icons';
const router = useRouter(); const router = useRouter();
const store = useStore<AppStore>(); const store = useStore();
const logout = () => { const logout = () => {
store.dispatch('auth/logout'); store.dispatch('auth/logout');

View File

@ -5,14 +5,6 @@ class PitchTypeService extends ApiService<PitchType> {
constructor() { constructor() {
super('pitch_types'); super('pitch_types');
} }
public getLocalPitchTypes(): PitchType[] {
return JSON.parse(localStorage.getItem("pitchTypes") || '""');
}
public updateLocalPitchTypes(pitchTypes: PitchType[]): void {
localStorage.setItem("pitchTypes", JSON.stringify(pitchTypes));
}
} }
export default new PitchTypeService(); export default new PitchTypeService();

View File

@ -22,7 +22,6 @@ const pitchTypes: Module<PitchTypeState, RootState> = {
}, },
mutations: { mutations: {
initialize(state, pitchTypeList: PitchType[]) { initialize(state, pitchTypeList: PitchType[]) {
// pitchTypeService.updateLocalPitchTypes(pitchTypeList);
state.pitchTypes = pitchTypeList; state.pitchTypes = pitchTypeList;
} }
} }

View File

@ -11,7 +11,7 @@ export interface PlayerState {
type PlayerActionContext = ActionContext<PlayerState, RootState>; type PlayerActionContext = ActionContext<PlayerState, RootState>;
const pitchTypes: Module<PlayerState, RootState> = { const player: Module<PlayerState, RootState> = {
namespaced: true, namespaced: true,
state: {player: null}, state: {player: null},
actions: { actions: {
@ -33,4 +33,4 @@ const pitchTypes: Module<PlayerState, RootState> = {
} }
}; };
export default pitchTypes; export default player;

View File

@ -20,12 +20,9 @@ import {
IonLabel, IonBadge, IonLabel, IonBadge,
} from '@ionic/vue'; } from '@ionic/vue';
import { import {
playOutline,
statsChartOutline,
personOutline,
baseball, baseball,
add, add,
personAddOutline, baseballOutline baseballOutline
} from 'ionicons/icons'; } from 'ionicons/icons';
import {useStore} from "vuex"; import {useStore} from "vuex";
import {useRouter} from "vue-router"; import {useRouter} from "vue-router";
@ -38,9 +35,9 @@ import PitchType from "@/types/PitchType";
const router = useRouter(); const router = useRouter();
const store = useStore(); const store = useStore();
const userImage = ref(null);
const user = computed(() => store.state.auth.user); const user = computed(() => store.state.auth.user);
const pitchTypes = computed(() => store.state.pitchTypes.pitchTypes);
const isAuthenticated = computed(() => store.state.auth.isAuthenticated); const isAuthenticated = computed(() => store.state.auth.isAuthenticated);
if (user.value === undefined || user.value === null || user.value === '') { if (user.value === undefined || user.value === null || user.value === '') {
@ -89,11 +86,11 @@ const formatDate = (date: Date) => {
return dayjs(date).format('YYYY.MM.DD HH:mm'); return dayjs(date).format('YYYY.MM.DD HH:mm');
} }
// const determinePitchTypeName = (id: number): string => { const determinePitchTypeName = (id: number): string => {
// const pitchType = store.state.pitchTypes.find((pitchType: PitchType) => pitchType.id === id); const pitchType = pitchTypes.value.find((pitchType: PitchType) => pitchType.id === id);
//
// return pitchType?.name ?? 'Unknown'; return pitchType?.name ?? 'Unknown';
// } }
const ionInfinite = (event: InfiniteScrollCustomEvent) => { const ionInfinite = (event: InfiniteScrollCustomEvent) => {
generateItems(); generateItems();
@ -122,14 +119,14 @@ generateItems();
<ion-item v-for="(bullpen, index) in items" :key="index"> <ion-item v-for="(bullpen, index) in items" :key="index">
<ion-icon aria-hidden="true" :icon="baseball" slot="start"></ion-icon> <ion-icon aria-hidden="true" :icon="baseball" slot="start"></ion-icon>
<ion-label>Bullpen from ({{formatDate(bullpen.startedAt)}})</ion-label> <ion-label>Bullpen from ({{formatDate(bullpen.startedAt)}})</ion-label>
<!-- <ion-list v-for="(pitch, index) in bullpen.pitches" :key="index">--> <ion-list v-for="(pitch, index) in bullpen.pitches" :key="index">
<!-- <ion-item>--> <ion-item>
<!-- <ion-icon slot="start" :icon="baseballOutline" class="icon-login"></ion-icon>--> <ion-icon slot="start" :icon="baseballOutline" class="icon-login"></ion-icon>
<!-- <ion-label>{{determinePitchTypeName(pitch.pitchTypeId)}}</ion-label>--> <ion-label>{{determinePitchTypeName(pitch.pitchTypeId)}}</ion-label>
<!-- <ion-badge>{{pitch.aimedArea}}</ion-badge>--> <ion-badge>{{pitch.aimedArea}}</ion-badge>
<!-- <ion-badge>{{pitch.hitArea}}</ion-badge>--> <ion-badge>{{pitch.hitArea}}</ion-badge>
<!-- </ion-item>--> </ion-item>
<!-- </ion-list>--> </ion-list>
</ion-item> </ion-item>
</ion-list> </ion-list>
<ion-infinite-scroll @ionInfinite="ionInfinite"> <ion-infinite-scroll @ionInfinite="ionInfinite">

View File

@ -43,11 +43,18 @@ const store = useStore();
const loginError = ref(''); const loginError = ref('');
const isAuthenticated = computed(() => store.state.auth.isAuthenticated); const isAuthenticated = computed(() => store.state.auth.isAuthenticated);
const user = computed(() => store.state.auth.user);
onMounted(() => { onMounted(() => {
if (isAuthenticated.value) { if (!isAuthenticated.value) {
router.push({path: '/home'}); return;
} }
console.log('User is already authenticated. Redirecting to home.', user.value);
router.push({path: '/home'});
store.dispatch('pitchTypes/fetch').then(() => {
router.push({path: '/home'});
});
}); });
const submit = handleSubmit((values, { resetForm }) => { const submit = handleSubmit((values, { resetForm }) => {
@ -57,10 +64,11 @@ const submit = handleSubmit((values, { resetForm }) => {
password: values.password, password: values.password,
}).then((user: User) => { }).then((user: User) => {
return store.dispatch('player/selectPlayer', user); return store.dispatch('player/selectPlayer', user);
}).then(() => {
return store.dispatch('pitchTypes/fetch');
}).then(() => { }).then(() => {
resetForm(); resetForm();
router.push({path: '/home'}); router.push({path: '/home'});
// onLogin();
}).catch(error => { }).catch(error => {
loading.value = false; loading.value = false;
console.log(error); console.log(error);