refactor: enhance parental control features and improve device blocking logic 🔨

This commit is contained in:
2025-07-02 23:29:40 +05:00
parent 40bf8413f8
commit c90b003167
7 changed files with 229 additions and 192 deletions

View File

@ -1,18 +1,22 @@
import { Suspense } from "react";
import { DevicesTable } from "@/components/devices-table";
import Search from "@/components/search";
import { Suspense } from "react";
export default async function ParentalControl({
searchParams,
}: {
searchParams: Promise<{
query: string;
page: number;
sortBy: string;
status: string;
}>;
}) {
const query = (await searchParams)?.query || "";
const parentalControlFilters = {
is_active: "true",
has_a_pending_payment: "false",
};
return (
<div>
<div className="flex justify-between items-center border rounded-md border-dashed font-bold title-bg py-4 px-2 mb-4">
@ -25,10 +29,11 @@ export default async function ParentalControl({
>
<Search />
</div>
<Suspense key={query} fallback={"loading...."}>
<Suspense key={(await searchParams).page} fallback={"loading...."}>
<DevicesTable
parentalControl={true}
searchParams={searchParams}
additionalFilters={parentalControlFilters}
/>
</Suspense>
</div>

View File

@ -1,7 +1,4 @@
import { redirect } from "next/navigation";
import { getServerSession } from "next-auth";
import { Suspense } from "react";
import { authOptions } from "@/app/auth";
import { PaymentsTable } from "@/components/payments-table";
import Search from "@/components/search";
@ -16,10 +13,7 @@ export default async function Payments({
}>;
}) {
const query = (await searchParams)?.query || "";
const session = await getServerSession(authOptions);
if (session?.user?.is_admin) {
return redirect("/user-payments");
}
return (
<div>
<div className="flex justify-between items-center border rounded-md border-dashed font-bold title-bg py-4 px-2 mb-4">