export const isFileImage = (file: File): boolean => {
  return [
    'image/png',
    'image/gif',
    'image/jpeg',
    'image/svg',
    'image/svg+xml',
  ].includes(file.type);
};

export const getImageFromFile = async (
  file: File,
): Promise<{ img: string | ArrayBuffer | null; name: string }> => {
  return new Promise((resolve, reject) => {
    const fr = new FileReader();
    fr.onload = () => {
      resolve({ img: fr.result, name: file.name });
    };
    fr.readAsDataURL(file);
    fr.onerror = (error) => {
      reject(error);
    };
  });
};
