Fix after MR

This commit is contained in:
Kevin FEDYNA
2025-01-15 15:57:08 +01:00
parent b720a5e7b8
commit b894930e12
9 changed files with 49 additions and 65 deletions
+1
View File
@@ -3,6 +3,7 @@ export interface AppProperties {
icon: string;
pages: Record<string, string>;
adminOnly: string[];
hint: string;
}
export type EmptyObject = Record<string | number | symbol, never>;
+17
View File
@@ -0,0 +1,17 @@
import { AppProperties } from "$root/defaults/interfaces.ts";
type AppCardProps = {
app: AppProperties;
href: string;
};
export default function AppCard(props: AppCardProps) {
return (
<div className="app-card">
<a href={`/${props.href}`} f-client-nav={false}>
<span className="material-symbols-outlined">{props.app.icon}</span>
<p>{props.app.name}</p>
</a>
</div>
);
}
-16
View File
@@ -1,16 +0,0 @@
import { AppProperties } from "../(_islands)/AppNavigator.tsx";
type ModuleCardProps = {
module: AppProperties;
};
export default function ModuleCard({ module }: ModuleCardProps) {
return (
<div className="module-card">
<a href={`/${module.name}`}>
<span className="material-symbols-outlined">{module.icon}</span>
<p>{module.name}</p>
</a>
</div>
);
}
+17 -1
View File
@@ -1,13 +1,29 @@
import { AppProperties } from "$root/defaults/interfaces.ts";
import AppCard from "$root/routes/(_components)/AppCard.tsx";
type AppNavigatorProps = {
apps: Record<string, AppProperties>;
};
export default function AppNavigator(props: AppNavigatorProps) {
if (!props.apps) {
return (
<>
<p>{JSON.stringify(props.apps)}</p>
<h2>Welcome to PolyMPR!</h2>
<p>No apps available.</p>
</>
);
}
return (
<>
<h2>Welcome to PolyMPR!</h2>
<h3>app list</h3>
<div className="app-list">
{Object.entries(props.apps).map(([key, app]) => (
<AppCard href={key} app={app} />
))}
</div>
</>
);
}
+1 -1
View File
@@ -3,7 +3,7 @@ import { AppProperties } from "../../../(_islands)/AppNavigator.tsx";
const properties: AppProperties = {
name: "PolyMobility",
icon: "flight_takeoff",
hint: "Gestionnaire de mobilité"
hint: "Gestionnaire de mobilité",
};
export default properties;
-1
View File
@@ -5,7 +5,6 @@ export default function Modules(_props: ModulesProps) {
<>
<h2>All PolyMPR modules</h2>
<nav>
</nav>
</>
);
+1 -1
View File
@@ -10,7 +10,7 @@ const properties: AppProperties = {
students: "Students management",
},
adminOnly: ["courses", "students"],
hint: "Gestionnaire de note"
hint: "Gestionnaire de note",
};
export default properties;
+8 -2
View File
@@ -16,8 +16,14 @@ export default async function App(
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PolyMPR</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap"
/>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0"
/>
<link rel="stylesheet" href="/styles/main.css" />
<link rel="stylesheet" href="/styles/app.css" />
</head>
+2 -41
View File
@@ -1,49 +1,10 @@
import { FreshContext, Handlers } from "$fresh/server.ts";
import ModuleCard from "./(_components)/ModuleCard.tsx";
import { AppProperties } from "./(_islands)/AppNavigator.tsx";
export const handler: Handlers = {
async GET(_request, context) {
const apps: Record<string, AppProperties> = {};
for await (const appDir of Deno.readDir("routes/(apps)")) {
try {
const properties: AppProperties = (await import(
`./(apps)/${appDir.name}/(_props)/props.ts`
)).default;
apps[appDir.name] = properties;
} catch (error) {
console.error(`Couldn't import app "${appDir.name}": ${error}`);
}
}
return context.render(apps);
},
};
import { FreshContext } from "$fresh/server.ts";
// deno-lint-ignore require-await
export default async function Home(_request: Request, context: FreshContext) {
const apps: Record<string, AppProperties> = context.data;
console.log("Context data:", context.data);
if (!apps) {
export default async function Home(_request: Request, _context: FreshContext) {
return (
<>
<h2>Welcome to PolyMPR!</h2>
<p>No modules available.</p>
</>
);
}
return (
<>
<h2>Welcome to PolyMPR!</h2>
<h3>Module list</h3>
<div className="module-list">
{Object.entries(apps).map(([key, module]) => (
<ModuleCard key={key} module={module} />
))}
</div>
</>
);
}