Skip to content

Commit

Permalink
fix: rating field
Browse files Browse the repository at this point in the history
  • Loading branch information
MiroslavPetrik committed Mar 14, 2023
1 parent 1052537 commit 257fabd
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/rating-field/RatingField.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
NumberFieldProps,
useNumberFieldProps,
useSelectOptions,
} from "@form-atoms/field";
import { NumberFieldProps, useNumberFieldProps } from "@form-atoms/field";
import { HelperText, Rating, RatingProps } from "flowbite-react";
import { useFieldActions } from "form-atoms";

Expand All @@ -20,14 +16,6 @@ export const RatingField = ({
}: RatingProps & NumberFieldProps) => {
const props = useNumberFieldProps(field);
const actions = useFieldActions(field);
const { renderOptions } = useSelectOptions<number, number | undefined>(
field,
{
getValue: (val) => val,
getLabel: (val) => val,
options,
}
);

return (
<FlowbiteField
Expand All @@ -39,7 +27,7 @@ export const RatingField = ({
{({ color, helperText, ...fieldProps }) => (
<>
<Rating size={size} {...uiProps} {...fieldProps}>
{renderOptions.map(({ value }) => (
{options.map((value) => (
<div key={value} onClick={() => actions.setValue(value)}>
<Rating.Star
filled={props.value && value ? value <= props.value : false}
Expand Down

0 comments on commit 257fabd

Please sign in to comment.