Skip to content

Commit

Permalink
fix(settingstab): fix state updates
Browse files Browse the repository at this point in the history
  • Loading branch information
schettn authored Sep 16, 2021
1 parent af7752b commit 0535ee5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/jaen-pages/src/containers/ui/tabs/SettingsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,16 @@ const SiteSettings: React.FC<SiteSettingsType> = props => {
<Box p={2}>
<Heading size="sm">Name</Heading>
<Input
placeholder="Description"
placeholder="John Doe"
value={values.author?.name || ''}
onChange={e => handleValuesChange('description', e)}
onChange={e =>
setValues({
...values,
author: {
name: e.target.value
}
})
}
onBlur={handleValuesCb}
/>
</Box>
Expand All @@ -193,27 +200,54 @@ const SiteSettings: React.FC<SiteSettingsType> = props => {
<Box p={2}>
<Heading size="sm">Name</Heading>
<Input
placeholder="Description"
placeholder="Example, Inc."
value={values.organization?.name || ''}
onChange={e => handleValuesChange('description', e)}
onChange={e =>
setValues({
...values,
organization: {
name: e.target.value,
url: values.organization?.url || '',
logo: values.organization?.logo || ''
}
})
}
onBlur={handleValuesCb}
/>
</Box>
<Box p={2}>
<Heading size="sm">URL</Heading>
<Input
placeholder="Description"
placeholder="https://example.com"
value={values.organization?.url || ''}
onChange={e => handleValuesChange('description', e)}
onChange={e =>
setValues({
...values,
organization: {
name: values.organization?.name || '',
url: e.target.value,
logo: values.organization?.logo || ''
}
})
}
onBlur={handleValuesCb}
/>
</Box>
<Box p={2}>
<Heading size="sm">Logo</Heading>
<Input
placeholder="Description"
placeholder="https://example.com"
value={values.organization?.logo || ''}
onChange={e => handleValuesChange('description', e)}
onChange={e =>
setValues({
...values,
organization: {
name: values.organization?.name || '',
url: values.organization?.url || '',
logo: e.target.value
}
})
}
onBlur={handleValuesCb}
/>
</Box>
Expand All @@ -228,7 +262,10 @@ const SiteSettings: React.FC<SiteSettingsType> = props => {
transition="0.2s all"
objectFit="cover"
_hover={{filter: 'brightness(70%)', cursor: 'pointer'}}
onClick={props.onImageClick}
onClick={() => {
handleValuesCb()
props.onImageClick()
}}
/>
</Box>
</Flex>
Expand Down

0 comments on commit 0535ee5

Please sign in to comment.