mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 12:18:11 +00:00
Seatmap rendering and other updates
This commit is contained in:
@@ -250,6 +250,9 @@ export const promotionsApi = {
|
||||
delete: (id: string) => apiClient.delete(`/promos/${id}`),
|
||||
};
|
||||
|
||||
export { promosApi } from './promos';
|
||||
export { usersApi } from './users';
|
||||
|
||||
// Support API
|
||||
export const supportApi = {
|
||||
getConversations: async (params?: any) => {
|
||||
|
||||
54
apps/edr-passenger-web/backoffice/src/lib/api/promos.ts
Normal file
54
apps/edr-passenger-web/backoffice/src/lib/api/promos.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { apiClient } from '@/lib/api-client';
|
||||
|
||||
export interface PromoCode {
|
||||
id: string;
|
||||
code: string;
|
||||
title: string;
|
||||
discountType: 'PERCENTAGE' | 'FIXED';
|
||||
discountValue: number;
|
||||
maxDiscount?: number;
|
||||
minBookingAmount?: number;
|
||||
maxUsagePerUser?: number;
|
||||
totalUsageLimit?: number;
|
||||
usageCount: number;
|
||||
validFrom: string;
|
||||
validUntil: string;
|
||||
isActive: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export const promosApi = {
|
||||
getAll: (filters?: { search?: string; active?: string; page?: number; pageSize?: number }) => {
|
||||
const params = new URLSearchParams();
|
||||
if (filters?.search) params.append('search', filters.search);
|
||||
if (filters?.active) params.append('active', filters.active);
|
||||
if (filters?.page) params.append('page', filters.page.toString());
|
||||
if (filters?.pageSize) params.append('pageSize', filters.pageSize.toString());
|
||||
|
||||
return apiClient.get<{ items: PromoCode[]; total: number; page: number; pageSize: number }>(`/promos/all?${params.toString()}`);
|
||||
},
|
||||
|
||||
getById: (id: string) => {
|
||||
return apiClient.get<PromoCode>(`/promos/${id}`);
|
||||
},
|
||||
|
||||
create: (data: Omit<PromoCode, 'id' | 'createdAt' | 'updatedAt' | 'usageCount'>) => {
|
||||
return apiClient.post<PromoCode>('/promos', data);
|
||||
},
|
||||
|
||||
update: (id: string, data: Partial<PromoCode>) => {
|
||||
return apiClient.patch<PromoCode>(`/promos/${id}`, data);
|
||||
},
|
||||
|
||||
delete: (id: string) => {
|
||||
return apiClient.delete<void>(`/promos/${id}`);
|
||||
},
|
||||
|
||||
validate: (code: string, bookingAmount?: number) => {
|
||||
return apiClient.post<{ valid: boolean; message?: string; discount?: number }>('/promos/validate', {
|
||||
code,
|
||||
bookingAmount,
|
||||
});
|
||||
},
|
||||
};
|
||||
59
apps/edr-passenger-web/backoffice/src/lib/api/users.ts
Normal file
59
apps/edr-passenger-web/backoffice/src/lib/api/users.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { apiClient } from '@/lib/api-client';
|
||||
|
||||
export interface BackofficeUser {
|
||||
id: string;
|
||||
email: string;
|
||||
fullName: string;
|
||||
role: 'ADMIN' | 'SUPERVISOR' | 'STAFF' | 'AGENT';
|
||||
status: 'ACTIVE' | 'INACTIVE';
|
||||
lastLogin?: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export const usersApi = {
|
||||
getAll: async (filters?: { search?: string; role?: string; status?: string; page?: number; pageSize?: number }) => {
|
||||
const params = new URLSearchParams();
|
||||
if (filters?.search) params.append('search', filters.search);
|
||||
if (filters?.role) params.append('role', filters.role);
|
||||
if (filters?.status) params.append('status', filters.status);
|
||||
if (filters?.page) params.append('page', filters.page.toString());
|
||||
if (filters?.pageSize) params.append('pageSize', filters.pageSize.toString());
|
||||
|
||||
const response = await apiClient.get<any>(`/auth/users?${params.toString()}`);
|
||||
|
||||
// Handle different response formats
|
||||
if (response && typeof response === 'object') {
|
||||
if ('items' in response) {
|
||||
return response as { items: BackofficeUser[]; total: number };
|
||||
}
|
||||
if (Array.isArray(response)) {
|
||||
return { items: response as BackofficeUser[], total: response.length };
|
||||
}
|
||||
}
|
||||
|
||||
return { items: Array.isArray(response) ? response : [], total: 0 };
|
||||
},
|
||||
|
||||
getById: (id: string) => {
|
||||
return apiClient.get<BackofficeUser>(`/auth/users/${id}`);
|
||||
},
|
||||
|
||||
create: (data: { email: string; fullName: string; role: string; password: string }) => {
|
||||
return apiClient.post<BackofficeUser>('/auth/users', data);
|
||||
},
|
||||
|
||||
update: (id: string, data: Partial<BackofficeUser>) => {
|
||||
return apiClient.patch<BackofficeUser>(`/auth/users/${id}`, data);
|
||||
},
|
||||
|
||||
delete: (id: string) => {
|
||||
return apiClient.delete<void>(`/auth/users/${id}`);
|
||||
},
|
||||
|
||||
resetPassword: (id: string, tempPassword: string) => {
|
||||
return apiClient.post<{ success: boolean; message: string }>(`/auth/users/${id}/reset-password`, {
|
||||
tempPassword,
|
||||
});
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user