56 lines
1.3 KiB
Dart
56 lines
1.3 KiB
Dart
|
|
import 'package:dio/dio.dart';
|
||
|
|
|
||
|
|
import '../../core/api/api_client.dart';
|
||
|
|
|
||
|
|
class HrApi {
|
||
|
|
HrApi(this._client);
|
||
|
|
|
||
|
|
final ApiClient _client;
|
||
|
|
|
||
|
|
Future<Map<String, dynamic>?> fetchTodayShift({
|
||
|
|
required String cafeId,
|
||
|
|
required String employeeId,
|
||
|
|
}) async {
|
||
|
|
final res = await _client.dio.get<Map<String, dynamic>>(
|
||
|
|
'/api/cafes/$cafeId/employees/$employeeId/shift/today',
|
||
|
|
);
|
||
|
|
final data = res.data?['data'] as Map<String, dynamic>?;
|
||
|
|
return data;
|
||
|
|
}
|
||
|
|
|
||
|
|
Future<void> clockIn({
|
||
|
|
required String cafeId,
|
||
|
|
required String employeeId,
|
||
|
|
}) async {
|
||
|
|
await _client.dio.post(
|
||
|
|
'/api/cafes/$cafeId/employees/$employeeId/attendance/clock-in',
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
Future<void> clockOut({
|
||
|
|
required String cafeId,
|
||
|
|
required String employeeId,
|
||
|
|
}) async {
|
||
|
|
await _client.dio.post(
|
||
|
|
'/api/cafes/$cafeId/employees/$employeeId/attendance/clock-out',
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
Future<void> submitLeave({
|
||
|
|
required String cafeId,
|
||
|
|
required String employeeId,
|
||
|
|
required String startDate,
|
||
|
|
required String endDate,
|
||
|
|
String? reason,
|
||
|
|
}) async {
|
||
|
|
await _client.dio.post(
|
||
|
|
'/api/cafes/$cafeId/employees/$employeeId/leave-requests',
|
||
|
|
data: {
|
||
|
|
'startDate': startDate,
|
||
|
|
'endDate': endDate,
|
||
|
|
if (reason != null && reason.isNotEmpty) 'reason': reason,
|
||
|
|
},
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|