<template>
	<div class="sticky top-0 z-10 shrink-0">
		<Header>
			<FBreadcrumbs
				:items="[
					{ label: '合作伙伴门户', route: { name: 'Partner Portal' } },
				]"
			/>
		</Header>
		<TabsWithRouter
			v-if="
				Boolean(this.$team.pg.jerp_partner) && $session.hasPartnerAccess
			"
			:tabs="tabs"
		/>
		<div
			v-else
			class="mx-auto mt-60 w-fit rounded border border-dashed px-12 py-8 text-center text-gray-600"
		>
			<i-lucide-alert-triangle class="mx-auto mb-4 h-6 w-6 text-red-600" />
			<ErrorMessage
				message="您无权查看合作伙伴页面。请向团队所有者申请为您的角色提供权限。"
			/>
		</div>
	</div>
</template>

<script>
import Header from '../components/Header.vue';
import { Breadcrumbs, Tabs } from 'jingrow-ui';
import TabsWithRouter from '../components/TabsWithRouter.vue';

export default {
	name: 'Partner',
	components: {
		Header,
		FBreadcrumbs: Breadcrumbs,
		FTabs: Tabs,
		TabsWithRouter,
	},
	data() {
		return {
			currentTab: 0,
			tabs: [
				{ label: '概览', route: { name: 'PartnerOverview' } },
				{ label: '客户', route: { name: 'PartnerCustomers' } },
				{
					label: '审批请求',
					route: { name: 'PartnerApprovalRequests' },
				},
				{
					label: '本地支付设置',
					route: { name: 'LocalPaymentSetup' },
					condition: () =>
						Boolean(
							this.$team.pg.country === 'Kenya' &&
								this.$team.pg.mpesa_enabled,
						),
				},
			],
		};
	},
};
</script>