Moved all student management tools into student app for global uses (working)

This commit is contained in:
Clayzxr
2025-01-21 17:29:59 +01:00
parent c04505e95d
commit b5fedbb425
12 changed files with 79 additions and 65 deletions
+1 -2
View File
@@ -8,9 +8,8 @@ const properties: AppProperties = {
index: "Homepage",
overview: "Mobility overview",
mobility: "Mobility management",
students: "Students management",
},
adminOnly: ["students"],
adminOnly: ["mobility"],
};
export default properties;
@@ -1,20 +0,0 @@
import { RouteConfig } from "$fresh/server.ts";
import UploadStudents from "../(_islands)/UploadStudents.tsx";
import ConsultStudents from "../(_islands)/ConsultStudents.tsx";
//import EditStudents from "../(_islands)/EditStudents.tsx";
export const config: RouteConfig = {
skipAppWrapper: false,
skipInheritedLayouts: false,
};
export default function Students() {
return (
<section id="students-page">
<h1>Manage Promotions</h1>
<UploadStudents />
<hr />
<ConsultStudents />
</section>
);
}
@@ -21,7 +21,7 @@ export default function ConsultStudents() {
useEffect(() => {
const fetchData = async () => {
try {
const response = await fetch("/mobility/api/insert_students");
const response = await fetch("/students/api/insert_students");
if (!response.ok) {
throw new Error(`Error fetching data: ${response.statusText}`);
}
@@ -37,7 +37,7 @@ export default function UploadStudents() {
range: 1, // Ignorer les en-têtes
});
const response = await fetch("/mobility/api/insert_students", {
const response = await fetch("/students/api/insert_students", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ promoName: sheetName, data }),
+4 -2
View File
@@ -5,10 +5,12 @@ const properties: AppProperties = {
icon: "badge",
pages: {
index: "Homepage",
overview: "Students overview",
upload: "Upload students",
consult: "Consult students"
},
adminOnly: ["upload"],
hint: "See student information",
adminOnly: ["upload", "consult"],
hint: "Create students promotion and see informations",
};
export default properties;
-22
View File
@@ -1,22 +0,0 @@
import { Handlers } from "$fresh/server.ts";
export const handler: Handlers = {
async POST(request, context) {
if (request.headers.get("content-type") != "application/json") {
return new Response(null, {
status: 400,
});
}
const responseBody = {
requestBody: await request.json(),
context,
};
return new Response(JSON.stringify(responseBody), {
headers: {
"content-type": "application/json",
},
});
},
};
@@ -0,0 +1,17 @@
import ConsultStudents from "$root/routes/(apps)/students/(_islands)/ConsultStudents.tsx";
import { getPartialsConfig, makePartials } from "$root/defaults/makePartials.tsx";
import { FreshContext } from "$fresh/server.ts";
import { State } from "$root/routes/_middleware.ts";
//import EditStudents from "../(_islands)/EditStudents.tsx";
async function Students(_request: Request, _context: FreshContext<State>) {
return (
<>
<h1>Manage Promotions</h1>
<ConsultStudents />
</>
);
}
export const config = getPartialsConfig();
export default makePartials(Students);
@@ -0,0 +1,17 @@
import UploadStudents from "$root/routes/(apps)/students/(_islands)/UploadStudents.tsx";
import { getPartialsConfig, makePartials } from "$root/defaults/makePartials.tsx";
import { FreshContext } from "$fresh/server.ts";
import { State } from "$root/routes/_middleware.ts";
//import EditStudents from "../(_islands)/EditStudents.tsx";
async function Students(_request: Request, _context: FreshContext<State>) {
return (
<>
<h1>Manage Promotions</h1>
<UploadStudents />
</>
);
}
export const config = getPartialsConfig();
export default makePartials(Students);
@@ -0,0 +1,17 @@
import { Partial } from "$fresh/runtime.ts";
import { RouteConfig } from "$fresh/server.ts";
type ModulesProps = Record<string | number | symbol, never>;
export const config: RouteConfig = {
skipAppWrapper: true,
skipInheritedLayouts: true,
};
export default function Modules(_props: ModulesProps) {
return (
<Partial name="body">
<a href="students" f-partial={"notes/partials"}>students</a>
</Partial>
);
}