All files / src/ui/Statistic StatisticWithProvider.tsx

100% Statements 52/52
83.33% Branches 5/6
100% Functions 2/2
100% Lines 52/52

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 741x 1x     1x 1x 1x 1x     1x 1x     1x 1x   1x 3x   3x 3x 3x 3x   3x 3x 1x 1x 1x 1x   3x 3x   3x 3x     3x 3x 3x   3x 3x 3x 3x   3x   3x   1x 3x 3x 3x     3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x   3x   1x  
import { useEffect } from 'react';
import '@copilotkit/react-ui/styles.css';
 
// Providers
import { QueryProvider } from '@/providers/QueryProvider';
import { ChatBotWrapper } from '@/providers/chatbot';
import { AuthProvider, FirebaseProvider, useAuthContext } from '@/providers';
import { StatisticProvider } from '@/providers/statistic';
 
// Components
import ChatBot from '@/components/Chatbot';
import Statistic from './';
 
// Types
import { UserProfile, UserRole } from '@/types';
import { UserGroup } from '@shared/types';
 
const StatisticContent = () => {
  useEffect(() => {
    // Remove SSR skeleton once React is ready
    const skeleton = document.getElementById('statistic-skeleton');
    if (skeleton) skeleton.remove();
  }, []);
  const { user: userProfile } = useAuthContext();
 
  const isShowChatbot =
    userProfile.role === UserRole.ADMIN ||
    (userProfile &&
      userProfile.groups.some((g: UserGroup) =>
        [UserGroup.KITCHEN_MANAGER]!.includes(g),
      ));
 
  return (
    <>
      {/* Background layer */}
      <div className="hero-background absolute -top-1 w-full h-[159px] bg-top bg-no-repeat bg-contain z-0" />
      <div className="hidden md:block background-secondary fixed top-1/2 left-3.5 -translate-y-1/2 w-[86px] h-[66px] bg-no-repeat bg-contain z-0" />
 
      {/* Page Content */}
      <div className="relative z-10 overflow-y-auto overflow-x-hidden flex flex-col flex-1">
        <Statistic />
      </div>
 
      {isShowChatbot && (
        <ChatBotWrapper>
          <ChatBot />
        </ChatBotWrapper>
      )}
    </>
  );
};
 
const StatisticWithProvider = ({
  currentOrigin,
  user,
}: {
  currentOrigin: string;
  user: UserProfile;
}) => {
  return (
    <FirebaseProvider currentOrigin={currentOrigin}>
      <QueryProvider>
        <StatisticProvider>
          <AuthProvider initialUser={user}>
            <StatisticContent />
          </AuthProvider>
        </StatisticProvider>
      </QueryProvider>
    </FirebaseProvider>
  );
};
 
export default StatisticWithProvider;