// Hooks import { useState, useCallback } from 'react' import { useTranslation } from 'next-i18next' import { useBackend } from 'site/hooks/useBackend.mjs' import { useDropzone } from 'react-dropzone' import { useToast } from 'site/hooks/useToast.mjs' // Components import { Icons, welcomeSteps, BackToAccountButton } from './shared.mjs' import { ContinueButton } from 'site/components/buttons/continue-button.mjs' import { SaveSettingsButton } from 'site/components/buttons/save-settings-button.mjs' export const ns = ['account', 'toast'] export const ImgSettings = ({ app, title = false, welcome = false }) => { const backend = useBackend(app) const toast = useToast() const { t } = useTranslation(ns) const [img, setImg] = useState(false) const onDrop = useCallback((acceptedFiles) => { const reader = new FileReader() reader.onload = () => { setImg(reader.result) } acceptedFiles.forEach((file) => reader.readAsDataURL(file)) }, []) const { getRootProps, getInputProps } = useDropzone({ onDrop }) const save = async () => { app.startLoading() const result = await backend.updateAccount({ img }) if (result === true) toast.for.settingsSaved() else toast.for.backendError() app.stopLoading() } const nextHref = '/docs/guide' return ( <> {title ?
{t('imgDragAndDropImageHere')}
{t('or')}