Client - minor refactor
This commit is contained in:
parent
72db7afe44
commit
3dc1e46329
@ -6,6 +6,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
import Footer from '@/components/Footer.vue'
|
||||
import NavBar from '@/components/NavBar.vue'
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import axios from 'axios'
|
||||
|
||||
import store from '@/store'
|
||||
import { USER_STORE } from '@/store/constants'
|
||||
import { getApiUrl } from '@/utils'
|
||||
|
@ -1,4 +1,5 @@
|
||||
import axios from 'axios'
|
||||
|
||||
import { getApiUrl } from '@/utils'
|
||||
|
||||
const api = axios.create({
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { PropType, defineComponent, ref } from 'vue'
|
||||
|
||||
import { IDropdownOption } from '@/interfaces'
|
||||
import { TDropdownOptions } from '@/types'
|
||||
|
||||
|
@ -61,8 +61,8 @@
|
||||
|
||||
import { IDropdownOption } from '@/interfaces'
|
||||
import { ROOT_STORE, USER_STORE } from '@/store/constants'
|
||||
import { useStore } from '@/use/useStore'
|
||||
import { IAuthUserProfile } from '@/store/modules/user/interfaces'
|
||||
import { useStore } from '@/use/useStore'
|
||||
import Dropdown from '@/components/Common/Dropdown.vue'
|
||||
|
||||
export default defineComponent({
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
import UserForm from '@/components/User/UserForm.vue'
|
||||
|
||||
export default defineComponent({
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
|
||||
import './registerServiceWorker'
|
||||
import App from './App.vue'
|
||||
import i18n from './i18n'
|
||||
import router from './router'
|
||||
import store from './store'
|
||||
import i18n from './i18n'
|
||||
|
||||
createApp(App).use(i18n).use(store).use(router).mount('#app')
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
|
||||
|
||||
import Dashboard from '@/views/DashBoard.vue'
|
||||
import Login from '@/views/Login.vue'
|
||||
import NotFound from '@/views/NotFound.vue'
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { createStore } from 'vuex'
|
||||
|
||||
import { IRootState } from '@/store/modules/root/interfaces'
|
||||
import root from '@/store/modules/root'
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { GetterTree } from 'vuex'
|
||||
|
||||
import { ROOT_STORE } from '@/store/constants'
|
||||
import { IRootState, IRootGetters } from '@/store/modules/root/interfaces'
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Module, ModuleTree } from 'vuex'
|
||||
|
||||
import { getters } from '@/store/modules/root/getters'
|
||||
import { IRootState } from '@/store/modules/root/interfaces'
|
||||
import { mutations } from '@/store/modules/root/mutations'
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { MutationTree } from 'vuex'
|
||||
|
||||
import { ROOT_STORE } from '@/store/constants'
|
||||
import { IRootState } from '@/store/modules/root/interfaces'
|
||||
import { TRootMutations } from '@/store/modules/root/types'
|
||||
|
@ -1,14 +1,15 @@
|
||||
import { ActionContext, ActionTree } from 'vuex'
|
||||
|
||||
import { ROOT_STORE, USER_STORE } from '@/store/constants'
|
||||
import { IRootState } from '@/store/modules/root/interfaces'
|
||||
import {
|
||||
ILoginOrRegisterData,
|
||||
IUserActions,
|
||||
IUserState,
|
||||
} from '@/store/modules/user/interfaces'
|
||||
import { IRootState } from '@/store/modules/root/interfaces'
|
||||
import { handleError } from '@/utils'
|
||||
import api from '@/api/defaultApi'
|
||||
import authApi from '@/api/authApi'
|
||||
import api from '@/api/defaultApi'
|
||||
import router from '@/router'
|
||||
|
||||
export const actions: ActionTree<IUserState, IRootState> & IUserActions = {
|
||||
|
@ -2,11 +2,13 @@ export enum UserActions {
|
||||
GET_USER_PROFILE = 'GET_USER_PROFILE',
|
||||
LOGIN_OR_REGISTER = 'LOGIN_OR_REGISTER',
|
||||
}
|
||||
|
||||
export enum UserGetters {
|
||||
AUTH_TOKEN = 'AUTH_TOKEN',
|
||||
AUTH_USER_PROFILE = 'AUTH_USER_PROFILE',
|
||||
IS_AUTHENTICATED = 'IS_AUTHENTICATED',
|
||||
}
|
||||
|
||||
export enum UserMutations {
|
||||
UPDATE_AUTH_TOKEN = 'UPDATE_AUTH_TOKEN',
|
||||
UPDATE_AUTH_USER_PROFILE = 'UPDATE_AUTH_USER_PROFILE',
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { GetterTree } from 'vuex'
|
||||
|
||||
import { USER_STORE } from '@/store/constants'
|
||||
import { IRootState } from '@/store/modules/root/interfaces'
|
||||
import { IUserGetters, IUserState } from '@/store/modules/user/interfaces'
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Module } from 'vuex'
|
||||
|
||||
import { IRootState } from '@/store/modules/root/interfaces'
|
||||
import { actions } from '@/store/modules/user/actions'
|
||||
import { getters } from '@/store/modules/user/getters'
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { ActionContext } from 'vuex'
|
||||
|
||||
import { IFormData } from '@/interfaces'
|
||||
import { USER_STORE } from '@/store/constants'
|
||||
import { IRootState } from '@/store/modules/root/interfaces'
|
||||
@ -36,15 +37,15 @@ export interface IUserState {
|
||||
authUserProfile: IAuthUserProfile
|
||||
}
|
||||
|
||||
export interface IUserGetters {
|
||||
[USER_STORE.GETTERS.AUTH_TOKEN](state: IUserState): string | null
|
||||
[USER_STORE.GETTERS.AUTH_USER_PROFILE](state: IUserState): IAuthUserProfile
|
||||
[USER_STORE.GETTERS.IS_AUTHENTICATED](state: IUserState): boolean
|
||||
}
|
||||
|
||||
export interface IUserActions {
|
||||
[USER_STORE.ACTIONS.LOGIN_OR_REGISTER](
|
||||
context: ActionContext<IUserState, IRootState>,
|
||||
data: ILoginOrRegisterData
|
||||
): void
|
||||
}
|
||||
|
||||
export interface IUserGetters {
|
||||
[USER_STORE.GETTERS.AUTH_TOKEN](state: IUserState): string | null
|
||||
[USER_STORE.GETTERS.AUTH_USER_PROFILE](state: IUserState): IAuthUserProfile
|
||||
[USER_STORE.GETTERS.IS_AUTHENTICATED](state: IUserState): boolean
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { MutationTree } from 'vuex'
|
||||
import { TUserMutations } from '@/store/modules/user/types'
|
||||
|
||||
import { USER_STORE } from '@/store/constants'
|
||||
import { IAuthUserProfile, IUserState } from '@/store/modules/user/interfaces'
|
||||
import { TUserMutations } from '@/store/modules/user/types'
|
||||
|
||||
export const mutations: MutationTree<IUserState> & TUserMutations = {
|
||||
[USER_STORE.MUTATIONS.UPDATE_AUTH_TOKEN](
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
import BikePic from '@/components/BikePic.vue'
|
||||
import LoginForm from '@/components/User/LoginForm.vue'
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import Error from '@/components/Error.vue'
|
||||
|
||||
export default defineComponent({
|
||||
|
Loading…
Reference in New Issue
Block a user