diff --git a/routes/(apps)/admin/(_props)/props.ts b/routes/(apps)/admin/(_props)/props.ts new file mode 100644 index 0000000..3ae55a1 --- /dev/null +++ b/routes/(apps)/admin/(_props)/props.ts @@ -0,0 +1,13 @@ +import { AppProperties } from "$root/defaults/interfaces.ts"; + +const properties: AppProperties = { + name: "Admin", + icon: "school", + pages: { + index: "Homepage", + }, + adminOnly: [], + hint: "PolyMPR module", +}; + +export default properties; diff --git a/routes/(apps)/admin/api/example.ts b/routes/(apps)/admin/api/example.ts new file mode 100644 index 0000000..9f04cd1 --- /dev/null +++ b/routes/(apps)/admin/api/example.ts @@ -0,0 +1,22 @@ +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", + }, + }); + }, +}; diff --git a/routes/(apps)/admin/api/permissions.ts b/routes/(apps)/admin/api/permissions.ts new file mode 100644 index 0000000..1175eb0 --- /dev/null +++ b/routes/(apps)/admin/api/permissions.ts @@ -0,0 +1,22 @@ +import { Handlers } from "$fresh/server.ts"; +import { AuthenticatedState } from "$root/defaults/interfaces.ts"; + +const PERMISSIONS = [ + { id: "student_read", nom: "Consulter les élèves" }, + { id: "student_write", nom: "Gérer les élèves" }, + { id: "note_read", nom: "Consulter les notes" }, + { id: "note_write", nom: "Gérer les notes" }, + { id: "module_read", nom: "Consulter les modules" }, + { id: "module_write", nom: "Gérer les modules" }, + { id: "user_read", nom: "Consulter les utilisateurs" }, + { id: "user_write", nom: "Gérer les utilisateurs" }, + { id: "role_write", nom: "Gérer les rôles" }, +] as const; + +export const handler: Handlers = { + GET(_request, _context): Response { + return new Response(JSON.stringify(PERMISSIONS), { + headers: { "content-type": "application/json" }, + }); + }, +}; diff --git a/routes/(apps)/admin/index.tsx b/routes/(apps)/admin/index.tsx new file mode 100644 index 0000000..1d82f7f --- /dev/null +++ b/routes/(apps)/admin/index.tsx @@ -0,0 +1,2 @@ +import makeIndex from "$root/defaults/makeIndex.ts"; +export default makeIndex(import.meta.dirname!); diff --git a/routes/(apps)/admin/partials/index.tsx b/routes/(apps)/admin/partials/index.tsx new file mode 100644 index 0000000..12adb8d --- /dev/null +++ b/routes/(apps)/admin/partials/index.tsx @@ -0,0 +1,13 @@ +import { + getPartialsConfig, + makePartials, +} from "$root/defaults/makePartials.tsx"; +import { FreshContext } from "$fresh/server.ts"; +import { State } from "$root/routes/_middleware.ts"; + +export async function Index(request: Request, context: FreshContext) { + return

Welcome to Admin.

; +} + +export const config = getPartialsConfig(); +export default makePartials(Index);