<template>
  <div class="form-content">
    <div class="form-inner-content form-inner-content-left">
      <template
        v-if="
          !usersStore.isPanelUser &&
          (usersStore.selectedUserApproveId === 0 ||
            usersStore.selectedUserApproveId === 3)
        ">
        <form-uye-bilgileri />
      </template>
      <template v-else>
        <form-uye-bilgileri-display
          v-if="
            !usersStore.isPanelUser || (usersStore.isPanelUser && route.name !== 'Profil')
          " />
        <form-sifre-degistir v-if="usersStore.isPanelUser && CanChangePassword" />
      </template>
      <div class="form-part" v-if="(usersStore.isPanelUser && route.name !== 'Profil') ||
          (!usersStore.isPanelUser && route.name === 'Profil') ||
          (!usersStore.isPanelUser && route.name === 'UyeYetkiliDetay')">
        <form-uye-irtibat-kisi
          v-if="
            route.name === 'Profil' &&
            (usersStore.selectedUserApproveId === 0 ||
              usersStore.selectedUserApproveId === 3)
          " />
        <form-uye-irtibat-kisi-display v-else />
      </div>
    </div>
    <div class="form-inner-content form-inner-content-right">
      <form-uye-documents
        v-if="
          (usersStore.isPanelUser && route.name !== 'Profil') ||
          (!usersStore.isPanelUser && route.name === 'Profil')
        " />
      <form-uye-picture
        v-if="route.name !== 'UyeYetkiliDetay' && route.name !== 'UyeYetkiliYeni'" />
      <form-sifre-degistir
        v-if="
          route.name !== 'UyeYetkiliDetay' &&
          route.name !== 'UyeYetkiliYeni' &&
          CanChangePassword &&
          !usersStore.isPanelUser
        " />
    </div>
  </div>
</template>
<script setup lang="ts">
  import { computed } from 'vue'
  import { useRoute } from 'vue-router'
  const route = useRoute()
  import { useUsersStore } from '@/stores/usersStore'
  const usersStore = useUsersStore()
  import { useGlobalStore } from '@/stores/globalStore'
  const globalStore = useGlobalStore()

  import FormUyeBilgileri from './form/FormUyeBilgileri.vue'
  import FormUyeBilgileriDisplay from './display/FormUyeBilgileriDisplay.vue'
  import FormUyeIrtibatKisi from './form/FormUyeIrtibatKisi.vue'
  import FormUyeIrtibatKisiDisplay from './display/FormUyeIrtibatKisiDisplay.vue'
  import FormUyeDocuments from './form/FormUyeDocuments.vue'
  import FormUyePicture from './form/FormUyePicture.vue'
  import FormSifreDegistir from '@/module/kullanicilar/components/form/FormSifreDegistir.vue'

  const CanChangePassword = computed<boolean>(() => {
    if (usersStore.isPanelUser) {
      if (route.name === 'Profil' && usersStore.userId === usersStore.selectedUserId())
        return true
      else return false
    } else {
      if (usersStore.userId === usersStore.selectedUserId()) return true
      else return false
    }
  })
</script>
