fix: reorder hooks to resolve handleSync declaration order
This commit is contained in:
@@ -66,7 +66,8 @@
|
|||||||
"Bash(curl -sf http://localhost:8917)",
|
"Bash(curl -sf http://localhost:8917)",
|
||||||
"Bash(xargs sed *)",
|
"Bash(xargs sed *)",
|
||||||
"Bash(sed -i -e 's/\\\\btext-slate-100\\\\b/text-secondary/g' -e s/placeholder:text-slate-700/placeholder:text-muted/g -e s/hover:text-slate-300/hover:text-secondary/g app/page.tsx)",
|
"Bash(sed -i -e 's/\\\\btext-slate-100\\\\b/text-secondary/g' -e s/placeholder:text-slate-700/placeholder:text-muted/g -e s/hover:text-slate-300/hover:text-secondary/g app/page.tsx)",
|
||||||
"Bash(sed -i 's/\\\\btext-slate-300\\\\b/text-secondary/g' app/page.tsx)"
|
"Bash(sed -i 's/\\\\btext-slate-300\\\\b/text-secondary/g' app/page.tsx)",
|
||||||
|
"Bash(npx tsc *)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 [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 [comparisonLoading, setComparisonLoading] = useState(false);
|
||||||
|
|
||||||
|
const { syncing, handleSync } = useSync({
|
||||||
|
isOnline,
|
||||||
|
currentUser,
|
||||||
|
onInventoryUpdate: setInventory
|
||||||
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
mode,
|
mode,
|
||||||
setMode,
|
setMode,
|
||||||
@@ -106,12 +112,6 @@ export default function Home() {
|
|||||||
onInventoryUpdate: setInventory
|
onInventoryUpdate: setInventory
|
||||||
});
|
});
|
||||||
|
|
||||||
const { syncing, handleSync } = useSync({
|
|
||||||
isOnline,
|
|
||||||
currentUser,
|
|
||||||
onInventoryUpdate: setInventory
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!localStorage.getItem('inventory_token')) {
|
if (!localStorage.getItem('inventory_token')) {
|
||||||
window.location.href = '/login';
|
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) => {
|
const handleOnboardingComplete = async (itemData: any) => {
|
||||||
try {
|
try {
|
||||||
if (itemData.part_number) {
|
if (itemData.part_number) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user