Add Agreements page, enhance Devices and Users components with sorting and filtering options, and implement user verification dialogs

- Introduced a new Agreements page for managing agreements in the dashboard.
- Enhanced the Devices page by adding sorting and filtering options for better device management.
- Updated the Users page to include sorting functionality and improved layout.
- Implemented user verification and rejection dialogs for better user management.
- Added InputReadOnly component for displaying user information in a read-only format.
- Refactored search component to improve usability and visual consistency.
This commit is contained in:
2024-12-01 23:19:31 +05:00
parent 2b0bd515e7
commit 9021f01ff4
16 changed files with 459 additions and 107 deletions

View File

@ -9,9 +9,10 @@ import {
TableRow,
} from "@/components/ui/table";
import prisma from "@/lib/db";
import Link from "next/link";
import Pagination from "./pagination";
import { Badge } from "./ui/badge";
import { UserVerifyDialog } from "./user/user-verify-dialog";
import { Button } from "./ui/button";
export async function UsersTable({
searchParams,
@ -43,7 +44,7 @@ export async function UsersTable({
},
},
{
house_name: {
address: {
contains: query || "",
mode: "insensitive",
},
@ -57,6 +58,7 @@ export async function UsersTable({
],
verified: verified === "all" ? undefined : verified === "verified",
},
});
const totalPages = Math.ceil(totalUsers / 10);
@ -79,7 +81,7 @@ export async function UsersTable({
},
},
{
house_name: {
address: {
contains: query || "",
mode: "insensitive",
},
@ -92,6 +94,7 @@ export async function UsersTable({
},
],
verified: verified === "all" ? undefined : verified === "verified",
},
include: {
island: true,
@ -100,7 +103,7 @@ export async function UsersTable({
skip: offset,
take: limit,
orderBy: {
name: `${sortBy}` as "asc" | "desc",
id: `${sortBy}` as "asc" | "desc",
},
});
@ -146,7 +149,7 @@ export async function UsersTable({
<TableCell className="font-medium">{user.id_card}</TableCell>
<TableCell>{user.atoll?.name}</TableCell>
<TableCell>{user.island?.name}</TableCell>
<TableCell>{user.house_name}</TableCell>
<TableCell>{user.address}</TableCell>
<TableCell>
{user.verified ? (
@ -175,7 +178,11 @@ export async function UsersTable({
<TableCell>{user.phoneNumber}</TableCell>
<TableCell>
<UserVerifyDialog user={user} />
<Link href={`/users/${user.id}/verify`}>
<Button>
Details
</Button>
</Link>
</TableCell>
</TableRow>
))}