some shit..

This commit is contained in:
Sockenklaus
2021-11-12 23:37:17 +01:00
parent 8204135b0f
commit de2052d136
6 changed files with 46 additions and 11 deletions

View File

@@ -2,4 +2,6 @@ import axios from 'axios'
export default axios.create({
baseURL: 'http://localhost:3333/api/v1/'
})
})
export const apiUrl = 'http://localhost:3333/api/v1/'

View File

@@ -1,5 +1,7 @@
import { defineStore } from "pinia";
import { useEmployees } from "../employees";
import { useUser } from "../user";
import axios from '@/axios'
import _clone from "lodash/clone";
import _difference from "lodash/difference";
import _pull from "lodash/pull";
@@ -40,8 +42,21 @@ export const settingsEmployeesIndex = defineStore({
* Persist columnsSelected to API
*/
async persist() {
console.log("persist")
console.log(this.columnsSelected)
const user = useUser()
const result = await axios.post('settings',
{
settings: [
{
key: "employees-index-columns-selected",
value: JSON.stringify(this.columnsSelected)
}
]
},
{
headers: user.header
})
console.log(result)
}
}
})

View File

@@ -3,7 +3,10 @@ import { useNotifications } from './notifications'
import { getUnixTime } from 'date-fns'
import { AxiosError } from 'axios'
import axios from '@/axios'
import { apiUrl } from '@/axios'
import Axios from 'axios'
import { useRequest } from 'vue-request'
import { json } from 'stream/consumers'
type AuthSuccResult = {
user: string,
@@ -34,21 +37,18 @@ export const useUser = defineStore({
actions: {
async login(username: string, password: string):
Promise<
boolean |
Promise<boolean |
'E_INVALID_AUTH_PASSWORD: Password mis-match' |
'E_INVALID_AUTH_UID: User not found'
> {
'E_INVALID_AUTH_UID: User not found'>
{
const notifications = useNotifications()
try {
const response = await axios.post<AuthSuccResult>('login', {
username: username,
password: password
})
console.log(response)
this.isLoggedIn = true
this.user = response.data.user
@@ -76,7 +76,7 @@ export const useUser = defineStore({
notifications.add('danger', err as string, -1)
return false
}
}
},

View File

@@ -92,6 +92,8 @@ async function onClick() {
if(!(await v$.value.$validate())) return
const result = await userStore.login(input.username, input.password)
console.log("back in login form: "+result)
switch(result) {
case true: