mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 02:14:05 +00:00
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:
@@ -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} />
|
||||
|
||||
Reference in New Issue
Block a user