feat: auto-detect podman/docker in agent, add studentId to activation response, fix download URLs
This commit is contained in:
@@ -9,14 +9,15 @@ import { DeleteClassDialog } from "./DeleteClassDialog";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function ClassDetailPage({ params }: { params: { id: string } }) {
|
||||
export default async function ClassDetailPage({ params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params;
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session?.user) redirect("/login");
|
||||
if (!session.user.establishmentId && session.user.role !== "superadmin") redirect("/dashboard");
|
||||
|
||||
const establishmentId = session.user.establishmentId;
|
||||
const cls = await prisma.class.findFirst({
|
||||
where: { id: params.id, ...(establishmentId ? { establishmentId } : {}) },
|
||||
where: { id, ...(establishmentId ? { establishmentId } : {}) },
|
||||
include: { students: true },
|
||||
});
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ async function createClass(formData: FormData) {
|
||||
"use server";
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session?.user) redirect("/login");
|
||||
if (!session.user.establishmentId && session.user.role !== "superadmin") redirect("/dashboard");
|
||||
if (!session.user.establishmentId) redirect("/dashboard");
|
||||
|
||||
const parsed = schema.safeParse(Object.fromEntries(formData));
|
||||
if (!parsed.success) return;
|
||||
@@ -27,7 +27,7 @@ async function createClass(formData: FormData) {
|
||||
data: {
|
||||
name: parsed.data.name,
|
||||
level: parsed.data.level,
|
||||
establishmentId: session.user.establishmentId!,
|
||||
establishment: { connect: { id: session.user.establishmentId } },
|
||||
},
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@ async function createClass(formData: FormData) {
|
||||
export default async function NewClassPage() {
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session?.user) redirect("/login");
|
||||
if (!session.user.establishmentId && session.user.role !== "superadmin") redirect("/dashboard");
|
||||
if (!session.user.establishmentId) redirect("/dashboard");
|
||||
|
||||
return (
|
||||
<div className="space-y-6 max-w-xl">
|
||||
|
||||
@@ -14,7 +14,7 @@ export default function DownloadPage() {
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-sm text-muted-foreground mb-4">Agent EduBox pour Windows (64 bits)</p>
|
||||
<a href="/agent/edubox-agent.exe" download className="inline-flex items-center justify-center rounded-md text-sm font-medium bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2 w-full">Télécharger (.exe)</a>
|
||||
<a href="/edubox-agent.exe" download className="inline-flex items-center justify-center rounded-md text-sm font-medium bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2 w-full">Télécharger (.exe)</a>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card>
|
||||
@@ -23,7 +23,7 @@ export default function DownloadPage() {
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-sm text-muted-foreground mb-4">Agent EduBox pour Linux (64 bits)</p>
|
||||
<a href="/agent/edubox-agent" download className="inline-flex items-center justify-center rounded-md text-sm font-medium bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2 w-full">Télécharger</a>
|
||||
<a href="/edubox-agent" download className="inline-flex items-center justify-center rounded-md text-sm font-medium bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2 w-full">Télécharger</a>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card>
|
||||
@@ -32,7 +32,7 @@ export default function DownloadPage() {
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-sm text-muted-foreground mb-4">Agent EduBox pour macOS (Intel & Apple Silicon)</p>
|
||||
<a href="/agent/edubox-agent-mac" download className="inline-flex items-center justify-center rounded-md text-sm font-medium bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2 w-full">Télécharger</a>
|
||||
<a href="/edubox-agent-mac" download className="inline-flex items-center justify-center rounded-md text-sm font-medium bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2 w-full">Télécharger</a>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
@@ -11,7 +11,8 @@ import { generateActivationCodeAction } from "./actions";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function StudentDetailPage({ params }: { params: { id: string } }) {
|
||||
export default async function StudentDetailPage({ params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params;
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session?.user) redirect("/login");
|
||||
if (!session.user.establishmentId && session.user.role !== "superadmin") redirect("/dashboard");
|
||||
@@ -19,7 +20,7 @@ export default async function StudentDetailPage({ params }: { params: { id: stri
|
||||
const establishmentId = session.user.establishmentId;
|
||||
const student = await prisma.student.findFirst({
|
||||
where: {
|
||||
id: params.id,
|
||||
id,
|
||||
class: establishmentId ? { establishmentId } : undefined,
|
||||
},
|
||||
include: { class: true },
|
||||
|
||||
Reference in New Issue
Block a user