From 034477cc633f4f7c81edabf0dea17d1e142cf781 Mon Sep 17 00:00:00 2001 From: joostdecock Date: Fri, 25 Aug 2023 18:10:14 +0200 Subject: [PATCH] feat(shared): Ported account/img to new inputs --- markdown/org/docs/site/account/img/en.md | 7 +++ sites/shared/components/account/img.mjs | 69 +++++++----------------- 2 files changed, 27 insertions(+), 49 deletions(-) create mode 100644 markdown/org/docs/site/account/img/en.md diff --git a/markdown/org/docs/site/account/img/en.md b/markdown/org/docs/site/account/img/en.md new file mode 100644 index 00000000000..d0df265737f --- /dev/null +++ b/markdown/org/docs/site/account/img/en.md @@ -0,0 +1,7 @@ +--- +title: Profile Image +--- + +You can choose a **profile image** to further personalize your account. + +It can be a picture of you, your cat, your favourite cartoon character. You do you. diff --git a/sites/shared/components/account/img.mjs b/sites/shared/components/account/img.mjs index 540d94e7193..002478bf3f1 100644 --- a/sites/shared/components/account/img.mjs +++ b/sites/shared/components/account/img.mjs @@ -11,6 +11,8 @@ import { useLoadingStatus } from 'shared/hooks/use-loading-status.mjs' import { Icons, welcomeSteps, BackToAccountButton } from './shared.mjs' import { ContinueButton } from 'shared/components/buttons/continue-button.mjs' import { SaveSettingsButton } from 'shared/components/buttons/save-settings-button.mjs' +import { PassiveImageInput } from 'shared/components/inputs.mjs' +import { DynamicOrgDocs } from 'shared/components/dynamic-docs/org.mjs' export const ns = ['account', 'status'] @@ -18,24 +20,13 @@ export const ImgSettings = ({ title = false, welcome = false }) => { const { account, setAccount } = useAccount() const backend = useBackend() const { setLoadingStatus, LoadingStatus } = useLoadingStatus() - const { t } = useTranslation(ns) + const { t, i18n } = useTranslation(ns) - const [img, setImg] = useState(false) - const [url, setUrl] = useState('') - - 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 [img, setImg] = useState('') const save = async () => { setLoadingStatus([true, 'processingUpdate']) - const result = await backend.updateAccount({ img: url ? url : img }) + const result = await backend.updateAccount({ img }) if (result.success) { setAccount(result.data.account) setLoadingStatus([true, 'settingsSaved', true, true]) @@ -47,41 +38,21 @@ export const ImgSettings = ({ title = false, welcome = false }) => { return (
- {title ?

{t('imgTitle')}

: null} -
- {!welcome || img !== false ? ( - img - ) : null} -
- -

{t('imgDragAndDropImageHere')}

-

{t('or')}

- -
-

{t('or')}

-
- setUrl(evt.target.value)} - /> -
-
- + {!welcome || img !== false ? ( + img + ) : null} + val.length > 0} + docs={} + /> {welcome ? ( <>