/*import fetchWrapper from "../fetchWrapper.js";
import getXSRFToken from "../getXSRF.js";

export default async function updateUser(name, lastname, phone) {
    const csrfToken = await getXSRFToken();

    return fetchWrapper(
        "/api/users/update",
        { name, lastname, phone },
        "POST",
        { "X-XSRF-TOKEN": csrfToken }
    );
}*/

import fetchWrapper from "../fetchWrapper";
import getXSRFToken from "../getXSRF";

interface UserUpdateData {
  name: string;
  lastname: string;
  phone: string | null;
}

interface RequestHeaders {
  "X-XSRF-TOKEN": string;
}
export default async function updateUser(name: string,lastname: string,phone: string | null): Promise<Response> {
    const csrfToken: string = await getXSRFToken();
    const userData: UserUpdateData = {name,lastname,phone,};
    const headers: RequestHeaders = {"X-XSRF-TOKEN": csrfToken,};
    return fetchWrapper("/api/users/update",userData,"POST",headers);
}

