import React from 'react';
import { Provider } from 'react-redux';
import { PaperProvider } from 'react-native-paper';
import { store } from '../../store';
import { AuthProvider, useAuthState } from './AuthContext';
import customTheme from '../../theme';

interface RainbowProviderProps {
  children: React.ReactNode;
}

const AuthInitializer: React.FC = () => {
    useAuthState();
    return null;
}

export const RainbowProvider: React.FC<RainbowProviderProps> = ({ children }) => {
  return (
    <Provider store={store}>
      <PaperProvider theme={customTheme}>
        <AuthProvider>
            <AuthInitializer />
            {children}
        </AuthProvider>
      </PaperProvider>
    </Provider>
  );
};
