mirror of
https://git.meshkee.com/Meshkee/dashboards.git
synced 2026-08-11 22:30:58 +04:30
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
@@ -2,6 +2,7 @@ import { useEffect, useMemo, useState } from 'react'
|
|||||||
import { createPortal } from 'react-dom'
|
import { createPortal } from 'react-dom'
|
||||||
import { X } from 'lucide-react'
|
import { X } from 'lucide-react'
|
||||||
import { useT } from '../i18n/useT'
|
import { useT } from '../i18n/useT'
|
||||||
|
import type { BusinessMessageKey } from '../i18n/messages'
|
||||||
import { ApiError } from '../lib/api'
|
import { ApiError } from '../lib/api'
|
||||||
import {
|
import {
|
||||||
assignBusinessAccess,
|
assignBusinessAccess,
|
||||||
@@ -16,6 +17,12 @@ const ANIMATION_MS = 220
|
|||||||
const ALL_TEAM_ROLES = ['admin', 'editor', 'viewer'] as const
|
const ALL_TEAM_ROLES = ['admin', 'editor', 'viewer'] as const
|
||||||
const BUSINESS_TEAM_ROLES = ['editor', 'viewer'] as const
|
const BUSINESS_TEAM_ROLES = ['editor', 'viewer'] as const
|
||||||
|
|
||||||
|
const TEAM_ROLE_LABEL_KEYS: Record<(typeof ALL_TEAM_ROLES)[number], BusinessMessageKey> = {
|
||||||
|
admin: 'customers.access.role.admin',
|
||||||
|
editor: 'customers.access.role.editor',
|
||||||
|
viewer: 'customers.access.role.viewer',
|
||||||
|
}
|
||||||
|
|
||||||
export interface ChangeUserAccessModalProps {
|
export interface ChangeUserAccessModalProps {
|
||||||
open: boolean
|
open: boolean
|
||||||
user: BusinessCustomerListItem | null
|
user: BusinessCustomerListItem | null
|
||||||
@@ -195,7 +202,7 @@ export function ChangeUserAccessModal({
|
|||||||
disabled={submitting}
|
disabled={submitting}
|
||||||
/>
|
/>
|
||||||
<span className={styles.roleOptionLabel}>
|
<span className={styles.roleOptionLabel}>
|
||||||
{t(`customers.access.role.${slug}`)}
|
{t(TEAM_ROLE_LABEL_KEYS[slug as (typeof ALL_TEAM_ROLES)[number]])}
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { Tooltip } from '../components/Tooltip'
|
|||||||
import { useAuth } from '../context/AuthContext'
|
import { useAuth } from '../context/AuthContext'
|
||||||
import { useToast } from '../context/ToastContext'
|
import { useToast } from '../context/ToastContext'
|
||||||
import { useT } from '../i18n/useT'
|
import { useT } from '../i18n/useT'
|
||||||
|
import type { BusinessMessageKey } from '../i18n/messages'
|
||||||
import { ApiError, isAbortError } from '../lib/api'
|
import { ApiError, isAbortError } from '../lib/api'
|
||||||
import { getActiveBusinessId } from '../lib/businessContext'
|
import { getActiveBusinessId } from '../lib/businessContext'
|
||||||
import { formatCellForDisplay } from '../lib/cellNumber'
|
import { formatCellForDisplay } from '../lib/cellNumber'
|
||||||
@@ -52,7 +53,7 @@ function formatTransactionTotal(total: number | null | undefined) {
|
|||||||
return formatIrtPrice(total)
|
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.isBusinessOwner) return 'customers.access.badge.owner'
|
||||||
if (user.teamRole === 'admin') return 'customers.access.badge.admin'
|
if (user.teamRole === 'admin') return 'customers.access.badge.admin'
|
||||||
if (user.teamRole === 'editor') return 'customers.access.badge.editor'
|
if (user.teamRole === 'editor') return 'customers.access.badge.editor'
|
||||||
@@ -61,6 +62,13 @@ function accessBadgeKey(user: BusinessCustomerListItem): string | null {
|
|||||||
return 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() {
|
export function CustomersPage() {
|
||||||
const t = useT()
|
const t = useT()
|
||||||
const { locale } = useLocale()
|
const { locale } = useLocale()
|
||||||
@@ -269,7 +277,7 @@ export function CustomersPage() {
|
|||||||
const roleLabel = updated.isBusinessOwner
|
const roleLabel = updated.isBusinessOwner
|
||||||
? t('customers.access.badge.owner')
|
? t('customers.access.badge.owner')
|
||||||
: updated.teamRole
|
: updated.teamRole
|
||||||
? t(`customers.access.role.${updated.teamRole}`)
|
? t(teamRoleMessageKey(updated.teamRole))
|
||||||
: t('customers.access.customer')
|
: t('customers.access.customer')
|
||||||
showToast(t('customers.toast.accessUpdated', { role: roleLabel }), 'success')
|
showToast(t('customers.toast.accessUpdated', { role: roleLabel }), 'success')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user