'use client' import type { ReactNode } from 'react' import type { RatingOptions } from '@/lib/types' interface RatingScaleProps { name: string legend: ReactNode ratingOptions: RatingOptions value: number | undefined required: boolean onChange: (value: number) => void error?: string } export function RatingScale({ name, legend, ratingOptions, value, required, onChange, error, }: RatingScaleProps) { const { min, max, min_label, max_label } = ratingOptions const steps = Array.from({ length: max - min + 1 }, (_, i) => min + i) return (
{legend} {required && } {required && (obligatorio)}
{steps.map((step) => { const id = `${name}_${step}` return ( ) })}
{error && ( )}
) }