Account Dashboard Card
This commit is contained in:
@@ -8,6 +8,15 @@ import { Exercise } from "../models/exercises/exercise.model";
|
|||||||
|
|
||||||
export const account = Router()
|
export const account = Router()
|
||||||
|
|
||||||
|
account.get("/", (req: Request, res: Response) => {
|
||||||
|
Account.findAll({
|
||||||
|
include: [ AccountRole ]
|
||||||
|
})
|
||||||
|
.then(accounts => {
|
||||||
|
res.status(200).json(accounts)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// Login user
|
// Login user
|
||||||
account.post("/login", (req: Request, res: Response) => {
|
account.post("/login", (req: Request, res: Response) => {
|
||||||
Account.findOne({
|
Account.findOne({
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ import { AccountModel } from "../models/user/accountModel"
|
|||||||
|
|
||||||
const BASE_URL = "http://localhost:3000/accounts"
|
const BASE_URL = "http://localhost:3000/accounts"
|
||||||
|
|
||||||
|
export async function fetchAllAccounts() {
|
||||||
|
return await axios.get(BASE_URL)
|
||||||
|
}
|
||||||
|
|
||||||
export async function loginAccount(username: string, password: string) {
|
export async function loginAccount(username: string, password: string) {
|
||||||
return await axios.post(BASE_URL + "/login", {
|
return await axios.post(BASE_URL + "/login", {
|
||||||
username: username,
|
username: username,
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ exerciseStore.solveExercise(2, 1)
|
|||||||
bandStore.getBands()
|
bandStore.getBands()
|
||||||
locationStore.getLocations()
|
locationStore.getLocations()
|
||||||
genreStore.getGenres()
|
genreStore.getGenres()
|
||||||
|
accountStore.getAllAccounts()
|
||||||
concertStore.getConcerts()
|
concertStore.getConcerts()
|
||||||
.then(result => {
|
.then(result => {
|
||||||
for(let concert of concertStore.concerts) {
|
for(let concert of concertStore.concerts) {
|
||||||
@@ -106,13 +107,24 @@ concertStore.getConcerts()
|
|||||||
:title="$t('account.account', 2)"
|
:title="$t('account.account', 2)"
|
||||||
icon="mdi-account"
|
icon="mdi-account"
|
||||||
>
|
>
|
||||||
|
<div class="text-h4 text-center">
|
||||||
|
{{ accountStore.accounts.length }} {{ $t('account.account', accountStore.accounts.length) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template #actions>
|
||||||
|
<outlined-button
|
||||||
|
@click="router.push('/admin/accounts')"
|
||||||
|
>
|
||||||
|
{{ $t('misc.actions.more') }}
|
||||||
|
</outlined-button>
|
||||||
|
</template>
|
||||||
</card-view>
|
</card-view>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
<v-col>
|
<v-col>
|
||||||
<card-view
|
<card-view
|
||||||
:title="$t('band.genre', 2)"
|
:title="$t('band.genre', 2)"
|
||||||
icon="mdi-account"
|
icon="mdi-music-clef-treble"
|
||||||
>
|
>
|
||||||
<div class="text-h4 text-center">
|
<div class="text-h4 text-center">
|
||||||
{{ genreStore.genres.length }} {{ $t('band.genre', 2) }}
|
{{ genreStore.genres.length }} {{ $t('band.genre', 2) }}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { defineStore } from "pinia";
|
|||||||
import { AccountModel } from "../data/models/user/accountModel";
|
import { AccountModel } from "../data/models/user/accountModel";
|
||||||
import { OrderModel } from "../data/models/ordering/orderModel";
|
import { OrderModel } from "../data/models/ordering/orderModel";
|
||||||
import { useFeedbackStore } from "./feedback.store";
|
import { useFeedbackStore } from "./feedback.store";
|
||||||
import { loginAccount, registerAccount, updateAccount } from "../data/api/accountApi";
|
import { fetchAllAccounts, loginAccount, registerAccount, updateAccount } from "../data/api/accountApi";
|
||||||
import { fetchUserOrders } from "../data/api/orderApi";
|
import { fetchUserOrders } from "../data/api/orderApi";
|
||||||
import { BannerStateEnum } from "../data/enums/bannerStateEnum";
|
import { BannerStateEnum } from "../data/enums/bannerStateEnum";
|
||||||
import { AddressModel } from "../data/models/user/addressModel";
|
import { AddressModel } from "../data/models/user/addressModel";
|
||||||
@@ -11,18 +11,23 @@ import { PaymentModel } from "../data/models/user/paymentModel";
|
|||||||
import { AccountApiModel } from "../data/models/user/accountApiModel";
|
import { AccountApiModel } from "../data/models/user/accountApiModel";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { OrderApiModel } from "@/data/models/apiEndpoints/orderApiModel";
|
import { OrderApiModel } from "@/data/models/apiEndpoints/orderApiModel";
|
||||||
|
import { LocationApiModel } from "@/data/models/locations/locationApiModel";
|
||||||
|
|
||||||
export const useAccountStore = defineStore("accountStore", {
|
export const useAccountStore = defineStore("accountStore", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
|
/** All accounts */
|
||||||
|
accounts: ref<Array<LocationApiModel>>([]),
|
||||||
|
|
||||||
/** Useraccount which is currently logged in */
|
/** Useraccount which is currently logged in */
|
||||||
userAccount: useLocalStorage("hackmycart/accountStore/userAccount", new AccountApiModel()),
|
userAccount: useLocalStorage("hackmycart/accountStore/userAccount", new AccountApiModel()),
|
||||||
|
|
||||||
/** User input on login screen */
|
/** User input on login screen */
|
||||||
|
// todo: Remove JSON!
|
||||||
loginData: ref<{ username: String, password: String}>(
|
loginData: ref<{ username: String, password: String}>(
|
||||||
{ username: "duranduran", password: "H4nn0ver" }
|
{ username: "duranduran", password: "H4nn0ver" }
|
||||||
),
|
),
|
||||||
|
|
||||||
/** */
|
/** Buffer for register data */
|
||||||
registerData: ref<AccountModel>(new AccountModel()),
|
registerData: ref<AccountModel>(new AccountModel()),
|
||||||
|
|
||||||
/** All orders of the user */
|
/** All orders of the user */
|
||||||
@@ -33,6 +38,16 @@ export const useAccountStore = defineStore("accountStore", {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
async getAllAccounts() {
|
||||||
|
this.fetchInProgress = true
|
||||||
|
|
||||||
|
fetchAllAccounts()
|
||||||
|
.then(response => {
|
||||||
|
this.accounts = response.data
|
||||||
|
this.fetchInProgress = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the login process
|
* Start the login process
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user