refactor(places): one label for a rating badge

The list rows and the map pins wrote the average with their own copy of
the whole star or one decimal rule; both now read ratingBadge.
This commit is contained in:
Maurice
2026-11-30 12:34:50 +01:00
parent 7008427022
commit 501e4449ef
2 changed files with 5 additions and 6 deletions
@@ -7,9 +7,7 @@ import StatusBadge from './StatusBadge'
import EntryTagDots from './EntryTagDots'
import { usePlaceReorder } from './usePlaceReorder'
import CategoryBadge from './CategoryBadge'
/** A vote average as the map's pins write it: a whole number bare, else one decimal. */
const ratingLabel = (rating: number): string => (Number.isInteger(rating) ? String(rating) : rating.toFixed(1))
import { ratingBadge } from './ratingLabel'
interface CollectionListProps {
@@ -50,7 +48,7 @@ function rowClass(on: boolean, canReorder: boolean, dragging: boolean, dropSide:
*/
function RowAvatar({ place, t }: { place: CollectionPlace; t: TranslationFn }) {
const category = place.category ? { color: place.category.color ?? undefined, icon: place.category.icon ?? undefined } : null
const rating = typeof place.rating_avg === 'number' && place.rating_avg > 0 ? ratingLabel(place.rating_avg) : null
const rating = ratingBadge(place.rating_avg)
return (
<span className="col-lrow-avatar">
<PlaceAvatar place={place} size={40} category={category} />