import { message } from '@tauri-apps/plugin-dialog'; import { Dispatch, SetStateAction, useState } from 'react'; import { useArk } from '@libs/ark'; import { LoaderIcon } from '@shared/icons'; export function AvatarUploader({ setPicture, }: { setPicture: Dispatch>; }) { const ark = useArk(); const [loading, setLoading] = useState(false); const uploadAvatar = async () => { try { // start loading setLoading(true); const image = await ark.upload({}); if (image) { setPicture(image); setLoading(false); } return; } catch (e) { // stop loading setLoading(false); await message(`Upload failed, error: ${e}`, { title: 'Lume', type: 'error' }); } }; return ( ); }