step 10 : check distance selfie or not from back end
This commit is contained in:
45
lib/repository/presensi_repository.dart
Normal file
45
lib/repository/presensi_repository.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
import 'package:absensi_sas_flutter/model/check_distance_model.dart';
|
||||
import 'base_repository.dart';
|
||||
|
||||
class PresensiRepository extends BaseRepository {
|
||||
PresensiRepository({required super.graphql, required super.dio});
|
||||
|
||||
// check distance
|
||||
Future<CheckDistanceModel> checkDistance(
|
||||
String M_StaffID,
|
||||
String M_CompanyID,
|
||||
String CurrentLatitude,
|
||||
String CurrentLongitude,
|
||||
) async {
|
||||
const String query =
|
||||
r'''query($M_StaffID:String!, $M_CompanyID:String!, $CurrentLatitude:String!, $CurrentLongitude:String!){ queryCheckDistance(M_StaffID:$M_StaffID, M_CompanyID:$M_CompanyID, CurrentLatitude:$CurrentLatitude, CurrentLongitude:$CurrentLongitude){ status message selfie unit max_distance current_distance } }''';
|
||||
|
||||
Map<String, dynamic> inpVariables = {
|
||||
"M_StaffID": M_StaffID,
|
||||
"M_CompanyID": M_CompanyID,
|
||||
"CurrentLatitude": CurrentLatitude,
|
||||
"CurrentLongitude": CurrentLongitude,
|
||||
};
|
||||
final resp = await postGraphQlMutation(query, inpVariables);
|
||||
// final loginData = AuthModel.fromJson(resp['userLogin']);
|
||||
|
||||
print(inpVariables);
|
||||
|
||||
print('obj queryCheckDistance : ${resp["queryCheckDistance"]}');
|
||||
|
||||
// final result = AuthModel(
|
||||
// token: resp["loginAttendance"]["token"],
|
||||
// model: StaffModel.fromJson(resp["loginAttendance"]),
|
||||
// );
|
||||
|
||||
final result = CheckDistanceModel(
|
||||
currentDistance: resp['queryCheckDistance']['current_distance'],
|
||||
maxDistance: resp['queryCheckDistance']['max_distance'],
|
||||
message: resp['queryCheckDistance']['message'],
|
||||
selfie: resp['queryCheckDistance']['selfie'],
|
||||
status: resp['queryCheckDistance']['status'],
|
||||
unit: resp['queryCheckDistance']['unit']
|
||||
);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user