import { useEssentials } from '@wix/fe-essentials/react';
import { dashboard } from '@wix/dashboard';
import React from 'react';
import {
  WixPatternsDashboardBaseProvider,
  WixPatternsProviderProps,
} from './WixPatternsDashboardBaseProvider';
import { useEnvironment } from './useEnvironment';

export function WixPatternsDashboardProviderInternal(
  props: WixPatternsProviderProps,
) {
  const essentials = useEssentials();
  const environment = useEnvironment();

  if (!environment) {
    return null;
  }

  return (
    <WixPatternsDashboardBaseProvider
      {...props}
      dashboard={dashboard}
      environment={environment}
      essentials={essentials}
    />
  );
}
