import { get, post } from '.';

export async function getPicture(): Promise<Blob | undefined> {
  const response = await get('users/picture');
  if (response?.status === 200) {
    return response.blob();
  } else {
    return undefined;
  }
}

export async function setPicture(payload: File): Promise<boolean> {
  const data = new FormData();
  data.append('data', payload);
  // TODO: Figure out why the form data object is empty
  const response = await post('users/picture', data, {
    type: 'form'
  });
  if (response?.status === 200) {
    return true;
  } else {
    return false;
  }
}
