import React, { useContext } from 'react';
import { FieldNameContext } from './FieldNameContext';

interface FieldSectionProps {
  children: React.ReactNode;
  name: string;
}

export default function FieldSection({ children, name }: FieldSectionProps) {
  const parentContext = useContext(FieldNameContext);
  const effectiveValue = parentContext ? `${parentContext}.${name}` : name;

  return (
    <FieldNameContext.Provider value={effectiveValue}>
      {children}
    </FieldNameContext.Provider>
  );
}
