Files
hedena_gold/apps/admin-panel/src/views/user/myData.vue
T

45 lines
1.6 KiB
Vue

<template>
<!--
Ported from legacy henza_admin/src/views/user/myData.vue.
LEGACY BUG preserved in effect, not in code: legacy reads
`user.user_type.val`, but the users/show payload carries the title under
`title` (and `config_static` rows used `val` only in the raw lookup table),
so that cell fell through to its 'آنلاین' fallback for everyone. Here the
real title is shown when present, with the same fallback — the fallback is
what legacy actually displayed.
-->
<a-card title="اطلاعات کاربری">
<a-descriptions>
<a-descriptions-item label="نام">{{ user?.fname || '-' }}</a-descriptions-item>
<a-descriptions-item label="نام خانوادگی">{{ user?.lname || '-' }}</a-descriptions-item>
<a-descriptions-item label="شماره تلفن">{{ user?.mobile || '-' }}</a-descriptions-item>
<a-descriptions-item label="نوع کاربری">
{{ userTypeTitle || 'آنلاین' }}
</a-descriptions-item>
</a-descriptions>
</a-card>
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue';
import { useAuthStore } from '../../stores/auth';
import api from '../../api/client';
const auth = useAuthStore();
const fresh = ref<Record<string, any> | null>(null);
const user = computed(() => fresh.value ?? auth.user);
const userTypeTitle = computed(() => user.value?.user_type?.title);
onMounted(async () => {
try {
const { data } = await api.get('admin/users/me');
fresh.value = data;
} catch (e) {
// fall back to the cached login payload, as legacy did
console.log(e);
}
});
</script>