import { useEffect } from 'react';
import { Stack } from 'expo-router';
import { StatusBar } from 'expo-status-bar';
import { useAuthStore } from '../store/auth-store';
import { useNotesStore } from '../store/notes-store';
import { useWorkspaceStore } from '../store/workspace-store';

export default function RootLayout() {
  const bootstrapAuth = useAuthStore((state) => state.bootstrap);
  const hydrateNotes = useNotesStore((state) => state.hydrate);
  const hydrateWorkspaces = useWorkspaceStore((state) => state.hydrate);

  useEffect(() => {
    void bootstrapAuth();
    void hydrateNotes();
    void hydrateWorkspaces();
  }, [bootstrapAuth, hydrateNotes, hydrateWorkspaces]);

  return (
    <>
      <StatusBar style="light" />
      <Stack
        screenOptions={{
          headerShown: false,
          animation: 'fade',
        }}
      />
    </>
  );
}
