diff --git a/src/components/profile/ChangePassword.vue b/src/components/profile/ChangePassword.vue index 1ae5d3b..c6d524e 100644 --- a/src/components/profile/ChangePassword.vue +++ b/src/components/profile/ChangePassword.vue @@ -1,31 +1,41 @@ @@ -34,19 +44,21 @@ import SeasonedInput from "@/components/ui/SeasonedInput.vue"; import SeasonedButton from "@/components/ui/SeasonedButton.vue"; import SeasonedMessages from "@/components/ui/SeasonedMessages.vue"; + import PasswordGenerator from "@/components/settings/PasswordGenerator.vue"; import type { Ref } from "vue"; import { ErrorMessageTypes } from "../../interfaces/IErrorMessage"; import type { IErrorMessage } from "../../interfaces/IErrorMessage"; - // interface ResetPasswordPayload { - // old_password: string; - // new_password: string; - // } - const oldPassword: Ref = ref(""); const newPassword: Ref = ref(""); const newPasswordRepeat: Ref = ref(""); const messages: Ref = ref([]); + const loading = ref(false); + + function handleGeneratedPassword(password: string) { + newPassword.value = password; + newPasswordRepeat.value = password; + } function addWarningMessage(message: string, title?: string) { messages.value.push({ @@ -57,6 +69,7 @@ } function validate() { + return return new Promise((resolve, reject) => { if (!oldPassword.value || oldPassword?.value?.length === 0) { addWarningMessage("Missing old password!", "Validation error"); @@ -80,19 +93,62 @@ }); } - // TODO seasoned-api /user/password-reset async function changePassword() { try { - validate(); + await validate(); + + loading.value = true; + + // API call disabled for now + // TODO: Implement actual password change API call + // await api.changePassword({ oldPassword, newPassword }); + + messages.value.push({ + message: "Password change is currently disabled", + title: "Feature Disabled", + type: ErrorMessageTypes.Warning + } as IErrorMessage); + + // Clear form + oldPassword.value = ""; + newPassword.value = ""; + newPasswordRepeat.value = ""; + + loading.value = false; } catch (error) { console.log("not valid! error:", error); // eslint-disable-line no-console + loading.value = false; } - - // const body: ResetPasswordPayload = { - // old_password: oldPassword.value, - // new_password: newPassword.value - // }; - // const options = {}; - // fetch() } + +