mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-14 02:38:58 +02:00
Restored to '479577c4ff1b136dd2b1cea9dffd6c0fc0018d59'
Replit-Restored-To: 479577c4ff
This commit is contained in:
1 parent
1346c9b34c
commit
a4a637d415
13 files changed
+128
-347
No files matched your search
@@ -1,30 +0,0 @@
|
||||
import { useState, useMemo, useEffect } from 'react';
|
||||
|
||||
export function usePagination<T>(data: T[], initialItemsPerPage: number = 10) {
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [itemsPerPage, setItemsPerPage] = useState(initialItemsPerPage);
|
||||
|
||||
const totalItems = data.length;
|
||||
const totalPages = Math.ceil(totalItems / itemsPerPage);
|
||||
|
||||
// Reset to first page when data changes
|
||||
useEffect(() => {
|
||||
setCurrentPage(1);
|
||||
}, [data.length, itemsPerPage]);
|
||||
|
||||
const paginatedData = useMemo(() => {
|
||||
const startIndex = (currentPage - 1) * itemsPerPage;
|
||||
const endIndex = startIndex + itemsPerPage;
|
||||
return data.slice(startIndex, endIndex);
|
||||
}, [data, currentPage, itemsPerPage]);
|
||||
|
||||
return {
|
||||
currentPage,
|
||||
setCurrentPage,
|
||||
itemsPerPage,
|
||||
setItemsPerPage,
|
||||
totalPages,
|
||||
totalItems,
|
||||
paginatedData,
|
||||
};
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
interface ResponsiveState {
|
||||
isMobile: boolean;
|
||||
isTablet: boolean;
|
||||
isDesktop: boolean;
|
||||
screenWidth: number;
|
||||
}
|
||||
|
||||
const BREAKPOINTS = {
|
||||
mobile: 768,
|
||||
tablet: 1024,
|
||||
} as const;
|
||||
|
||||
export function useResponsive(): ResponsiveState {
|
||||
const [state, setState] = useState<ResponsiveState>(() => {
|
||||
if (typeof window === 'undefined') {
|
||||
return {
|
||||
isMobile: false,
|
||||
isTablet: false,
|
||||
isDesktop: true,
|
||||
screenWidth: 1920,
|
||||
};
|
||||
}
|
||||
|
||||
const width = window.innerWidth;
|
||||
return {
|
||||
isMobile: width < BREAKPOINTS.mobile,
|
||||
isTablet: width >= BREAKPOINTS.mobile && width < BREAKPOINTS.tablet,
|
||||
isDesktop: width >= BREAKPOINTS.tablet,
|
||||
screenWidth: width,
|
||||
};
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
const width = window.innerWidth;
|
||||
setState({
|
||||
isMobile: width < BREAKPOINTS.mobile,
|
||||
isTablet: width >= BREAKPOINTS.mobile && width < BREAKPOINTS.tablet,
|
||||
isDesktop: width >= BREAKPOINTS.tablet,
|
||||
screenWidth: width,
|
||||
});
|
||||
};
|
||||
|
||||
window.addEventListener('resize', handleResize);
|
||||
return () => window.removeEventListener('resize', handleResize);
|
||||
}, []);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
// Hook spécialisé pour la navigation mobile
|
||||
export function useIsMobileNavigation() {
|
||||
const { isMobile } = useResponsive();
|
||||
return isMobile;
|
||||
}
|
||||
Reference in new issue
Block a user