Show saving status in ProfileSettings
This commit is contained in:
parent
d5aa083a2f
commit
9d5ddcfccc
|
@ -33,6 +33,7 @@ export const ProfileSettings = () => {
|
||||||
const { t } = useLocalize()
|
const { t } = useLocalize()
|
||||||
const [prevForm, setPrevForm] = createStore({})
|
const [prevForm, setPrevForm] = createStore({})
|
||||||
const [isFormInitialized, setIsFormInitialized] = createSignal(false)
|
const [isFormInitialized, setIsFormInitialized] = createSignal(false)
|
||||||
|
const [isSaving, setIsSaving] = createSignal(false)
|
||||||
const [social, setSocial] = createSignal([])
|
const [social, setSocial] = createSignal([])
|
||||||
const [addLinkForm, setAddLinkForm] = createSignal<boolean>(false)
|
const [addLinkForm, setAddLinkForm] = createSignal<boolean>(false)
|
||||||
const [incorrectUrl, setIncorrectUrl] = createSignal<boolean>(false)
|
const [incorrectUrl, setIncorrectUrl] = createSignal<boolean>(false)
|
||||||
|
@ -70,16 +71,20 @@ export const ProfileSettings = () => {
|
||||||
|
|
||||||
const handleSubmit = async (event: Event) => {
|
const handleSubmit = async (event: Event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
setIsSaving(true)
|
||||||
if (nameInputRef.current.value.length === 0) {
|
if (nameInputRef.current.value.length === 0) {
|
||||||
setNameError(t('Required'))
|
setNameError(t('Required'))
|
||||||
nameInputRef.current.focus()
|
nameInputRef.current.focus()
|
||||||
|
setIsSaving(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (slugInputRef.current.value.length === 0) {
|
if (slugInputRef.current.value.length === 0) {
|
||||||
setSlugError(t('Required'))
|
setSlugError(t('Required'))
|
||||||
slugInputRef.current.focus()
|
slugInputRef.current.focus()
|
||||||
|
setIsSaving(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await submit(form)
|
await submit(form)
|
||||||
setPrevForm(clone(form))
|
setPrevForm(clone(form))
|
||||||
|
@ -91,6 +96,8 @@ export const ProfileSettings = () => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
showSnackbar({ type: 'error', body: t('Error') })
|
showSnackbar({ type: 'error', body: t('Error') })
|
||||||
|
} finally {
|
||||||
|
setIsSaving(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
await loadAuthor() // renews author's profile
|
await loadAuthor() // renews author's profile
|
||||||
|
@ -359,7 +366,12 @@ export const ProfileSettings = () => {
|
||||||
}
|
}
|
||||||
onClick={handleCancel}
|
onClick={handleCancel}
|
||||||
/>
|
/>
|
||||||
<Button onClick={handleSubmit} variant="primary" value={t('Save settings')} />
|
<Button
|
||||||
|
onClick={handleSubmit}
|
||||||
|
variant="primary"
|
||||||
|
disabled={isSaving()}
|
||||||
|
value={isSaving() ? t('Saving...') : t('Save settings')}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user