Repair gift-card register success modal text, enforce KYC with correct identity checks, and show skeleton/fallback while home layout loads. Co-authored-by: Cursor <cursoragent@cursor.com>
96 lines
3.0 KiB
Vue
96 lines
3.0 KiB
Vue
<script setup lang="ts">
|
||
import { computed } from 'vue'
|
||
import { storeToRefs } from 'pinia'
|
||
import { useUserStore } from '@/store/userStore'
|
||
import { getToken } from '@/utils'
|
||
import { isGuestHomeActive } from '@/utils/guestHome'
|
||
import HomeSkeleton from '../components/HomeSkeleton.vue'
|
||
import { getHomeLayoutConfig } from './registry'
|
||
import { HOME_SECTION_COMPONENTS } from './sections'
|
||
import type { HomeLayoutConfig, HomeSectionId } from './types'
|
||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||
|
||
const props = defineProps<{
|
||
layoutConfig?: HomeLayoutConfig
|
||
}>()
|
||
|
||
const userStore = useUserStore()
|
||
const { userInfo } = storeToRefs(userStore)
|
||
const layoutConfig = computed(() => props.layoutConfig ?? getHomeLayoutConfig())
|
||
|
||
const isGuestHome = computed(() => isGuestHomeActive())
|
||
|
||
const outerSections = computed(() =>
|
||
(layoutConfig.value.outerSections ?? [])
|
||
.filter((section) => section.visible !== false)
|
||
.filter((section) => {
|
||
if (!isGuestHome.value) return true
|
||
return section.id !== 'assets' && section.id !== 'boursecuQuickActions'
|
||
}),
|
||
)
|
||
|
||
const innerSections = computed(() =>
|
||
layoutConfig.value.sections.filter((section) => section.visible !== false)
|
||
)
|
||
|
||
const tailSections = computed(() =>
|
||
(layoutConfig.value.tailSections ?? []).filter((section) => section.visible !== false)
|
||
)
|
||
|
||
/** محتوا با userInfo — دادههای API در پسزمینه لود میشوند */
|
||
const showContent = computed(() => Boolean(userInfo.value) || isGuestHome.value)
|
||
const showSkeleton = computed(() => Boolean(getToken()) && !userInfo.value)
|
||
|
||
function resolveSectionComponent(sectionId: HomeSectionId) {
|
||
return HOME_SECTION_COMPONENTS[sectionId]
|
||
}
|
||
|
||
async function retryLoad() {
|
||
if (!getToken()) return
|
||
await userStore.getMyInfo()
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<div v-if="showContent">
|
||
<component
|
||
:is="resolveSectionComponent(section.id)"
|
||
v-for="section in outerSections"
|
||
:key="`outer-${section.id}`"
|
||
/>
|
||
|
||
<div v-if="layoutConfig.wrapperClass" :class="layoutConfig.wrapperClass">
|
||
<component
|
||
:is="resolveSectionComponent(section.id)"
|
||
v-for="section in innerSections"
|
||
:key="section.id"
|
||
/>
|
||
</div>
|
||
|
||
<template v-else>
|
||
<component
|
||
:is="resolveSectionComponent(section.id)"
|
||
v-for="section in innerSections"
|
||
:key="section.id"
|
||
/>
|
||
</template>
|
||
|
||
<component
|
||
:is="resolveSectionComponent(section.id)"
|
||
v-for="section in tailSections"
|
||
:key="`tail-${section.id}`"
|
||
/>
|
||
</div>
|
||
|
||
<HomeSkeleton v-else-if="showSkeleton" class="w-full" />
|
||
|
||
<div v-else class="home-layout-fallback flex flex-col items-center justify-center gap-3 p-6 text-center min-h-[50vh]">
|
||
<p class="text-sm text-slate-600 leading-7">
|
||
در حال آمادهسازی صفحه اصلی هستیم. اگر چیزی نمایش داده نمیشود، یکبار تلاش مجدد کنید.
|
||
</p>
|
||
<BasicButton type="primary" class="!rounded-xl" @click="retryLoad">
|
||
تلاش مجدد
|
||
</BasicButton>
|
||
</div>
|
||
</template>
|