Browse Source

feat(topbar): add CRM support portal (Report Issues) button next to language switcher

master
mortezaei 3 weeks ago
parent
commit
2d17ccc7a7
  1. 27
      src/components/layout/Topbar.tsx
  2. 63
      src/features/support/supportPortal.ts
  3. 1
      src/locales/ar.json
  4. 1
      src/locales/en.json
  5. 1
      src/locales/fa.json

27
src/components/layout/Topbar.tsx

@ -1,15 +1,19 @@
import React, { useMemo } from 'react'
import { useLocation } from 'react-router-dom'
import { SidebarTrigger } from '@/components/ui/sidebar'
import { Button } from '@/components/ui/button'
import ThemeToggle from '@/components/layout/ThemeToggle'
import ServerHealthTrigger from '@/components/layout/ServerHealthTrigger'
import LanguageSwitcher from '@/components/layout/LanguageSwitcher'
import { getNavigationConfig } from '@/config/navigation'
import { useSupportPortalUrl } from '@/features/support/supportPortal'
import { useTranslation } from '@/i18n'
import { Ic } from '@/icons'
export default function Topbar() {
const { pathname } = useLocation()
const { t } = useTranslation()
const supportPortalUrl = useSupportPortalUrl()
const navConfig = useMemo(() => getNavigationConfig(t), [t])
@ -56,11 +60,32 @@ export default function Topbar() {
</div>
</div>
{/* ابزارهای هدر: انتخابگر زبان، وضعیت اتصال سرور، سوئیچ تم */}
{/* ابزارهای هدر: انتخابگر زبان، گزارش مشکلات، وضعیت اتصال سرور، سوئیچ تم */}
<div className="flex items-center gap-2 sm:gap-2.5 shrink-0">
{/* انتخابگر زبان سه گانه (فارسی، عربی، انگلیسی) */}
<LanguageSwitcher />
{/* دکمه گزارش مشکلات (پرتال پشتیبانی CRM) */}
<Button
variant="outline"
size="sm"
asChild
className="h-9 px-2.5 sm:px-3 rounded-xl border-border/70 bg-card/40 hover:bg-card text-xs font-semibold gap-2 shadow-xs transition-all"
>
<a
href={supportPortalUrl}
target="_blank"
rel="noopener noreferrer"
title={t('topbar.reportIssues')}
aria-label={t('topbar.reportIssues')}
>
<Ic name="headset" className="size-4 text-primary shrink-0" />
<span className="hidden sm:inline-block text-[12px] text-foreground">
{t('topbar.reportIssues')}
</span>
</a>
</Button>
{/* نشانگر وضعیت اتصال سرور */}
<ServerHealthTrigger />

63
src/features/support/supportPortal.ts

@ -0,0 +1,63 @@
import { useMemo } from 'react'
import { useThemeStore } from '@/stores/theme'
export const AQILA_SUPPORT_PORTAL_TOKEN = '76cb859c-24e3-4309-9d99-504ac2e49268'
export const AQILA_SUPPORT_PORTAL_BASE_URL = `https://teamby.nwhco.ir/portal/${AQILA_SUPPORT_PORTAL_TOKEN}`
export const FALLBACK_PRIMARY = '#d09460'
function isValidHex(value: string): boolean {
return /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(value.trim())
}
function toCleanSixDigitHex(raw: string): string {
let clean = raw.trim().replace(/^#/, '')
if (clean.length === 3) {
clean = clean
.split('')
.map((c) => c + c)
.join('')
}
return clean.toLowerCase()
}
export function resolveSupportPortalPrimaryHex(): string {
const candidates = [
typeof document !== 'undefined'
? document.documentElement.style.getPropertyValue('--primary').trim() ||
getComputedStyle(document.documentElement).getPropertyValue('--primary').trim()
: undefined,
FALLBACK_PRIMARY,
]
for (const candidate of candidates) {
if (candidate && isValidHex(candidate)) {
return toCleanSixDigitHex(candidate)
}
}
return toCleanSixDigitHex(FALLBACK_PRIMARY)
}
export function buildAqilaSupportPortalUrl(options: {
primaryHex: string
theme: 'light' | 'dark'
}): string {
const url = new URL(AQILA_SUPPORT_PORTAL_BASE_URL)
url.searchParams.set('primary', toCleanSixDigitHex(options.primaryHex))
url.searchParams.set('theme', options.theme)
return url.toString()
}
/**
* Returns the live TeamBy Support Portal URL parameterized with the active
* Aqila Panel color palette and light/dark mode.
*/
export function useSupportPortalUrl(): string {
const isDark = useThemeStore((s) => s.isDark)
const theme: 'light' | 'dark' = isDark ? 'dark' : 'light'
return useMemo(() => {
const primaryHex = resolveSupportPortalPrimaryHex()
return buildAqilaSupportPortalUrl({ primaryHex, theme })
}, [theme])
}

1
src/locales/ar.json

@ -51,6 +51,7 @@
"theme": "المظهر",
"language": "اللغة",
"selectLanguage": "اختر لغة النظام",
"reportIssues": "الإبلاغ عن المشاكل",
"search": "بحث..."
},
"auth": {

1
src/locales/en.json

@ -51,6 +51,7 @@
"theme": "Theme",
"language": "Language",
"selectLanguage": "Select System Language",
"reportIssues": "Report Issues",
"search": "Search..."
},
"auth": {

1
src/locales/fa.json

@ -51,6 +51,7 @@
"theme": "تغییر تم",
"language": "تغییر زبان",
"selectLanguage": "انتخاب زبان سامانه",
"reportIssues": "گزارش مشکلات",
"search": "جستجو..."
},
"auth": {

Loading…
Cancel
Save