Refactor role switcher: single item with arrows on right
All checks were successful
Build Docker Image / build (push) Successful in 4m44s

- Remove separate "Кабинет" link and two role buttons
- Add single role switcher: "Я клиент <>" format
- Arrows <> shown only when user has both roles
- Click text → navigate to cabinet, click arrows → switch role
This commit is contained in:
Ruslan Bakiev
2026-01-29 15:44:52 +07:00
parent 3d5215d967
commit 72f2e1c39d
2 changed files with 31 additions and 36 deletions

View File

@@ -32,40 +32,36 @@
> >
{{ $t('catalog.modes.quote') }} {{ $t('catalog.modes.quote') }}
</button> </button>
<!-- Role switcher: Я клиент <> -->
<div v-if="loggedIn" class="flex items-center">
<NuxtLink <NuxtLink
v-if="loggedIn" :to="localePath(currentRole === 'SELLER' ? '/clientarea/offers' : '/clientarea/orders')"
:to="localePath('/clientarea/orders')"
class="px-3 py-1 text-sm font-medium rounded-lg transition-colors" class="px-3 py-1 text-sm font-medium rounded-lg transition-colors"
:class="isClientArea :class="isClientArea
? (useWhiteText ? 'bg-white/20 text-white' : 'bg-base-300 text-base-content') ? (useWhiteText ? 'bg-white/20 text-white' : 'bg-base-300 text-base-content')
: (useWhiteText ? 'text-white/70 hover:text-white hover:bg-white/10' : 'text-base-content/70 hover:text-base-content hover:bg-base-200')" : (useWhiteText ? 'text-white/70 hover:text-white hover:bg-white/10' : 'text-base-content/70 hover:text-base-content hover:bg-base-200')"
> >
{{ $t('cabinetNav.cabinet') }} {{ currentRole === 'SELLER' ? $t('cabinetNav.roles.seller') : $t('cabinetNav.roles.client') }}
</NuxtLink> </NuxtLink>
<!-- Role switcher --> <!-- Стрелки <> справа (если есть обе роли) -->
<div v-if="loggedIn && (hasBuyerTeam || hasSellerTeam)" class="flex items-center gap-1 ml-2 pl-2 border-l border-white/20"> <div v-if="hasMultipleRoles" class="flex items-center ml-1">
<button <button
v-if="currentRole === 'BUYER' || hasBuyerTeam" class="p-0.5 transition-colors"
class="px-3 py-1 text-sm font-medium rounded-lg transition-colors" :class="useWhiteText ? 'text-white/50 hover:text-white' : 'text-base-content/50 hover:text-base-content'"
:class="currentRole === 'BUYER' @click="$emit('switch-role', currentRole === 'BUYER' ? 'SELLER' : 'BUYER')"
? (useWhiteText ? 'bg-white/20 text-white' : 'bg-base-300 text-base-content')
: (useWhiteText ? 'text-white/70 hover:text-white hover:bg-white/10' : 'text-base-content/70 hover:text-base-content hover:bg-base-200')"
@click="$emit('switch-role', 'BUYER')"
> >
{{ $t('cabinetNav.roles.client') }} <Icon name="lucide:chevron-left" size="14" />
</button> </button>
<button <button
v-if="currentRole === 'SELLER' || hasSellerTeam" class="p-0.5 transition-colors"
class="px-3 py-1 text-sm font-medium rounded-lg transition-colors" :class="useWhiteText ? 'text-white/50 hover:text-white' : 'text-base-content/50 hover:text-base-content'"
:class="currentRole === 'SELLER' @click="$emit('switch-role', currentRole === 'BUYER' ? 'SELLER' : 'BUYER')"
? (useWhiteText ? 'bg-white/20 text-white' : 'bg-base-300 text-base-content')
: (useWhiteText ? 'text-white/70 hover:text-white hover:bg-white/10' : 'text-base-content/70 hover:text-base-content hover:bg-base-200')"
@click="$emit('switch-role', 'SELLER')"
> >
{{ $t('cabinetNav.roles.seller') }} <Icon name="lucide:chevron-right" size="14" />
</button> </button>
</div> </div>
</div>
</nav> </nav>
</div> </div>
@@ -361,8 +357,7 @@ const props = withDefaults(defineProps<{
} | null } | null
isSeller?: boolean isSeller?: boolean
// Role switching props // Role switching props
hasBuyerTeam?: boolean hasMultipleRoles?: boolean
hasSellerTeam?: boolean
currentRole?: string currentRole?: string
// Search props // Search props
activeTokens?: Array<{ type: string; id: string; label: string; icon: string }> activeTokens?: Array<{ type: string; id: string; label: string; icon: string }>

View File

@@ -17,8 +17,7 @@
:theme="theme" :theme="theme"
:user-data="userData" :user-data="userData"
:is-seller="isSeller" :is-seller="isSeller"
:has-buyer-team="hasBuyerTeam" :has-multiple-roles="hasMultipleRoles"
:has-seller-team="hasSellerTeam"
:current-role="currentRole" :current-role="currentRole"
:active-tokens="activeTokens" :active-tokens="activeTokens"
:available-chips="availableChips" :available-chips="availableChips"
@@ -153,6 +152,7 @@ const sellerTeam = computed(() =>
) )
const hasBuyerTeam = computed(() => !!buyerTeam.value) const hasBuyerTeam = computed(() => !!buyerTeam.value)
const hasSellerTeam = computed(() => !!sellerTeam.value) const hasSellerTeam = computed(() => !!sellerTeam.value)
const hasMultipleRoles = computed(() => hasBuyerTeam.value && hasSellerTeam.value)
const currentRole = computed(() => const currentRole = computed(() =>
userData.value?.activeTeam?.teamType || 'BUYER' userData.value?.activeTeam?.teamType || 'BUYER'
) )