<template>
  <view class="app-container">
    <SalesHome v-if="role === 'sales'" />
    <DispatchHome v-else-if="role === 'dispatch'" />
    <ConstructionHome v-else />
  </view>
</template>

<script setup lang="ts">
import { onShow } from '@dcloudio/uni-app'
import { computed } from 'vue'
import { useAuthStore } from '@/stores/auth'
import SalesHome from '@/components/home/SalesHome.vue'
import DispatchHome from '@/components/home/DispatchHome.vue'
import ConstructionHome from '@/components/home/ConstructionHome.vue'

const authStore = useAuthStore()
const role = computed(() => authStore.userRole || 'sales')

onShow(() => {
  const pages = getCurrentPages()
  const page = pages[pages.length - 1] as any
  page?.getTabBar?.()?.setSelected?.(0)
})
</script>
