Fix typed i18n keys for customer access labels.
Unblocks the business dashboard production build after Customer/Manager role UI. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
f622e6d605
commit
beec3035e5
@@ -12,6 +12,7 @@ import { Tooltip } from '../components/Tooltip'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import { useToast } from '../context/ToastContext'
|
||||
import { useT } from '../i18n/useT'
|
||||
import type { BusinessMessageKey } from '../i18n/messages'
|
||||
import { ApiError, isAbortError } from '../lib/api'
|
||||
import { getActiveBusinessId } from '../lib/businessContext'
|
||||
import { formatCellForDisplay } from '../lib/cellNumber'
|
||||
@@ -52,7 +53,7 @@ function formatTransactionTotal(total: number | null | undefined) {
|
||||
return formatIrtPrice(total)
|
||||
}
|
||||
|
||||
function accessBadgeKey(user: BusinessCustomerListItem): string | null {
|
||||
function accessBadgeKey(user: BusinessCustomerListItem): BusinessMessageKey | null {
|
||||
if (user.isBusinessOwner) return 'customers.access.badge.owner'
|
||||
if (user.teamRole === 'admin') return 'customers.access.badge.admin'
|
||||
if (user.teamRole === 'editor') return 'customers.access.badge.editor'
|
||||
@@ -61,6 +62,13 @@ function accessBadgeKey(user: BusinessCustomerListItem): string | null {
|
||||
return null
|
||||
}
|
||||
|
||||
function teamRoleMessageKey(teamRole: string): BusinessMessageKey {
|
||||
if (teamRole === 'admin') return 'customers.access.role.admin'
|
||||
if (teamRole === 'editor') return 'customers.access.role.editor'
|
||||
if (teamRole === 'viewer') return 'customers.access.role.viewer'
|
||||
return 'customers.access.badge.manager'
|
||||
}
|
||||
|
||||
export function CustomersPage() {
|
||||
const t = useT()
|
||||
const { locale } = useLocale()
|
||||
@@ -269,7 +277,7 @@ export function CustomersPage() {
|
||||
const roleLabel = updated.isBusinessOwner
|
||||
? t('customers.access.badge.owner')
|
||||
: updated.teamRole
|
||||
? t(`customers.access.role.${updated.teamRole}`)
|
||||
? t(teamRoleMessageKey(updated.teamRole))
|
||||
: t('customers.access.customer')
|
||||
showToast(t('customers.toast.accessUpdated', { role: roleLabel }), 'success')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user