30 lines
No EOL
785 B
TypeScript
30 lines
No EOL
785 B
TypeScript
import type {Show} from "@models/show/show";
|
|
import axios, {type AxiosResponse} from "axios";
|
|
|
|
export interface User {
|
|
id?: number;
|
|
login: string;
|
|
role: string;
|
|
firstName: string;
|
|
lastName: string;
|
|
email?: boolean;
|
|
cellPhone?: boolean;
|
|
|
|
show?: Show[];
|
|
}
|
|
|
|
|
|
export const getUser = async (options: {
|
|
role?: string | null;
|
|
withShow?: boolean;
|
|
}): Promise<User[]> => {
|
|
const filteredParams = Object.fromEntries(
|
|
Object.entries(options).filter(([_, value]) => value !== undefined && value !== null)
|
|
);
|
|
return await axios.get(`/user`, {params: filteredParams})
|
|
.then((response: AxiosResponse) => {
|
|
return response.data
|
|
}).catch((error: Error) => {
|
|
console.log("Error: " + error);
|
|
})
|
|
} |