import { convertFileToBase64String } from "../utils";

export function useUserApi() {
    async function login(data: { email: string; password: string }) {
        const resp = { name: "Иван", surname: "Иванов", email: data.email, image: "" };
        return resp;
    }

    async function register(data: { name: string; surname: string; email: string; password: string; imageFile?: File }) {
        const resp = {
            name: data.name,
            surname: data.surname,
            email: data.email,
            image: data.imageFile != null ? await convertFileToBase64String(data.imageFile) : "",
        };
        return resp;
    }

    async function changeUserData(data: { name: string; surname: string; imageFile?: File }) {
        const resp = {
            name: data.name,
            surname: data.surname,
            image: data.imageFile != null ? await convertFileToBase64String(data.imageFile) : "",
        };
        return resp;
    }

    async function changeUserPassword(data: { oldPassword: string; newPassword: string; newPassword2: string }) {
        const resp = true;
        return resp;
    }

    return { login, register, changeUserData, changeUserPassword };
}
