mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-07 12:46:30 +00:00
refactor: enhance parental control features and improve device blocking logic 🔨
This commit is contained in:
@ -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>
|
||||
|
@ -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">
|
||||
|
Reference in New Issue
Block a user