28 lines
799 B
TypeScript
28 lines
799 B
TypeScript
import { BadgeProps, Text } from '@chakra-ui/react';
|
|
import { IconBadge } from './WorkingListCard';
|
|
|
|
interface WorkingRatingParams {
|
|
rating: string;
|
|
color: BadgeProps['backgroundColor'];
|
|
iconClass: string;
|
|
}
|
|
|
|
export function WorkingRatingBadge({ ratingTotal }: { ratingTotal: number }) {
|
|
const ratingParams: WorkingRatingParams =
|
|
ratingTotal >= 0
|
|
? {
|
|
rating: ratingTotal.toString(),
|
|
color: 'green.500',
|
|
iconClass: 'nf nf-fa-angle_up'
|
|
}
|
|
: {
|
|
rating: ratingTotal.toString().slice(1),
|
|
color: 'red.500',
|
|
iconClass: 'nf nf-fa-angle_down'
|
|
};
|
|
return (
|
|
<IconBadge backgroundColor={ratingParams.color} iconClass={ratingParams.iconClass}>
|
|
<Text>{ratingParams.rating}</Text>
|
|
</IconBadge>
|
|
);
|
|
}
|