Spaces:
Sleeping
Sleeping
FauziIsyrinApridal commited on
Commit ·
c6e8b99
1
Parent(s): 4c1af35
add feedback
Browse files
app/(main)/components/RagDashboard.tsx
CHANGED
|
@@ -220,7 +220,9 @@ export default function RagDashboard() {
|
|
| 220 |
))}
|
| 221 |
</DropdownMenuContent>
|
| 222 |
</DropdownMenu>
|
| 223 |
-
|
|
|
|
|
|
|
| 224 |
<Button asChild className="bg-orange-600 hover:bg-orange-800">
|
| 225 |
<Link href={"/upload-document"}>Upload Document</Link>
|
| 226 |
</Button>
|
|
|
|
| 220 |
))}
|
| 221 |
</DropdownMenuContent>
|
| 222 |
</DropdownMenu>
|
| 223 |
+
<Button asChild className="bg-orange-600 hover:bg-orange-800">
|
| 224 |
+
<Link href={"/feedback"}>Feedback</Link>
|
| 225 |
+
</Button>
|
| 226 |
<Button asChild className="bg-orange-600 hover:bg-orange-800">
|
| 227 |
<Link href={"/upload-document"}>Upload Document</Link>
|
| 228 |
</Button>
|
app/(main)/feedback/page.tsx
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import { useEffect, useState } from "react";
|
| 4 |
+
import { createClient } from "@/utils/supabase/client";
|
| 5 |
+
import {
|
| 6 |
+
Table,
|
| 7 |
+
TableHeader,
|
| 8 |
+
TableBody,
|
| 9 |
+
TableHead,
|
| 10 |
+
TableRow,
|
| 11 |
+
TableCell,
|
| 12 |
+
} from "@/components/ui/table";
|
| 13 |
+
import { revalidatePath } from "next/cache";
|
| 14 |
+
import { redirect } from "next/navigation";
|
| 15 |
+
|
| 16 |
+
type Feedback = {
|
| 17 |
+
id: number;
|
| 18 |
+
message: string;
|
| 19 |
+
created_at: string;
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
export default async function FeedbackPage() {
|
| 23 |
+
const supabase = createClient();
|
| 24 |
+
|
| 25 |
+
const {
|
| 26 |
+
data: { session },
|
| 27 |
+
} = await supabase.auth.getSession();
|
| 28 |
+
|
| 29 |
+
if (!session) {
|
| 30 |
+
revalidatePath("/login", "page");
|
| 31 |
+
redirect("/login");
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
const [feedbacks, setFeedbacks] = useState<Feedback[]>([]);
|
| 35 |
+
const [loading, setLoading] = useState(true);
|
| 36 |
+
|
| 37 |
+
useEffect(() => {
|
| 38 |
+
const fetchFeedbacks = async () => {
|
| 39 |
+
const { data, error } = await supabase
|
| 40 |
+
.from("feedback")
|
| 41 |
+
.select("*")
|
| 42 |
+
.order("created_at", { ascending: false });
|
| 43 |
+
|
| 44 |
+
if (!error && data) {
|
| 45 |
+
setFeedbacks(data);
|
| 46 |
+
}
|
| 47 |
+
setLoading(false);
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
fetchFeedbacks();
|
| 51 |
+
}, []);
|
| 52 |
+
|
| 53 |
+
return (
|
| 54 |
+
<div className="mx-auto max-w-5xl p-4">
|
| 55 |
+
<h1 className="mb-6 text-2xl font-semibold">📋 Feedback Pengguna</h1>
|
| 56 |
+
|
| 57 |
+
{loading ? (
|
| 58 |
+
<p>Memuat data feedback...</p>
|
| 59 |
+
) : feedbacks.length === 0 ? (
|
| 60 |
+
<p className="text-muted-foreground">
|
| 61 |
+
Belum ada feedback yang dikirim.
|
| 62 |
+
</p>
|
| 63 |
+
) : (
|
| 64 |
+
<Table>
|
| 65 |
+
<TableHeader>
|
| 66 |
+
<TableRow>
|
| 67 |
+
<TableHead>ID</TableHead>
|
| 68 |
+
<TableHead>Pesan</TableHead>
|
| 69 |
+
<TableHead className="text-right">Tanggal</TableHead>
|
| 70 |
+
</TableRow>
|
| 71 |
+
</TableHeader>
|
| 72 |
+
<TableBody>
|
| 73 |
+
{feedbacks.map((fb) => (
|
| 74 |
+
<TableRow key={fb.id}>
|
| 75 |
+
<TableCell>{fb.id}</TableCell>
|
| 76 |
+
<TableCell className="max-w-[500px] whitespace-pre-line">
|
| 77 |
+
{fb.message}
|
| 78 |
+
</TableCell>
|
| 79 |
+
<TableCell className="text-right text-sm text-muted-foreground">
|
| 80 |
+
{new Date(fb.created_at).toLocaleString("id-ID")}
|
| 81 |
+
</TableCell>
|
| 82 |
+
</TableRow>
|
| 83 |
+
))}
|
| 84 |
+
</TableBody>
|
| 85 |
+
</Table>
|
| 86 |
+
)}
|
| 87 |
+
</div>
|
| 88 |
+
);
|
| 89 |
+
}
|