feat: add dashboard refresh buttons
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
import { RefreshCw } from "lucide-react";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from "@/components/ui/card";
|
||||||
@@ -39,7 +40,7 @@ export function RequestHistory() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2 flex-wrap">
|
||||||
<Input
|
<Input
|
||||||
value={query}
|
value={query}
|
||||||
onChange={(e) => setQuery(e.target.value)}
|
onChange={(e) => setQuery(e.target.value)}
|
||||||
@@ -57,6 +58,10 @@ export function RequestHistory() {
|
|||||||
<Button variant="secondary" onClick={() => setStatus("DECLINED")}>
|
<Button variant="secondary" onClick={() => setStatus("DECLINED")}>
|
||||||
Declined
|
Declined
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button variant="outline" onClick={load}>
|
||||||
|
<RefreshCw className="mr-2 h-4 w-4" />
|
||||||
|
Refresh
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid gap-3">
|
<div className="grid gap-3">
|
||||||
{filtered.map((r) => (
|
{filtered.map((r) => (
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { RefreshCw } from "lucide-react";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
@@ -86,11 +87,8 @@ export default function DashboardPage() {
|
|||||||
try {
|
try {
|
||||||
const costsRes = await overseerApi.getCosts();
|
const costsRes = await overseerApi.getCosts();
|
||||||
setRequestCosts(costsRes.data);
|
setRequestCosts(costsRes.data);
|
||||||
} catch {
|
} catch {}
|
||||||
/* ignore */
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleLogout = async () => {
|
const handleLogout = async () => {
|
||||||
try {
|
try {
|
||||||
await authApi.logout();
|
await authApi.logout();
|
||||||
@@ -98,13 +96,20 @@ export default function DashboardPage() {
|
|||||||
logout();
|
logout();
|
||||||
router.push("/login");
|
router.push("/login");
|
||||||
};
|
};
|
||||||
|
const handleRefresh = () => {
|
||||||
|
loadWalletAndPending();
|
||||||
|
loadCosts();
|
||||||
|
};
|
||||||
|
|
||||||
if (isLoading) return <div className="p-8">Loading...</div>;
|
if (isLoading) return <div className="p-8">Loading...</div>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-8 space-y-6">
|
<div className="p-8 space-y-6">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div />
|
<Button variant="outline" onClick={handleRefresh}>
|
||||||
|
<RefreshCw className="mr-2 h-4 w-4" />
|
||||||
|
Refresh
|
||||||
|
</Button>
|
||||||
<Button variant="outline" onClick={handleLogout}>
|
<Button variant="outline" onClick={handleLogout}>
|
||||||
Logout
|
Logout
|
||||||
</Button>
|
</Button>
|
||||||
@@ -137,10 +142,14 @@ export default function DashboardPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-4">
|
<div className="mt-4 flex gap-2">
|
||||||
<Button onClick={() => setIsSearchModalOpen(true)}>
|
<Button onClick={() => setIsSearchModalOpen(true)}>
|
||||||
Request content
|
Request content
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button variant="secondary" onClick={handleRefresh}>
|
||||||
|
<RefreshCw className="mr-2 h-4 w-4" />
|
||||||
|
Check requests
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
Reference in New Issue
Block a user