fix: sync pending requests from overseer

This commit is contained in:
2026-04-23 09:14:44 -04:00
parent e594b450c6
commit bf57169014
2 changed files with 73 additions and 19 deletions
+10 -6
View File
@@ -1,8 +1,9 @@
"use client";
import { useEffect, useState } from "react";
import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
Card,
CardContent,
@@ -10,7 +11,6 @@ import {
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { api, authApi, overseerApi, userApi } from "@/lib/api";
import { useStore } from "@/lib/store";
@@ -43,6 +43,7 @@ export default function DashboardPage() {
}
loadWalletAndPending();
loadCosts();
syncPending();
}, [isAuthenticated, router]);
const loadWalletAndPending = async () => {
@@ -65,6 +66,12 @@ export default function DashboardPage() {
setRequestCosts(costsRes.data);
} catch {}
};
const syncPending = async () => {
try {
await api.post("/overseer/sync-pending");
await loadWalletAndPending();
} catch {}
};
const handleLogout = async () => {
try {
await authApi.logout();
@@ -72,9 +79,6 @@ export default function DashboardPage() {
logout();
router.push("/login");
};
const handleRefresh = () => {
loadWalletAndPending();
};
if (isLoading) return <div className="p-8">Loading...</div>;
@@ -157,7 +161,7 @@ export default function DashboardPage() {
<WatchHistory />
</TabsContent>
<TabsContent value="requests">
<RequestHistory onRefresh={handleRefresh} />
<RequestHistory onRefresh={syncPending} />
</TabsContent>
<TabsContent value="leaderboard">
<Leaderboard />