Skip to content

Commit

Permalink
frontend: profile - change password - wip
Browse files Browse the repository at this point in the history
api integration is not completed yet
  • Loading branch information
rkshaon committed Jul 24, 2024
1 parent 8857a6d commit 9054a9c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions frontend/src/components/admin/user/AdminChangePasswordModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<script>
import { API_BASE_URL } from '@/config';
import { Modal } from 'bootstrap';
import { mapActions } from 'vuex';
import { useToast } from 'vue-toastification';
export default {
Expand All @@ -58,6 +59,8 @@ export default {
}
},
methods: {
...mapActions('user', ['changePassword']),
async showChangePasswordModal() {
const modalElement = this.$refs.changePasswordModal;
Expand All @@ -74,8 +77,20 @@ export default {
async confirmUpdate() {
console.log('Confirm update function called.');
const toast = useToast();
console.log(this.changePasswordData);
toast.info("work in progress");
try {
const changePasswordResponse = await this.changePassword(this.changePasswordData);
console.log(changePasswordResponse.data);
this.$emit('changePassword', changePasswordResponse);
toast.success('Category created!');
} catch (error) {
console.log('Failed:', error);
console.log(error.data);
toast.error('Failed to create category.');
}
const modalElement = this.$refs.changePasswordModal;
const modal = new Modal(modalElement);
modal._hideModal();
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/services/userAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ export const getUserProfile = () => {
return apiClient.get("/api/v1/users/profile");
};

export const changePassword = () => {
return apiClient.put("/api/v1/users/changepassword");
};

export default {};
6 changes: 6 additions & 0 deletions frontend/src/store/modules/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import {
getUserProfile,
changePassword,
} from "@/services/userAPI";

const state = {
Expand All @@ -19,6 +20,11 @@ const actions = {
const response = await getUserProfile();
commit("setUserProfile", response.data);
},

async changePassword() {
const response = await changePassword();
console.log(response.data);
},
};

const getters = {
Expand Down

0 comments on commit 9054a9c

Please sign in to comment.