Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
chore(profile): reset form on component unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwigoric committed Aug 6, 2023
1 parent 0373bf0 commit 81921ef
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/views/ProfileView.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup>
// Import packages
import { reactive, ref, onMounted, watch } from 'vue'
import { reactive, ref, onMounted, watch, onUnmounted } from 'vue'
import { useMediaQuery } from '@vueuse/core'
import moment from 'moment'
Expand Down Expand Up @@ -176,6 +176,16 @@ async function saveChanges(file) {
return false
}
const resetForm = () => {
newUsername.value = ''
newDescription.value = ''
currentPassword.value = ''
newPassword.value = ''
confirmNewPassword.value = ''
editError.value = false
editErrorMessage.value = ''
}
const processInput = async () => {
const { valid } = await editForm.value.validate()
if (!valid) return
Expand All @@ -199,12 +209,7 @@ const processInput = async () => {
dialog.value = false
// Reset form
currentPassword.value = ''
newPassword.value = ''
confirmNewPassword.value = ''
newUsername.value = ''
newDescription.value = ''
files.value = []
resetForm()
} else {
editError.value = true
editErrorMessage.value = error
Expand Down Expand Up @@ -277,6 +282,7 @@ async function deleteComment(id) {
// Define lifecycle hooks
onMounted(fetchUser)
onUnmounted(resetForm)
watch(
() => props.username,
() => {
Expand Down

0 comments on commit 81921ef

Please sign in to comment.