'use client' import Input from '@/components/formElements/Input' import { texts } from '@/texts' interface CancellationPolicyEditorProps { disabled?: boolean cancellationFeePercent: number cancellationFeePercent12To24Hours: number cancellationFeePercentMoreThan24Hours: number onChange: ( field: 'cancellationFeePercent' | 'cancellationFeePercent12To24Hours' | 'cancellationFeePercentMoreThan24Hours', value: number ) => void } /** * Makes all three time-based cancellation fee tiers explicit to hosts. */ export default function CancellationPolicyEditor({ disabled = false, cancellationFeePercent, cancellationFeePercent12To24Hours, cancellationFeePercentMoreThan24Hours, onChange, }: CancellationPolicyEditorProps) { const tiers = [ { field: 'cancellationFeePercentMoreThan24Hours' as const, label: texts.events.cancellationFeeMoreThan24HoursLabel, value: cancellationFeePercentMoreThan24Hours, }, { field: 'cancellationFeePercent12To24Hours' as const, label: texts.events.cancellationFee12To24HoursLabel, value: cancellationFeePercent12To24Hours, }, { field: 'cancellationFeePercent' as const, label: texts.events.cancellationFeeLabel, value: cancellationFeePercent, }, ] return (
{tiers.map((tier) => { const normalizedValue = Number.isFinite(tier.value) ? Math.min(100, Math.max(0, tier.value)) : 0 return (

{tier.label}

{ const next = Number(nextValue) onChange(tier.field, Number.isFinite(next) ? Math.min(100, Math.max(0, next)) : 0) }} /> ٪
) })}
) }