mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-15 11:19:43 +02:00
Refactor store context and improve responsiveness across the application
Refactored the `useStore` hook to be imported from a dedicated `StoreContext` to improve code organization and maintainability. Also, enhanced responsive design for better usability on various screen sizes, including tablet-specific adjustments for the sidebar and header. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 95e8aab4-f39f-4b48-aa57-a759ec15ba3d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/95e8aab4-f39f-4b48-aa57-a759ec15ba3d/A90CXrX
This commit is contained in:
1 parent
d2f2a532a5
commit
d0cecf90f3
29 files changed
+957
-254
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { ReactNode, createContext, useContext } from "react";
|
||||
import type { Group } from "@shared/schema";
|
||||
|
||||
interface StoreContextType {
|
||||
selectedStoreId: number | null;
|
||||
setSelectedStoreId: (storeId: number | null) => void;
|
||||
stores: Group[];
|
||||
sidebarCollapsed: boolean;
|
||||
setSidebarCollapsed: (collapsed: boolean) => void;
|
||||
mobileMenuOpen: boolean;
|
||||
setMobileMenuOpen: (open: boolean) => void;
|
||||
storeInitialized: boolean;
|
||||
}
|
||||
|
||||
const StoreContext = createContext<StoreContextType | undefined>(undefined);
|
||||
|
||||
export const useStore = () => {
|
||||
const context = useContext(StoreContext);
|
||||
if (!context) {
|
||||
throw new Error("useStore must be used within a StoreProvider");
|
||||
}
|
||||
return context;
|
||||
};
|
||||
|
||||
interface StoreProviderProps {
|
||||
children: ReactNode;
|
||||
value: StoreContextType;
|
||||
}
|
||||
|
||||
export function StoreProvider({ children, value }: StoreProviderProps) {
|
||||
return <StoreContext.Provider value={value}>{children}</StoreContext.Provider>;
|
||||
}
|
||||
Reference in new issue
Block a user