app pitch types progress
This commit is contained in:
parent
2301b164fa
commit
09cb9dff14
|
|
@ -17,7 +17,6 @@ import {
|
|||
} from '@ionic/vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useStore } from 'vuex'
|
||||
import { AppStore } from '@/store';
|
||||
import {onMounted, onBeforeUnmount, ref, computed} from "vue";
|
||||
import EventBus from "./common/EventBus";
|
||||
import backendService from '@/services/BackendService'
|
||||
|
|
@ -28,7 +27,7 @@ import {
|
|||
} from 'ionicons/icons';
|
||||
|
||||
const router = useRouter();
|
||||
const store = useStore<AppStore>();
|
||||
const store = useStore();
|
||||
|
||||
const logout = () => {
|
||||
store.dispatch('auth/logout');
|
||||
|
|
|
|||
|
|
@ -5,14 +5,6 @@ class PitchTypeService extends ApiService<PitchType> {
|
|||
constructor() {
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ const pitchTypes: Module<PitchTypeState, RootState> = {
|
|||
},
|
||||
mutations: {
|
||||
initialize(state, pitchTypeList: PitchType[]) {
|
||||
// pitchTypeService.updateLocalPitchTypes(pitchTypeList);
|
||||
state.pitchTypes = pitchTypeList;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export interface PlayerState {
|
|||
|
||||
type PlayerActionContext = ActionContext<PlayerState, RootState>;
|
||||
|
||||
const pitchTypes: Module<PlayerState, RootState> = {
|
||||
const player: Module<PlayerState, RootState> = {
|
||||
namespaced: true,
|
||||
state: {player: null},
|
||||
actions: {
|
||||
|
|
@ -33,4 +33,4 @@ const pitchTypes: Module<PlayerState, RootState> = {
|
|||
}
|
||||
};
|
||||
|
||||
export default pitchTypes;
|
||||
export default player;
|
||||
|
|
|
|||
|
|
@ -20,12 +20,9 @@ import {
|
|||
IonLabel, IonBadge,
|
||||
} from '@ionic/vue';
|
||||
import {
|
||||
playOutline,
|
||||
statsChartOutline,
|
||||
personOutline,
|
||||
baseball,
|
||||
add,
|
||||
personAddOutline, baseballOutline
|
||||
baseballOutline
|
||||
} from 'ionicons/icons';
|
||||
import {useStore} from "vuex";
|
||||
import {useRouter} from "vue-router";
|
||||
|
|
@ -38,9 +35,9 @@ import PitchType from "@/types/PitchType";
|
|||
const router = useRouter();
|
||||
const store = useStore();
|
||||
|
||||
const userImage = ref(null);
|
||||
|
||||
const user = computed(() => store.state.auth.user);
|
||||
const pitchTypes = computed(() => store.state.pitchTypes.pitchTypes);
|
||||
|
||||
const isAuthenticated = computed(() => store.state.auth.isAuthenticated);
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
// const determinePitchTypeName = (id: number): string => {
|
||||
// const pitchType = store.state.pitchTypes.find((pitchType: PitchType) => pitchType.id === id);
|
||||
//
|
||||
// return pitchType?.name ?? 'Unknown';
|
||||
// }
|
||||
const determinePitchTypeName = (id: number): string => {
|
||||
const pitchType = pitchTypes.value.find((pitchType: PitchType) => pitchType.id === id);
|
||||
|
||||
return pitchType?.name ?? 'Unknown';
|
||||
}
|
||||
|
||||
const ionInfinite = (event: InfiniteScrollCustomEvent) => {
|
||||
generateItems();
|
||||
|
|
@ -122,14 +119,14 @@ generateItems();
|
|||
<ion-item v-for="(bullpen, index) in items" :key="index">
|
||||
<ion-icon aria-hidden="true" :icon="baseball" slot="start"></ion-icon>
|
||||
<ion-label>Bullpen from ({{formatDate(bullpen.startedAt)}})</ion-label>
|
||||
<!-- <ion-list v-for="(pitch, index) in bullpen.pitches" :key="index">-->
|
||||
<!-- <ion-item>-->
|
||||
<!-- <ion-icon slot="start" :icon="baseballOutline" class="icon-login"></ion-icon>-->
|
||||
<!-- <ion-label>{{determinePitchTypeName(pitch.pitchTypeId)}}</ion-label>-->
|
||||
<!-- <ion-badge>{{pitch.aimedArea}}</ion-badge>-->
|
||||
<!-- <ion-badge>{{pitch.hitArea}}</ion-badge>-->
|
||||
<!-- </ion-item>-->
|
||||
<!-- </ion-list>-->
|
||||
<ion-list v-for="(pitch, index) in bullpen.pitches" :key="index">
|
||||
<ion-item>
|
||||
<ion-icon slot="start" :icon="baseballOutline" class="icon-login"></ion-icon>
|
||||
<ion-label>{{determinePitchTypeName(pitch.pitchTypeId)}}</ion-label>
|
||||
<ion-badge>{{pitch.aimedArea}}</ion-badge>
|
||||
<ion-badge>{{pitch.hitArea}}</ion-badge>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
<ion-infinite-scroll @ionInfinite="ionInfinite">
|
||||
|
|
|
|||
|
|
@ -43,11 +43,18 @@ const store = useStore();
|
|||
const loginError = ref('');
|
||||
|
||||
const isAuthenticated = computed(() => store.state.auth.isAuthenticated);
|
||||
const user = computed(() => store.state.auth.user);
|
||||
|
||||
onMounted(() => {
|
||||
if (isAuthenticated.value) {
|
||||
router.push({path: '/home'});
|
||||
if (!isAuthenticated.value) {
|
||||
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 }) => {
|
||||
|
|
@ -57,10 +64,11 @@ const submit = handleSubmit((values, { resetForm }) => {
|
|||
password: values.password,
|
||||
}).then((user: User) => {
|
||||
return store.dispatch('player/selectPlayer', user);
|
||||
}).then(() => {
|
||||
return store.dispatch('pitchTypes/fetch');
|
||||
}).then(() => {
|
||||
resetForm();
|
||||
router.push({path: '/home'});
|
||||
// onLogin();
|
||||
}).catch(error => {
|
||||
loading.value = false;
|
||||
console.log(error);
|
||||
|
|
|
|||
Loading…
Reference in New Issue