Client - reset user sport preferences - fix #123
This commit is contained in:
@ -138,6 +138,12 @@
|
||||
<button :disabled="loading" @click="updateSportInEdition(null)">
|
||||
{{ $t('buttons.CANCEL') }}
|
||||
</button>
|
||||
<button
|
||||
:disabled="loading"
|
||||
@click="(e) => resetSport(e, sport.id)"
|
||||
>
|
||||
{{ $t('buttons.RESET') }}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@ -234,6 +240,13 @@
|
||||
sportPayload
|
||||
)
|
||||
}
|
||||
function resetSport(event: Event, sportId: number) {
|
||||
event.preventDefault()
|
||||
store.dispatch(
|
||||
AUTH_USER_STORE.ACTIONS.RESET_USER_SPORT_PREFERENCES,
|
||||
sportId
|
||||
)
|
||||
}
|
||||
|
||||
watch(
|
||||
() => loading.value,
|
||||
@ -287,6 +300,11 @@
|
||||
min-width: 80px;
|
||||
}
|
||||
}
|
||||
.sport-btn {
|
||||
display: flex;
|
||||
background: yellow;
|
||||
gap: $default-padding;
|
||||
}
|
||||
.threshold-input {
|
||||
padding: $default-padding * 0.5;
|
||||
width: 50px;
|
||||
|
@ -10,6 +10,7 @@
|
||||
"LOGIN": "Log in",
|
||||
"NO": "No",
|
||||
"REGISTER": "Register",
|
||||
"RESET": "Reset",
|
||||
"SUBMIT": "Submit",
|
||||
"YES": "Yes"
|
||||
}
|
@ -10,6 +10,7 @@
|
||||
"LOGIN": "Se connecter",
|
||||
"NO": "Non",
|
||||
"REGISTER": "S'inscrire",
|
||||
"RESET": "Réinit.",
|
||||
"SUBMIT": "Valider",
|
||||
"YES": "Oui"
|
||||
}
|
@ -174,6 +174,26 @@ export const actions: ActionTree<IAuthUserState, IRootState> &
|
||||
context.commit(AUTH_USER_STORE.MUTATIONS.UPDATE_USER_LOADING, false)
|
||||
)
|
||||
},
|
||||
[AUTH_USER_STORE.ACTIONS.RESET_USER_SPORT_PREFERENCES](
|
||||
context: ActionContext<IAuthUserState, IRootState>,
|
||||
sportId: number
|
||||
): void {
|
||||
context.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
|
||||
context.commit(AUTH_USER_STORE.MUTATIONS.UPDATE_USER_LOADING, true)
|
||||
authApi
|
||||
.delete(`auth/profile/reset/sports/${sportId}`)
|
||||
.then((res) => {
|
||||
if (res.status === 204) {
|
||||
context.dispatch(SPORTS_STORE.ACTIONS.GET_SPORTS)
|
||||
} else {
|
||||
handleError(context, null)
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
handleError(context, error)
|
||||
context.commit(AUTH_USER_STORE.MUTATIONS.UPDATE_USER_LOADING, false)
|
||||
})
|
||||
},
|
||||
[AUTH_USER_STORE.ACTIONS.UPDATE_USER_SPORT_PREFERENCES](
|
||||
context: ActionContext<IAuthUserState, IRootState>,
|
||||
payload: IUserSportPreferencesPayload
|
||||
|
@ -7,6 +7,7 @@ export enum AuthUserActions {
|
||||
LOGOUT = 'LOGOUT',
|
||||
SEND_PASSWORD_RESET_REQUEST = 'SEND_PASSWORD_RESET_REQUEST',
|
||||
RESET_USER_PASSWORD = 'RESET_USER_PASSWORD',
|
||||
RESET_USER_SPORT_PREFERENCES = 'RESET_USER_SPORT_PREFERENCES',
|
||||
UPDATE_USER_PICTURE = 'UPDATE_USER_PICTURE',
|
||||
UPDATE_USER_PROFILE = 'UPDATE_USER_PROFILE',
|
||||
UPDATE_USER_PREFERENCES = 'UPDATE_USER_PREFERENCES',
|
||||
|
@ -73,6 +73,11 @@ export interface IAuthUserActions {
|
||||
payload: IUserPasswordResetPayload
|
||||
): void
|
||||
|
||||
[AUTH_USER_STORE.ACTIONS.RESET_USER_SPORT_PREFERENCES](
|
||||
context: ActionContext<IAuthUserState, IRootState>,
|
||||
sportId: number
|
||||
): void
|
||||
|
||||
[AUTH_USER_STORE.ACTIONS.DELETE_ACCOUNT](
|
||||
context: ActionContext<IAuthUserState, IRootState>,
|
||||
payload: IUserDeletionPayload
|
||||
|
Reference in New Issue
Block a user