Attendance validation involving Location Detection + Facial Recoginition with Liveness Detection
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
|
||||
@@ -14,9 +16,9 @@ final attendanceDateRangeProvider = StateProvider<ReportDateRange>((ref) {
|
||||
final now = AppTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
return ReportDateRange(
|
||||
start: today.subtract(const Duration(days: 7)),
|
||||
start: today,
|
||||
end: today.add(const Duration(days: 1)),
|
||||
label: 'Last 7 Days',
|
||||
label: 'Today',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -95,4 +97,52 @@ class AttendanceController {
|
||||
params: {'p_attendance_id': attendanceId, 'p_lat': lat, 'p_lng': lng},
|
||||
);
|
||||
}
|
||||
|
||||
/// Overtime check-in (no pre-existing schedule required).
|
||||
/// Creates an overtime duty schedule + attendance log in one RPC call.
|
||||
Future<String?> overtimeCheckIn({
|
||||
required double lat,
|
||||
required double lng,
|
||||
String? justification,
|
||||
}) async {
|
||||
final data = await _client.rpc(
|
||||
'overtime_check_in',
|
||||
params: {'p_lat': lat, 'p_lng': lng, 'p_justification': justification},
|
||||
);
|
||||
return data as String?;
|
||||
}
|
||||
|
||||
/// Upload a verification selfie and update the attendance log.
|
||||
Future<void> uploadVerification({
|
||||
required String attendanceId,
|
||||
required Uint8List bytes,
|
||||
required String fileName,
|
||||
required String status, // 'verified', 'unverified'
|
||||
}) async {
|
||||
final userId = _client.auth.currentUser!.id;
|
||||
final ext = fileName.split('.').last.toLowerCase();
|
||||
final path = '$userId/$attendanceId.$ext';
|
||||
await _client.storage
|
||||
.from('attendance-verification')
|
||||
.uploadBinary(
|
||||
path,
|
||||
bytes,
|
||||
fileOptions: const FileOptions(upsert: true),
|
||||
);
|
||||
final url = _client.storage
|
||||
.from('attendance-verification')
|
||||
.getPublicUrl(path);
|
||||
await _client
|
||||
.from('attendance_logs')
|
||||
.update({'verification_status': status, 'verification_photo_url': url})
|
||||
.eq('id', attendanceId);
|
||||
}
|
||||
|
||||
/// Mark an attendance log as skipped verification.
|
||||
Future<void> skipVerification(String attendanceId) async {
|
||||
await _client
|
||||
.from('attendance_logs')
|
||||
.update({'verification_status': 'skipped'})
|
||||
.eq('id', attendanceId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user