refactor(portal): partner-mode customer switcher on real tenants

Migrate the partner-mode customer switcher, in-customer banner, sidebar tile and the team invite/teammate panels off the data/customers fixture onto the real /api/partner/tenants list (shared key, gated to partner-staff so the global shell doesn't 403 for other users). Active customer resolves by tenant _id (the key the customers page already passes to partnerMode.enter); partner-identity labels now use the real partner name from useMe. Removes the now-unused customers + CustomerOrg-list fixture export and the dead setCustomer helper. Verified in UI: switcher + enter/exit show real Baslund Test / Baslund Research ApS.
This commit is contained in:
Ronni Baslund
2026-05-30 14:51:14 +02:00
parent 60e0b2286c
commit 7720e4be83
7 changed files with 67 additions and 63 deletions
+9 -8
View File
@@ -14,7 +14,7 @@
// source design.
import type { IconName } from './UiIcon.vue'
import { customers as fixtureCustomers } from '~/data/customers'
import type { PartnerTenantDoc } from '~/types/partner'
interface NavItem {
id: string
@@ -130,11 +130,6 @@ const currentId = computed(() => {
return ''
})
// Customer currently being acted-as (partner-in-customer mode)
const activeCustomer = computed(() =>
fixtureCustomers.find((c) => c.id === partnerMode.activeCustomerId.value) || null,
)
// Workspace-switcher content matches the URL section.
type SwitcherKind = 'customer' | 'partner' | 'in-customer'
const switcherKind = computed<SwitcherKind>(() => {
@@ -154,12 +149,18 @@ function exitCustomer() {
// hitting a 403 against the partner-scoped endpoint. useFetch with a stable
// key dedupes with the /partner/customers page's request.
const { partner, isPartnerStaff } = useMe()
const { data: partnerTenants } = await useFetch<unknown[]>('/api/partner/tenants', {
const { data: partnerTenants } = await useFetch<PartnerTenantDoc[]>('/api/partner/tenants', {
key: 'partner-tenants',
default: () => [],
immediate: isPartnerStaff.value,
})
const partnerCustomerCount = computed(() => partnerTenants.value?.length ?? 0)
// Customer currently being acted-as (partner-in-customer mode), resolved from
// the real tenant list by the _id stored in partner mode.
const activeCustomer = computed(() =>
(partnerTenants.value ?? []).find((c) => c._id === partnerMode.activeCustomerId.value) || null,
)
</script>
<template>
@@ -193,7 +194,7 @@ const partnerCustomerCount = computed(() => partnerTenants.value?.length ?? 0)
<span class="ws-tile" :style="{ background: activeCustomer?.brandColor || '#0A0A0A' }" />
<div v-if="!collapsed" class="ws-text">
<div class="ws-name">{{ activeCustomer?.name }}</div>
<div class="ws-sub mono">via NordicMSP</div>
<div class="ws-sub mono">via {{ partner?.name ?? 'partner' }}</div>
</div>
</template>