feat(v3): restructure project + add complete frontend
- Restructure: move backend from new_project/ to backend/ - Add full React/TypeScript frontend (37 pages, 17 services, 16 type defs, 11 query hooks) - Add docs/ with SRS specs, user stories, and workflow documentation - Update .gitignore for new directory layout Workflows implemented: WF1 User Signup, WF2 Placement Test, WF3 Exam Configuration, WF4 General English Exam, WF5 Course Generation, WF6 Entity Student Onboarding, AI Course Generation, Adaptive Learning Engine UI, White-Label Branding, Score Release Made-with: Cursor
This commit is contained in:
45
src/services/entities.service.ts
Normal file
45
src/services/entities.service.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { api } from "@/lib/api-client";
|
||||
import { asPaginated, asRecordData } from "@/lib/odoo-api";
|
||||
import type { Entity, EntityRole, PaginatedResponse, PaginationParams, ApiSuccessResponse } from "@/types";
|
||||
|
||||
export const entitiesService = {
|
||||
async list(params?: PaginationParams): Promise<PaginatedResponse<Entity>> {
|
||||
const raw = await api.get<unknown>("/entities", params as Record<string, string | number | boolean | undefined>);
|
||||
return asPaginated<Entity>(raw);
|
||||
},
|
||||
|
||||
async getById(id: number): Promise<Entity> {
|
||||
const raw = await api.get<unknown>(`/entities/${id}`);
|
||||
return asRecordData<Entity>(raw);
|
||||
},
|
||||
|
||||
async create(data: Partial<Entity>): Promise<Entity> {
|
||||
const raw = await api.post<unknown>("/entities", data);
|
||||
return asRecordData<Entity>(raw);
|
||||
},
|
||||
|
||||
async update(id: number, data: Partial<Entity>): Promise<Entity> {
|
||||
const raw = await api.patch<unknown>(`/entities/${id}`, data);
|
||||
return asRecordData<Entity>(raw);
|
||||
},
|
||||
|
||||
async delete(id: number): Promise<ApiSuccessResponse> {
|
||||
return api.delete<ApiSuccessResponse>(`/entities/${id}`);
|
||||
},
|
||||
|
||||
async getRoles(entityId: number): Promise<EntityRole[]> {
|
||||
return api.get<EntityRole[]>(`/entities/${entityId}/roles`);
|
||||
},
|
||||
|
||||
async createRole(entityId: number, data: Partial<EntityRole>): Promise<EntityRole> {
|
||||
return api.post<EntityRole>(`/entities/${entityId}/roles`, data);
|
||||
},
|
||||
|
||||
async updateRolePermissions(roleId: number, permissions: string[]): Promise<EntityRole> {
|
||||
return api.patch<EntityRole>(`/roles/${roleId}/permissions`, { permissions });
|
||||
},
|
||||
|
||||
async getPermissions(entityId: number): Promise<string[]> {
|
||||
return api.get<string[]>(`/permissions`, { entity_id: entityId });
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user