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

@ -21,11 +21,14 @@ import Pagination from "./pagination";
export async function DevicesTable({
searchParams,
parentalControl,
additionalFilters = {},
}: {
searchParams: Promise<{
[key: string]: unknown;
}>;
parentalControl?: boolean;
additionalFilters?: Record<string, string | number | boolean>;
}) {
const resolvedParams = await searchParams;
const session = await getServerSession(authOptions);
@ -42,9 +45,15 @@ export async function DevicesTable({
apiParams[key] = typeof value === "number" ? value : String(value);
}
}
for (const [key, value] of Object.entries(additionalFilters)) {
if (value !== undefined && value !== "") {
apiParams[key] = typeof value === "number" ? value : String(value);
}
}
apiParams.limit = limit;
apiParams.offset = offset;
console.log("API Params:", apiParams);
const [error, devices] = await tryCatch(
getDevices(apiParams),
);