import React, { PropsWithChildren } from 'react';
import { Config, ConfigProvider } from '@elephant-healthcare/config-provider';
import { Providers } from './Providers';
import { ErrorEvent, Event, FontConfig } from './types';

interface ShellWrapperProps {
  configServicePath: string;
  appVersion: string;
  emitAnalyticsEvent: (event: Event) => void;
  emitErrorEvent: (event: ErrorEvent) => void;
  fontConfig: FontConfig;
  onConfigChange?: (config: Config) => void;
}

const ShellWrapper = ({
  configServicePath,
  appVersion,
  emitAnalyticsEvent,
  emitErrorEvent,
  onConfigChange,
  fontConfig,
  children,
}: PropsWithChildren<ShellWrapperProps>) => {
  return (
    <ConfigProvider configServicePath={configServicePath}>
      <Providers
        appVersion={appVersion}
        emitAnalyticsEvent={emitAnalyticsEvent}
        emitErrorEvent={emitErrorEvent}
        onConfigChange={onConfigChange}
        fontConfig={fontConfig}
      >
        {children}
      </Providers>
    </ConfigProvider>
  );
};

export { ShellWrapper };
