feat: now compliant with eslint
All checks were successful
CI / build (push) Successful in 10s

This commit is contained in:
Pierre Tellier
2025-02-09 15:28:09 +01:00
parent 8af40bfe50
commit 1dff7573ff
13 changed files with 72 additions and 65 deletions

View File

@ -1,4 +1,4 @@
import axios from "axios";
import axios, {type AxiosError, type AxiosResponse} from "axios";
import {store} from "@/main.ts";
import {addNewMessage, color} from "@/services/popupDisplayer.ts";
@ -34,21 +34,18 @@ axiosInstance.interceptors.response.use(
);
// TODO: spawn a error modal
function defaultApiErrorHandler(err: string){
addNewMessage(err, color.Red);
function defaultApiErrorHandler(err: AxiosError){
addNewMessage(err.message, color.Red);
}
function defaultApiSuccessHandler(response: any){
addNewMessage(response.data, color.green)
function defaultApiSuccessHandler(response: AxiosResponse){
addNewMessage(response.data, color.Green)
}
function callApi(endpoint: string, onSuccessHandler?: any, onErrorHandler?: any): void {
function callApi(endpoint: string, onSuccessHandler?: (response: AxiosResponse) => void, onErrorHandler?: (error: AxiosError) => void): void {
axiosInstance.get(endpoint).then(
onSuccessHandler == null ? defaultApiSuccessHandler : onSuccessHandler
).catch(
(err) => {
onErrorHandler == null ? defaultApiErrorHandler(err): onErrorHandler(err);
throw err;
}
onErrorHandler == null ? defaultApiErrorHandler: onErrorHandler
)
}

View File

@ -1,4 +1,5 @@
import Keycloak from 'keycloak-js';
import type {AuthStore} from "@/stores/authStore.ts";
const options = {
url: import.meta.env.VITE_KEYCLOAK_URL,
@ -54,7 +55,7 @@ async function init(onInitCallback: () => void) {
* Initializes store with Keycloak user data
*
*/
async function initStore(storeInstance: any) {
async function initStore(storeInstance: AuthStore) {
try {
store = storeInstance
console.log(keycloak)

View File

@ -1,5 +1,19 @@
import {ref} from "vue";
enum color {Red, Yellow, Blue, green}
import {type Ref} from "vue";
enum color {Red, Yellow, Blue, Green}
type ErrorMessageContent = {
message: string;
color: color;
id: number;
timeout: number;
};
let id: number = 0;
const getId = () => {
id = id+1;
return id;
}
function addNewMessage(errorMessage: string, type?: color, timeout?: number){
if (timeout == null){
@ -9,11 +23,11 @@ function addNewMessage(errorMessage: string, type?: color, timeout?: number){
type = color.Red;
}
const data = {errorMessage: errorMessage, timeout: timeout, type: type, uid: Math.random()*100000};
const data: ErrorMessageContent = {message: errorMessage, timeout: timeout, color: type, id: getId()};
errorList.value.push(data)
setTimeout(() => errorList.value.slice(0, 1), timeout)
}
const errorList: any= ref([])
const errorList: Ref<ErrorMessageContent[]>= ref([])
export {addNewMessage, errorList, color}
export {addNewMessage, errorList, color, type ErrorMessageContent}