mirror of
https://github.com/Luchexx/wacrm.git
synced 2026-11-02 09:19:51 +00:00
refactor: improve type safety for translations by replacing any types with specific parameters and node types
This commit is contained in:
parent
eeea478315
commit
a6596de2c9
@ -198,7 +198,7 @@ export function InviteMemberDialog({
|
||||
{t.rich('inviteCreatedDesc', {
|
||||
role: tRoles(result.role),
|
||||
days: result.expiresInDays,
|
||||
bold: (chunks: any) => <strong>{chunks}</strong>
|
||||
bold: (chunks: React.ReactNode) => <strong>{chunks}</strong>
|
||||
})}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
@ -305,7 +305,7 @@ export function InviteMemberDialog({
|
||||
<SelectContent>
|
||||
{EXPIRY_OPTIONS.map((opt) => (
|
||||
<SelectItem key={opt.value} value={opt.value}>
|
||||
{t(opt.labelKey as any)}
|
||||
{t(opt.labelKey as Parameters<typeof t>[0])}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
|
||||
@ -115,7 +115,7 @@ function fmtDate(iso: string): string {
|
||||
});
|
||||
}
|
||||
|
||||
function fmtExpiresIn(iso: string, t: any): string {
|
||||
function fmtExpiresIn(iso: string, t: (key: string, values?: Record<string, unknown>) => string): string {
|
||||
const ms = new Date(iso).getTime() - Date.now();
|
||||
if (ms <= 0) return t('expired');
|
||||
const days = Math.floor(ms / (24 * 60 * 60 * 1000));
|
||||
@ -579,7 +579,7 @@ export function MembersTab() {
|
||||
<DialogDescription className="text-muted-foreground">
|
||||
{t.rich('removeDialogDesc', {
|
||||
name: removingMember?.full_name || t('unnamed'),
|
||||
bold: (chunks: any) => <strong>{chunks}</strong>
|
||||
bold: (chunks: React.ReactNode) => <strong>{chunks}</strong>
|
||||
})}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
@ -297,7 +297,7 @@ export function ProfileForm() {
|
||||
{t.rich('emailChangeHint', {
|
||||
oldEmail: profile?.email || '',
|
||||
newEmail: email,
|
||||
bold: (chunks: any) => <strong>{chunks}</strong>
|
||||
bold: (chunks: React.ReactNode) => <strong>{chunks}</strong>
|
||||
})}
|
||||
</span>
|
||||
</p>
|
||||
|
||||
@ -188,7 +188,7 @@ export function TagManager() {
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => confirmDelete(tag)}
|
||||
aria-label={t('deleteAria', { name: tag.name })}
|
||||
aria-label={t('deleteAria', { name: tag.name, bold: (chunks: React.ReactNode) => <strong>{chunks}</strong> })}
|
||||
className="ml-0.5 rounded-full p-0.5 opacity-60 transition-opacity hover:bg-black/10 hover:opacity-100 dark:hover:bg-white/10"
|
||||
>
|
||||
<X className="size-3" />
|
||||
@ -221,7 +221,7 @@ export function TagManager() {
|
||||
key={color.value}
|
||||
type="button"
|
||||
onClick={() => setSelectedColor(color.value)}
|
||||
aria-label={t('useColor', { color: t(`colors.${color.name}` as any) })}
|
||||
aria-label={t('useColor', { color: t(`colors.${color.name}` as Parameters<typeof t>[0]) })}
|
||||
aria-pressed={selectedColor === color.value}
|
||||
className={cn(
|
||||
'size-6 rounded-md transition-transform hover:scale-110',
|
||||
@ -229,7 +229,7 @@ export function TagManager() {
|
||||
'outline outline-2 outline-offset-2 outline-primary',
|
||||
)}
|
||||
style={{ backgroundColor: color.value }}
|
||||
title={t(`colors.${color.name}` as any)}
|
||||
title={t(`colors.${color.name}` as Parameters<typeof t>[0])}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user