import React from 'react';
export * from '@digigov/react-core/CircularProgressBase';
import CircularProgressBase, {
  CircularProgressBaseProps,
} from '@digigov/react-core/CircularProgressBase';
import { useNotificationArea } from '@digigov/ui/app/hooks/useNotificationArea';

export interface CircularProgressProps extends CircularProgressBaseProps {
  /**
   * loadingText prop is optional
   * Text for screen readers when loading starts
   * @default "Γίνεται φόρτωση..."
   */
  loadingText?: string;
  /**
   * loadingFinishedText prop is optional
   * Text for screen readers when loading finishes
   * @default "Η φόρτωση ολοκληρώθηκε."
   */
  loadingFinishedText?: string;
}

export const CircularProgress = React.forwardRef<
  SVGElement,
  CircularProgressProps
>(function CircularProgress(
  {
    loadingText = 'Γίνεται φόρτωση...',
    loadingFinishedText = 'Η φόρτωση ολοκληρώθηκε.',
    ...props
  },
  ref
) {
  useNotificationArea(loadingText, loadingFinishedText);

  return <CircularProgressBase ref={ref} {...props} />;
});

export default CircularProgress;
