Fix after MR
This commit is contained in:
@@ -3,6 +3,7 @@ export interface AppProperties {
|
|||||||
icon: string;
|
icon: string;
|
||||||
pages: Record<string, string>;
|
pages: Record<string, string>;
|
||||||
adminOnly: string[];
|
adminOnly: string[];
|
||||||
|
hint: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type EmptyObject = Record<string | number | symbol, never>;
|
export type EmptyObject = Record<string | number | symbol, never>;
|
||||||
|
|||||||
@@ -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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,13 +1,29 @@
|
|||||||
import { AppProperties } from "$root/defaults/interfaces.ts";
|
import { AppProperties } from "$root/defaults/interfaces.ts";
|
||||||
|
import AppCard from "$root/routes/(_components)/AppCard.tsx";
|
||||||
|
|
||||||
type AppNavigatorProps = {
|
type AppNavigatorProps = {
|
||||||
apps: Record<string, AppProperties>;
|
apps: Record<string, AppProperties>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function AppNavigator(props: AppNavigatorProps) {
|
export default function AppNavigator(props: AppNavigatorProps) {
|
||||||
|
if (!props.apps) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<h2>Welcome to PolyMPR!</h2>
|
||||||
|
<p>No apps available.</p>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<p>{JSON.stringify(props.apps)}</p>
|
<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>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { AppProperties } from "../../../(_islands)/AppNavigator.tsx";
|
|||||||
const properties: AppProperties = {
|
const properties: AppProperties = {
|
||||||
name: "PolyMobility",
|
name: "PolyMobility",
|
||||||
icon: "flight_takeoff",
|
icon: "flight_takeoff",
|
||||||
hint: "Gestionnaire de mobilité"
|
hint: "Gestionnaire de mobilité",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default properties;
|
export default properties;
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ export default function Modules(_props: ModulesProps) {
|
|||||||
<>
|
<>
|
||||||
<h2>All PolyMPR modules</h2>
|
<h2>All PolyMPR modules</h2>
|
||||||
<nav>
|
<nav>
|
||||||
|
|
||||||
</nav>
|
</nav>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const properties: AppProperties = {
|
|||||||
students: "Students management",
|
students: "Students management",
|
||||||
},
|
},
|
||||||
adminOnly: ["courses", "students"],
|
adminOnly: ["courses", "students"],
|
||||||
hint: "Gestionnaire de note"
|
hint: "Gestionnaire de note",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default properties;
|
export default properties;
|
||||||
|
|||||||
+8
-2
@@ -16,8 +16,14 @@ export default async function App(
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>PolyMPR</title>
|
<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
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />
|
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/main.css" />
|
||||||
<link rel="stylesheet" href="/styles/app.css" />
|
<link rel="stylesheet" href="/styles/app.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
+2
-41
@@ -1,49 +1,10 @@
|
|||||||
import { FreshContext, Handlers } from "$fresh/server.ts";
|
import { FreshContext } 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);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// deno-lint-ignore require-await
|
// deno-lint-ignore require-await
|
||||||
export default async function Home(_request: Request, context: FreshContext) {
|
export default async function Home(_request: Request, _context: FreshContext) {
|
||||||
const apps: Record<string, AppProperties> = context.data;
|
|
||||||
console.log("Context data:", context.data);
|
|
||||||
|
|
||||||
if (!apps) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<h2>Welcome to PolyMPR!</h2>
|
|
||||||
<p>No modules available.</p>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h2>Welcome to PolyMPR!</h2>
|
<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>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user