mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-01 15:23:58 +00:00
refactor: update authentication flow to use NextAuth, replace better-auth with axios for API calls, and clean up unused code
This commit is contained in:
@ -8,7 +8,7 @@ import {
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { auth } from "@/lib/auth";
|
||||
import { auth } from "@/app/auth";
|
||||
import prisma from "@/lib/db";
|
||||
import { headers } from "next/headers";
|
||||
import ClickableRow from "./clickable-row";
|
||||
@ -27,9 +27,9 @@ export async function DevicesTable({
|
||||
parentalControl?: boolean;
|
||||
}) {
|
||||
const session = await auth.api.getSession({
|
||||
headers: await headers()
|
||||
})
|
||||
const isAdmin = session?.user.role === "ADMIN"
|
||||
headers: await headers(),
|
||||
});
|
||||
const isAdmin = session?.user.role === "ADMIN";
|
||||
const query = (await searchParams)?.query || "";
|
||||
const page = (await searchParams)?.page;
|
||||
const sortBy = (await searchParams)?.sortBy || "asc";
|
||||
@ -53,12 +53,16 @@ export async function DevicesTable({
|
||||
NOT: {
|
||||
payments: {
|
||||
some: {
|
||||
paid: false
|
||||
}
|
||||
}
|
||||
paid: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
isActive: isAdmin ? undefined : parentalControl,
|
||||
blocked: isAdmin ? undefined : parentalControl !== undefined ? undefined : false,
|
||||
blocked: isAdmin
|
||||
? undefined
|
||||
: parentalControl !== undefined
|
||||
? undefined
|
||||
: false,
|
||||
},
|
||||
});
|
||||
|
||||
@ -86,8 +90,8 @@ export async function DevicesTable({
|
||||
NOT: {
|
||||
payments: {
|
||||
some: {
|
||||
paid: false
|
||||
}
|
||||
paid: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
isActive: parentalControl,
|
||||
@ -158,7 +162,12 @@ export async function DevicesTable({
|
||||
// )}
|
||||
// </TableCell>
|
||||
// </TableRow>
|
||||
<ClickableRow admin={isAdmin} key={device.id} device={device} parentalControl={parentalControl} />
|
||||
<ClickableRow
|
||||
admin={isAdmin}
|
||||
key={device.id}
|
||||
device={device}
|
||||
parentalControl={parentalControl}
|
||||
/>
|
||||
))}
|
||||
</TableBody>
|
||||
<TableFooter>
|
||||
@ -181,7 +190,11 @@ export async function DevicesTable({
|
||||
</div>
|
||||
<div className="sm:hidden my-4">
|
||||
{devices.map((device) => (
|
||||
<DeviceCard parentalControl={parentalControl} key={device.id} device={device} />
|
||||
<DeviceCard
|
||||
parentalControl={parentalControl}
|
||||
key={device.id}
|
||||
device={device}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
|
Reference in New Issue
Block a user