2023-08-01 10:24:57 +03:00
|
|
|
import { AxiosInstance } from "axios";
|
|
|
|
import { UUID } from "crypto";
|
|
|
|
|
2023-09-13 14:47:12 +03:00
|
|
|
import { UserStats } from "@/lib/types/User";
|
|
|
|
|
2023-08-01 10:24:57 +03:00
|
|
|
export type UserIdentityUpdatableProperties = {
|
2023-11-20 03:22:03 +03:00
|
|
|
empty?: string | null;
|
2023-08-01 10:24:57 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export type UserIdentity = {
|
|
|
|
user_id: UUID;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const updateUserIdentity = async (
|
|
|
|
userUpdatableProperties: UserIdentityUpdatableProperties,
|
|
|
|
axiosInstance: AxiosInstance
|
|
|
|
): Promise<UserIdentity> =>
|
|
|
|
axiosInstance.put(`/user/identity`, userUpdatableProperties);
|
|
|
|
|
|
|
|
export const getUserIdentity = async (
|
|
|
|
axiosInstance: AxiosInstance
|
|
|
|
): Promise<UserIdentity> => {
|
|
|
|
const { data } = await axiosInstance.get<UserIdentity>(`/user/identity`);
|
|
|
|
|
|
|
|
return data;
|
|
|
|
};
|
2023-09-13 14:47:12 +03:00
|
|
|
|
|
|
|
export const getUser = async (
|
|
|
|
axiosInstance: AxiosInstance
|
|
|
|
): Promise<UserStats> => (await axiosInstance.get<UserStats>("/user")).data;
|