fix: reorder hooks to resolve handleSync declaration order

This commit is contained in:
2026-04-19 14:22:26 +03:00
parent cbcd9263e0
commit cc6b55ec0f
3 changed files with 9 additions and 24 deletions

View File

@@ -61,6 +61,12 @@ export default function Home() {
const [comparisonModal, setComparisonModal] = useState<{ show: boolean, newItem: any, existingItem: any, existingId: number | null }>({ show: false, newItem: null, existingItem: null, existingId: null });
const [comparisonLoading, setComparisonLoading] = useState(false);
const { syncing, handleSync } = useSync({
isOnline,
currentUser,
onInventoryUpdate: setInventory
});
const {
mode,
setMode,
@@ -106,12 +112,6 @@ export default function Home() {
onInventoryUpdate: setInventory
});
const { syncing, handleSync } = useSync({
isOnline,
currentUser,
onInventoryUpdate: setInventory
});
useEffect(() => {
if (!localStorage.getItem('inventory_token')) {
window.location.href = '/login';
@@ -163,22 +163,6 @@ export default function Home() {
}
};
const handleSync = useCallback(async () => {
if (!isOnline || !currentUser) return;
setSyncing(true);
try {
const result = await syncOfflineOperations(currentUser.id);
if (result.success > 0) {
toast.success(`Synced ${result.success} operations!`);
}
await loadInventory();
} catch (error) {
console.error("Sync failed", error);
} finally {
setSyncing(false);
}
}, [isOnline, currentUser]);
const handleOnboardingComplete = async (itemData: any) => {
try {
if (itemData.part_number) {

File diff suppressed because one or more lines are too long