Disable "Save" button on profile form after submitting

This commit is contained in:
silverpill 2022-11-16 20:20:08 +00:00
parent f261839c59
commit 8206971633

View file

@ -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 } })
} }