|
|
@@ -1,5 +1,5 @@
|
|
|
import { inject, Injectable } from '@angular/core';
|
|
|
-import { OperationsDashboardData, OperationsPage, OperationsUser, OperationsUserDetail } from './admin.models';
|
|
|
+import { CoachAvailability, CoachDetailData, CoachSummary, OperationsDashboardData, OperationsPage, OperationsUser, OperationsUserDetail, PayRate, PayrollDetail, PayrollSummary, ScheduleCalendarData } from './admin.models';
|
|
|
import { CloudFunctionsService } from './cloud-functions.service';
|
|
|
|
|
|
export type OperationsListKind = 'relations' | 'course-bindings' | 'appointments' | 'lessons' | 'learning-records' | 'finance' | 'money-logs';
|
|
|
@@ -12,6 +12,10 @@ export class OperationsService {
|
|
|
return this.functions.operations<OperationsDashboardData>('ops/dashboard/summary');
|
|
|
}
|
|
|
|
|
|
+ request<T>(operation: string, params: Record<string, unknown> = {}): Promise<T> {
|
|
|
+ return this.functions.operations<T>(operation, params);
|
|
|
+ }
|
|
|
+
|
|
|
users(page: number, pageSize: number, search: string, filters: Record<string, unknown> = {}, refresh = false): Promise<OperationsPage<OperationsUser>> {
|
|
|
return this.functions.operations<OperationsPage<OperationsUser>>('ops/users/list', { page, pageSize, search, filters, refresh });
|
|
|
}
|
|
|
@@ -20,6 +24,38 @@ export class OperationsService {
|
|
|
return this.functions.operations<OperationsUserDetail>('ops/users/detail', { objectId });
|
|
|
}
|
|
|
|
|
|
+ coaches(page: number, pageSize: number, search = '', filters: Record<string, unknown> = {}): Promise<OperationsPage<CoachSummary>> {
|
|
|
+ return this.functions.operations<OperationsPage<CoachSummary>>('ops/coaches/list', { page, pageSize, search, filters });
|
|
|
+ }
|
|
|
+
|
|
|
+ coachDetail(objectId: string): Promise<CoachDetailData> {
|
|
|
+ return this.functions.operations<CoachDetailData>('ops/coaches/detail', { objectId });
|
|
|
+ }
|
|
|
+
|
|
|
+ schedule(dateFrom: string, dateTo: string, coachId = 0): Promise<ScheduleCalendarData> {
|
|
|
+ return this.functions.operations<ScheduleCalendarData>('ops/schedule/calendar', { dateFrom, dateTo, filters: { coachId } });
|
|
|
+ }
|
|
|
+
|
|
|
+ availability(coachId: number): Promise<OperationsPage<CoachAvailability>> {
|
|
|
+ return this.functions.operations<OperationsPage<CoachAvailability>>('ops/coach-availability/list', { page: 1, pageSize: 100, filters: { coachId } });
|
|
|
+ }
|
|
|
+
|
|
|
+ payRates(): Promise<OperationsPage<PayRate>> {
|
|
|
+ return this.functions.operations<OperationsPage<PayRate>>('ops/pay-rates/list', { page: 1, pageSize: 100 });
|
|
|
+ }
|
|
|
+
|
|
|
+ payrolls(page = 1, pageSize = 20): Promise<OperationsPage<PayrollSummary>> {
|
|
|
+ return this.functions.operations<OperationsPage<PayrollSummary>>('ops/payroll/list', { page, pageSize });
|
|
|
+ }
|
|
|
+
|
|
|
+ payrollPreview(month: string): Promise<PayrollDetail> {
|
|
|
+ return this.functions.operations<PayrollDetail>('ops/payroll/preview', { month });
|
|
|
+ }
|
|
|
+
|
|
|
+ payrollDetail(targetId: string): Promise<PayrollDetail> {
|
|
|
+ return this.functions.operations<PayrollDetail>('ops/payroll/detail', { targetId });
|
|
|
+ }
|
|
|
+
|
|
|
list(kind: OperationsListKind, page: number, pageSize: number, search: string, filters: Record<string, unknown> = {}): Promise<OperationsPage> {
|
|
|
const operation = kind === 'relations' ? 'ops/relations/list'
|
|
|
: kind === 'course-bindings' ? 'ops/course-bindings/list'
|
|
|
@@ -31,7 +67,7 @@ export class OperationsService {
|
|
|
return this.functions.operations<OperationsPage>(operation, { page, pageSize, search, filters });
|
|
|
}
|
|
|
|
|
|
- mutate<T>(operation: string, targetId: string, reason: string, payload: Record<string, unknown> = {}, expectedUpdatedAt = ''): Promise<T> {
|
|
|
- return this.functions.operations<T>(operation, { targetId, reason, payload, expectedUpdatedAt });
|
|
|
+ mutate<T>(operation: string, targetId: string, reason: string, payload: Record<string, unknown> = {}, expectedUpdatedAt = '', idempotencyKey = ''): Promise<T> {
|
|
|
+ return this.functions.operations<T>(operation, { targetId, reason, payload, expectedUpdatedAt, idempotencyKey: idempotencyKey || crypto.randomUUID() });
|
|
|
}
|
|
|
}
|