"use client";
import { LocalizationProvider } from "@mui/x-date-pickers";
import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFnsV3";
import { AppStore, persistor, store } from '../lib/store'
import { useRef } from "react";
import { Provider } from "react-redux";
import { StyledEngineProvider } from "@mui/material";
import { PersistGate } from "redux-persist/integration/react";
import { GuardedRoute } from "./RouteGuard";
export default function AppProvider({children}:{children: React.ReactNode}) {
    return (
        <LocalizationProvider dateAdapter={AdapterDateFns}>  
            <Provider store={store}>
                <PersistGate loading={null} persistor={persistor}>
                    <StyledEngineProvider injectFirst>
                        <GuardedRoute>
                            {children}
                        </GuardedRoute>
                    </StyledEngineProvider>
                </PersistGate>
            </Provider>
        </LocalizationProvider>
    )
}