From 0535ee54619392c51912631973b799b1115d73ae Mon Sep 17 00:00:00 2001 From: Nico Schett <52858351+schettn@users.noreply.github.com> Date: Thu, 16 Sep 2021 02:46:18 +0000 Subject: [PATCH] fix(settingstab): fix state updates --- .../src/containers/ui/tabs/SettingsTab.tsx | 2 +- .../molecules/SiteSettings/index.tsx | 55 ++++++++++++++++--- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/packages/jaen-pages/src/containers/ui/tabs/SettingsTab.tsx b/packages/jaen-pages/src/containers/ui/tabs/SettingsTab.tsx index 39c72cd8..c5f8a841 100644 --- a/packages/jaen-pages/src/containers/ui/tabs/SettingsTab.tsx +++ b/packages/jaen-pages/src/containers/ui/tabs/SettingsTab.tsx @@ -36,7 +36,7 @@ const SettingsTab: React.FC<{}> = () => { mode="selector" onSelectorClose={fileSelector.onClose} onSelectorSelect={i => { - handleValuesChange({image: i.src}) + handleValuesChange({...siteMetadata, image: i.src}) fileSelector.onClose() }} diff --git a/packages/jaen-shared-ui/src/components/molecules/SiteSettings/index.tsx b/packages/jaen-shared-ui/src/components/molecules/SiteSettings/index.tsx index 7b62ba2f..a9b23372 100644 --- a/packages/jaen-shared-ui/src/components/molecules/SiteSettings/index.tsx +++ b/packages/jaen-shared-ui/src/components/molecules/SiteSettings/index.tsx @@ -172,9 +172,16 @@ const SiteSettings: React.FC = props => { Name handleValuesChange('description', e)} + onChange={e => + setValues({ + ...values, + author: { + name: e.target.value + } + }) + } onBlur={handleValuesCb} /> @@ -193,27 +200,54 @@ const SiteSettings: React.FC = props => { Name handleValuesChange('description', e)} + onChange={e => + setValues({ + ...values, + organization: { + name: e.target.value, + url: values.organization?.url || '', + logo: values.organization?.logo || '' + } + }) + } onBlur={handleValuesCb} /> URL handleValuesChange('description', e)} + onChange={e => + setValues({ + ...values, + organization: { + name: values.organization?.name || '', + url: e.target.value, + logo: values.organization?.logo || '' + } + }) + } onBlur={handleValuesCb} /> Logo handleValuesChange('description', e)} + onChange={e => + setValues({ + ...values, + organization: { + name: values.organization?.name || '', + url: values.organization?.url || '', + logo: e.target.value + } + }) + } onBlur={handleValuesCb} /> @@ -228,7 +262,10 @@ const SiteSettings: React.FC = props => { transition="0.2s all" objectFit="cover" _hover={{filter: 'brightness(70%)', cursor: 'pointer'}} - onClick={props.onImageClick} + onClick={() => { + handleValuesCb() + props.onImageClick() + }} />