<script setup lang="ts">
const dialogVisible = ref(false)

const openDialog = () => {
  dialogVisible.value = true
}

const data = ref({
  oldPassword: '',
  newPassword: '',
  confirmPassword: ''
})

const clearData = () => {
  data.value = {
    oldPassword: '',
    newPassword: '',
    confirmPassword: ''
  }
}
defineExpose({
  openDialog
})
</script>

<template>
  <el-dialog
    v-model="dialogVisible"
    class="change-password-dialog"
    @close="clearData"
    top="20vh"
    :width="400"
    title="Change Password"
  >
    <div>
      <div class="form-item">
        <span class="label">Old Password</span>
        <el-input v-model="data.oldPassword" placeholder="Please input Old Password">
          <template #prefix>
            <span class="font_family icon-icon_password_b"></span>
          </template>
        </el-input>
      </div>
      <div class="form-item">
        <span class="label">New Password</span>
        <el-input
          v-model="data.newPassword"
          placeholder="New password must contain both letter and numeral"
        >
          <template #prefix>
            <span class="font_family icon-icon_password_b"></span>
          </template>
        </el-input>
      </div>
      <div class="form-item">
        <span class="label">Confirm Password</span>
        <el-input v-model="data.confirmPassword" placeholder="Please Confirm Password">
          <template #prefix>
            <span class="font_family icon-icon_password_b"></span>
          </template>
        </el-input>
      </div>
    </div>
    <template #footer>
      <el-button class="el-button--default" style="height: 40px" @click="dialogVisible = false"
        >Cancel</el-button
      >
      <el-button class="el-button--dark" style="height: 40px">Update</el-button>
    </template>
  </el-dialog>
</template>

<style lang="scss">
.change-password-dialog {
  .el-dialog__body {
    padding: 8px 16px 0px;
  }
  .form-item {
    margin-bottom: 16px;
    .label {
      font-size: 12px;
    }
  }
  .el-button {
    padding: 8px 24px;
  }
}
</style>
