| import api from './axiosInstance.api'; |
|
|
| |
| export interface IEventDayPhoto { |
| _id: string; |
| url: string; |
| publicId: string; |
| caption?: string; |
| uploadedBy: { |
| _id: string; |
| username: string; |
| }; |
| uploadedAt: string; |
| } |
|
|
| export interface IEventDayAttendance { |
| _id: string; |
| user: { |
| _id: string; |
| username: string; |
| email: string; |
| profilePhoto?: string; |
| }; |
| checkInTime: string; |
| checkInMethod: 'gps' | 'qr' | 'manual' | 'hotspot'; |
| checkInLocation?: { |
| type: 'Point'; |
| coordinates: [number, number]; |
| }; |
| verifiedBy?: { |
| _id: string; |
| username: string; |
| }; |
| } |
|
|
| export interface IEventDay { |
| _id: string; |
| event: { |
| _id: string; |
| title: string; |
| code: string; |
| }; |
| date: string; |
| dayNumber: number; |
| startTime: string; |
| endTime: string; |
| photos: IEventDayPhoto[]; |
| attendance?: IEventDayAttendance[]; |
| photoCount?: number; |
| attendanceCount?: number; |
| hasStarted: boolean; |
| isCompleted: boolean; |
| completedAt?: string; |
| status?: 'green' | 'red' | 'blue'; |
| notes?: string; |
| weatherCondition?: string; |
| activitiesConducted?: string[]; |
| incidentsReported?: string; |
| equipmentUsed?: string[]; |
| } |
|
|
| |
| export const getEventDays = async (eventId: string): Promise<{ eventDays: IEventDay[]; stats: any }> => { |
| const response = await api.get(`/event-days/event/${eventId}`); |
| return response.data; |
| }; |
|
|
| |
| export const getEventDayDetails = async (eventDayId: string): Promise<IEventDay> => { |
| const response = await api.get(`/event-days/${eventDayId}`); |
| return response.data; |
| }; |
|
|
| |
| export const uploadDayPhotos = async ( |
| eventDayId: string, |
| files: File[], |
| captions?: string[] |
| ): Promise<{ message: string; photos: IEventDayPhoto[] }> => { |
| const formData = new FormData(); |
| files.forEach((file) => { |
| formData.append('photos', file); |
| }); |
| if (captions) { |
| captions.forEach((caption) => { |
| formData.append('captions', caption); |
| }); |
| } |
|
|
| const response = await api.post(`/event-days/${eventDayId}/photos`, formData, { |
| headers: { |
| 'Content-Type': 'multipart/form-data', |
| }, |
| }); |
| return response.data; |
| }; |
|
|
| |
| export const deleteDayPhoto = async (eventDayId: string, photoId: string): Promise<{ message: string }> => { |
| const response = await api.delete(`/event-days/${eventDayId}/photos/${photoId}`); |
| return response.data; |
| }; |
|
|
| |
| export const markAttendance = async ( |
| eventDayId: string, |
| userId: string, |
| checkInMethod: 'gps' | 'qr' | 'manual' | 'hotspot', |
| location?: { latitude: number; longitude: number } |
| ): Promise<{ message: string; attendance: IEventDayAttendance }> => { |
| const response = await api.post( |
| `/event-days/${eventDayId}/attendance`, |
| { |
| userId, |
| checkInMethod, |
| ...location, |
| } |
| ); |
| return response.data; |
| }; |
|
|
| |
| export const updateDayMetadata = async ( |
| eventDayId: string, |
| metadata: { |
| notes?: string; |
| weatherCondition?: string; |
| activitiesConducted?: string[]; |
| incidentsReported?: string; |
| equipmentUsed?: string[]; |
| isCompleted?: boolean; |
| } |
| ): Promise<{ message: string; eventDay: IEventDay }> => { |
| const response = await api.patch(`/event-days/${eventDayId}`, metadata); |
| return response.data; |
| }; |
|
|
| |
| export const getAttendanceReport = async (eventId: string): Promise<any> => { |
| const response = await api.get(`/event-days/event/${eventId}/attendance-report`); |
| return response.data; |
| }; |
|
|
| |
| export const startEventDay = async (eventDayId: string): Promise<{ message: string; eventDay: Partial<IEventDay> }> => { |
| const response = await api.post(`/event-days/${eventDayId}/start`, {}); |
| return response.data; |
| }; |
|
|
| |
| export const endEventDay = async (eventDayId: string): Promise<{ message: string; eventDay: Partial<IEventDay> }> => { |
| const response = await api.post(`/event-days/${eventDayId}/end`, {}); |
| return response.data; |
| }; |
|
|
| |
| export const getEventDayStatus = async (eventDayId: string): Promise<{ status: 'green' | 'red' | 'blue'; message: string; eventDay: Partial<IEventDay> }> => { |
| const response = await api.get(`/event-days/${eventDayId}/status`); |
| return response.data; |
| }; |
|
|
| |
| export const bulkMarkAttendance = async ( |
| eventDayId: string, |
| userIds: string[], |
| checkInMethod: 'gps' | 'qr' | 'manual' | 'hotspot' = 'hotspot', |
| location?: { latitude: number; longitude: number } |
| ): Promise<{ message: string; results: { marked: string[]; alreadyMarked: string[]; notParticipant: string[] } }> => { |
| const response = await api.post( |
| `/event-days/${eventDayId}/attendance/bulk`, |
| { |
| userIds, |
| checkInMethod, |
| ...location, |
| } |
| ); |
| return response.data; |
| }; |
|
|