Skip to content

Commit 481cb54

Browse files
committed
more fixes
1 parent abccf8e commit 481cb54

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

src/composables/useAxiosForm.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ref } from 'vue';
22
import axios from '@/utils/axios';
3+
import progress from '@/utils/progress';
34
import { useAxiosErrorHandling } from '@/composables/useAxiosErrorHandling';
45

56
export function useAxiosForm(initialData = {}) {
@@ -24,9 +25,16 @@ export function useAxiosForm(initialData = {}) {
2425
};
2526

2627
const makeRequest = async (method, url, options = {}) => {
28+
options = {
29+
showProgress: false,
30+
...options,
31+
};
2732
try {
2833
clearErrors();
2934
processing.value = true;
35+
if (options.showProgress) {
36+
progress.start();
37+
}
3038

3139
if (options.onBefore) options.onBefore();
3240

@@ -47,6 +55,9 @@ export function useAxiosForm(initialData = {}) {
4755
if (onFinishCallback) onFinishCallback();
4856
if (options.onFinish) options.onFinish();
4957
processing.value = false;
58+
if (progress.isStarted()) {
59+
progress.done();
60+
}
5061
}
5162
};
5263

src/stores/auth.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const useAuthStore = defineStore('auth', () => {
4545
const { post: submitLogoutForm } = useAxiosForm();
4646
function logout() {
4747
return submitLogoutForm('/logout', {
48+
showProgress: true,
4849
onSuccess: (response) => {
4950
user.value = null;
5051
router.push({ name: 'welcome' });

src/views/profile/partials/UpdatePasswordForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ const {
2626
const submit = () => {
2727
submitForm('/password', {
2828
onSuccess: async () => {
29-
await authStore.fetchUser();
3029
toast.add({
3130
severity: 'success',
3231
summary: 'Saved',
3332
detail: 'Your password has been updated',
3433
life: 3000,
3534
});
3635
resetFormFields();
36+
authStore.fetchUser();
3737
},
3838
onError: () => {
3939
if (validationErrors.value?.password) {

src/views/profile/partials/UpdateProfileInformationForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ const {
2626
const submit = () => {
2727
submitForm('/profile', {
2828
onSuccess: async () => {
29-
await authStore.fetchUser();
3029
toast.add({
3130
severity: 'success',
3231
summary: 'Saved',
3332
detail: 'Profile information has been updated',
3433
life: 3000,
3534
});
35+
authStore.fetchUser();
3636
},
3737
});
3838
};

0 commit comments

Comments
 (0)