From 39712613ae4b2a5eb9448325285be3f8c71adc1e Mon Sep 17 00:00:00 2001 From: Ruslan Bakiev <572431+veikab@users.noreply.github.com> Date: Tue, 21 Apr 2026 14:09:51 +0700 Subject: [PATCH] fix(auth): org-scoped team tokens and header search order --- app/components/AppHeader.vue | 132 +++++++++++------- app/composables/useActiveTeam.ts | 5 +- app/composables/useAuth.ts | 4 +- app/composables/useLogtoTokens.ts | 49 +++++-- .../00-apollo-console-filter.client.ts | 22 ++- i18n/locales/en/ui.json | 2 + i18n/locales/ru/ui.json | 2 + server/api/auth/refresh.post.ts | 17 ++- 8 files changed, 157 insertions(+), 76 deletions(-) diff --git a/app/components/AppHeader.vue b/app/components/AppHeader.vue index b7206c0..a584fa0 100644 --- a/app/components/AppHeader.vue +++ b/app/components/AppHeader.vue @@ -43,16 +43,36 @@ const LANDING_SEARCH_TOP_STOP = 16 const LANDING_SEARCH_BOTTOM_GAP = 30 const logisticsSearch = reactive({ - from: '', - to: '', - cargo: '', + destination: '', + product: '', + quantity: '', }) function syncSearchFromRoute() { hydrateFromQuery(route.query) - logisticsSearch.from = typeof route.query.from === 'string' ? route.query.from : isCalcPage.value ? calcDraft.value.from : '' - logisticsSearch.to = typeof route.query.to === 'string' ? route.query.to : isCalcPage.value ? calcDraft.value.to : '' - logisticsSearch.cargo = typeof route.query.cargo === 'string' ? route.query.cargo : isCalcPage.value ? calcDraft.value.cargo : '' + logisticsSearch.destination = typeof route.query.hubName === 'string' + ? route.query.hubName + : typeof route.query.to === 'string' + ? route.query.to + : isCalcPage.value + ? calcDraft.value.to + : '' + logisticsSearch.product = typeof route.query.productName === 'string' + ? route.query.productName + : typeof route.query.from === 'string' + ? route.query.from + : isCalcPage.value + ? calcDraft.value.from + : '' + logisticsSearch.quantity = typeof route.query.qty === 'string' + ? route.query.qty + : typeof route.query.quantity === 'string' + ? route.query.quantity + : typeof route.query.cargo === 'string' + ? route.query.cargo + : isCalcPage.value + ? calcDraft.value.cargo + : '' } function inferCountryIso(value: string, fallback: string) { @@ -69,10 +89,8 @@ function isoToFlag(iso: string) { return String.fromCodePoint(...[...normalized].map(char => 127397 + char.charCodeAt(0))) } -const fromIso = computed(() => inferCountryIso(logisticsSearch.from, 'CN')) -const toIso = computed(() => inferCountryIso(logisticsSearch.to, 'RU')) -const fromFlag = computed(() => isoToFlag(fromIso.value)) -const toFlag = computed(() => isoToFlag(toIso.value)) +const destinationIso = computed(() => inferCountryIso(logisticsSearch.destination, 'RU')) +const destinationFlag = computed(() => isoToFlag(destinationIso.value)) const showAdminDock = computed(() => Boolean(showLogistics.value) && !isAuthPage.value) // Fullscreen menu const isMenuOpen = ref(false) @@ -212,53 +230,60 @@ const headerBackdropClass = computed(() => { return 'header-glass-backdrop--default' }) -function buildHeaderSearchQuery(from: string, to: string, cargo: string) { +function buildHeaderSearchQuery(destination: string, product: string, quantity: string) { const currentQuery = route.query || {} const patch = { - from, - to, - cargo, + from: product, + to: destination, + cargo: quantity, + } + const semanticQuery = { + ...(product ? { productName: product } : {}), + ...(destination ? { hubName: destination } : {}), + ...(quantity ? { qty: quantity, quantity } : {}), } if (isCalcPage.value) { return { ...currentQuery, ...buildCalcQuery(patch), + ...semanticQuery, } } return { ...currentQuery, - ...(from ? { from } : {}), - ...(to ? { to } : {}), - ...(cargo ? { cargo } : {}), + ...(product ? { from: product } : {}), + ...(destination ? { to: destination } : {}), + ...(quantity ? { cargo: quantity } : {}), + ...semanticQuery, } } async function submitHeaderSearch() { - const from = logisticsSearch.from.trim() - const to = logisticsSearch.to.trim() - const cargo = logisticsSearch.cargo.trim() + const destination = logisticsSearch.destination.trim() + const product = logisticsSearch.product.trim() + const quantity = logisticsSearch.quantity.trim() await navigateToLocalized({ path: '/catalog', - query: buildHeaderSearchQuery(from, to, cargo), + query: buildHeaderSearchQuery(destination, product, quantity), }) } -type StepRoute = 'from' | 'to' | 'cargo' +type StepRoute = 'destination' | 'product' | 'quantity' async function openStep(step: StepRoute) { - const from = logisticsSearch.from.trim() - const to = logisticsSearch.to.trim() - const cargo = logisticsSearch.cargo.trim() - const stepPath = step === 'from' - ? '/catalog/product' - : step === 'to' - ? '/catalog/destination' + const destination = logisticsSearch.destination.trim() + const product = logisticsSearch.product.trim() + const quantity = logisticsSearch.quantity.trim() + const stepPath = step === 'destination' + ? '/catalog/destination' + : step === 'product' + ? '/catalog/product' : '/catalog/quantity' await navigateToLocalized({ path: stepPath, - query: buildHeaderSearchQuery(from, to, cargo), + query: buildHeaderSearchQuery(destination, product, quantity), }) } @@ -297,7 +322,7 @@ async function goToSignIn() { @@ -321,43 +346,46 @@ async function goToSignIn() {
- -