Merge remote-tracking branch 'origin/dev' into feat/user-routes
# Conflicts: # frontend/src/controllers/base-controller.ts # frontend/src/controllers/controllers.ts
This commit is contained in:
commit
c84964e719
27 changed files with 1644 additions and 177 deletions
|
@ -1,10 +1,10 @@
|
|||
import { API_BASE } from "../../config.ts";
|
||||
import {apiConfig} from "@/config.ts";
|
||||
|
||||
export class BaseController {
|
||||
protected baseUrl: string;
|
||||
|
||||
constructor(basePath: string) {
|
||||
this.baseUrl = `${API_BASE}/${basePath}`;
|
||||
this.baseUrl = `${apiConfig.baseUrl}/${basePath}`;
|
||||
}
|
||||
|
||||
protected async get<T>(path: string, queryParams?: Record<string, any>): Promise<T> {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { StudentController } from "@/controllers/student-controller.ts";
|
||||
import { TeacherController } from "@/controllers/teacher-controller.ts";
|
||||
|
||||
import {ThemeController} from "@/controllers/themes.ts";
|
||||
|
||||
export function controllerGetter<T>(Factory: new () => T): () => T {
|
||||
let instance: T | undefined;
|
||||
|
||||
|
@ -14,3 +16,4 @@ export function controllerGetter<T>(Factory: new () => T): () => T {
|
|||
|
||||
export const getStudentController = controllerGetter(StudentController);
|
||||
export const getTeacherController = controllerGetter(TeacherController);
|
||||
export const getThemeController = controllerGetter(ThemeController);
|
||||
|
|
16
frontend/src/controllers/themes.ts
Normal file
16
frontend/src/controllers/themes.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import {BaseController} from "@/controllers/base-controller.ts";
|
||||
|
||||
export class ThemeController extends BaseController {
|
||||
constructor() {
|
||||
super("theme");
|
||||
}
|
||||
|
||||
getAll(language: string | null = null) {
|
||||
const query = language ? { language } : undefined;
|
||||
return this.get<any[]>("/", query);
|
||||
}
|
||||
|
||||
getHruidsByKey(themeKey: string) {
|
||||
return this.get<string[]>(`/${encodeURIComponent(themeKey)}`);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue