Skip to content

Commit 96137df

Browse files
Copilothotlong
andcommitted
fix: address code review — extract STATUS_FIELD_NAMES constant, fix label fallback, add clipboard .catch()
- Extract STATUS_FIELD_NAMES Set for maintainability - Fix label fallback to use fieldName variable instead of 'Inactive' - Add .catch() to clipboard operations for insecure contexts Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 635923c commit 96137df

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

packages/fields/src/index.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ export function PercentCellRenderer({ value, field }: CellRendererProps): React.
263263
);
264264
}
265265

266+
/** Field names that trigger warning badge when boolean value is false */
267+
const STATUS_FIELD_NAMES = new Set([
268+
'active', 'is_active', 'enabled', 'is_enabled', 'verified', 'is_verified',
269+
]);
270+
266271
/**
267272
* Boolean field cell renderer (Airtable-style checkbox)
268273
* Supports semantic rendering for completion fields (green indicator)
@@ -294,14 +299,10 @@ export function BooleanCellRenderer({ value, field }: CellRendererProps): React.
294299
}
295300

296301
// Warning badge for active/enabled fields when false
297-
const isStatusField = fieldName === 'active' || fieldName === 'is_active'
298-
|| fieldName === 'enabled' || fieldName === 'is_enabled'
299-
|| fieldName === 'verified' || fieldName === 'is_verified';
300-
301-
if (isStatusField && !value) {
302+
if (STATUS_FIELD_NAMES.has(fieldName) && !value) {
302303
return (
303304
<Badge variant="destructive" className="text-xs" data-testid="boolean-warning-badge">
304-
{field?.label || humanizeLabel(field?.name || 'Inactive')} — Off
305+
{field?.label || humanizeLabel(fieldName)} — Off
305306
</Badge>
306307
);
307308
}
@@ -458,7 +459,7 @@ export function EmailCellRenderer({ value }: CellRendererProps): React.ReactElem
458459
navigator.clipboard.writeText(String(value)).then(() => {
459460
setCopied(true);
460461
setTimeout(() => setCopied(false), 2000);
461-
});
462+
}).catch(() => { /* clipboard not available */ });
462463
};
463464

464465
return (
@@ -529,7 +530,7 @@ export function PhoneCellRenderer({ value }: CellRendererProps): React.ReactElem
529530
navigator.clipboard.writeText(String(value)).then(() => {
530531
setCopied(true);
531532
setTimeout(() => setCopied(false), 2000);
532-
});
533+
}).catch(() => { /* clipboard not available */ });
533534
};
534535

535536
return (

0 commit comments

Comments
 (0)