fix(ui): render singular label for ArrayCell when length is 1 (#7586)

## Description

V2 PR [here](https://github.com/payloadcms/payload/pull/7585)

- [x] I have read and understand the
[CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md)
document in this repository.

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)

## Checklist:

- [x] Existing test suite passes locally with my changes
This commit is contained in:
Patrik
2024-08-12 10:33:28 -04:00
committed by GitHub
parent 5dfcffa281
commit f88cef5470

View File

@@ -15,10 +15,10 @@ export const ArrayCell: React.FC<ArrayCellProps> = ({ cellData, labels }) => {
const arrayFields = cellData ?? []
const label = `${arrayFields.length} ${getTranslation(
labels?.plural || i18n.t('general:rows'),
i18n,
)}`
const label =
arrayFields.length === 1
? `${arrayFields.length} ${getTranslation(labels?.singular || i18n.t('general:rows'), i18n)}`
: `${arrayFields.length} ${getTranslation(labels?.plural || i18n.t('general:rows'), i18n)}`
return <span>{label}</span>
}