Disable "Save" button on profile form after submitting
This commit is contained in:
parent
f261839c59
commit
8206971633
1 changed files with 8 additions and 1 deletions
|
@ -74,7 +74,11 @@
|
||||||
Add new item
|
Add new item
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn" :disabled="!isFormValid()">
|
<button
|
||||||
|
type="submit"
|
||||||
|
class="btn"
|
||||||
|
:disabled="!isFormValid() || isLoading"
|
||||||
|
>
|
||||||
Save
|
Save
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
@ -105,6 +109,7 @@ const { ensureCurrentUser, setCurrentUser, ensureAuthToken } = $(useCurrentUser(
|
||||||
|
|
||||||
const extraFieldMaxCount = 10
|
const extraFieldMaxCount = 10
|
||||||
const profile = ensureCurrentUser()
|
const profile = ensureCurrentUser()
|
||||||
|
let isLoading = $ref(false)
|
||||||
|
|
||||||
function getFieldsAttributes() {
|
function getFieldsAttributes() {
|
||||||
const fields_attributes = []
|
const fields_attributes = []
|
||||||
|
@ -203,7 +208,9 @@ function isFormValid(): boolean {
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
const authToken = ensureAuthToken()
|
const authToken = ensureAuthToken()
|
||||||
|
isLoading = true
|
||||||
const user = await updateProfile(authToken, form)
|
const user = await updateProfile(authToken, form)
|
||||||
|
isLoading = false
|
||||||
setCurrentUser(user)
|
setCurrentUser(user)
|
||||||
router.push({ name: "profile", params: { profileId: user.id } })
|
router.push({ name: "profile", params: { profileId: user.id } })
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue