step 17 : proteksi presensi selfie button clock in & clock out
This commit is contained in:
@@ -18,7 +18,16 @@ abstract class BaseRepository {
|
||||
final QueryResult result = await graphql.mutate(options);
|
||||
|
||||
if (result.hasException) {
|
||||
throw BaseRepositoryException(message: result.exception.toString());
|
||||
// throw BaseRepositoryException(message: result.exception.toString());
|
||||
if (result.exception != null) {
|
||||
if (result.exception!.graphqlErrors.isNotEmpty) {
|
||||
String error = "";
|
||||
if (result.exception!.graphqlErrors[0].message != "") {
|
||||
error += result.exception!.graphqlErrors[0].message;
|
||||
throw BaseRepositoryException(message: error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return result.data!;
|
||||
@@ -36,9 +45,20 @@ abstract class BaseRepository {
|
||||
final QueryResult result = await graphql.query(options);
|
||||
|
||||
if (result.hasException) {
|
||||
throw BaseRepositoryException(message: result.exception.toString());
|
||||
// throw BaseRepositoryException(message: result.exception.toString());
|
||||
if (result.exception != null) {
|
||||
if (result.exception!.graphqlErrors.isNotEmpty) {
|
||||
if (result.exception!.graphqlErrors[0].message != "") {
|
||||
throw BaseRepositoryException(
|
||||
message: result.exception!.graphqlErrors[0].message.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// throw BaseRepositoryException(message: result.exception.toString());
|
||||
|
||||
return result.data!;
|
||||
} catch (e) {
|
||||
throw BaseRepositoryException(message: e.toString());
|
||||
|
||||
@@ -66,6 +66,7 @@ class CheckPresensiJamNotifier extends StateNotifier<CheckPresensiJamState> {
|
||||
state = CheckPresensiJamStateDone(model: resp);
|
||||
} catch (e) {
|
||||
if (e is BaseRepositoryException) {
|
||||
print(e.message);
|
||||
state = CheckPresensiJamStateError(message: e.message ?? "");
|
||||
} else {
|
||||
state = CheckPresensiJamStateError(message: e.toString());
|
||||
|
||||
@@ -290,13 +290,14 @@ class PresensiSelfieScreen extends HookConsumerWidget {
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return CustomDialogPresensiSukses(
|
||||
isLoadingAddressUserLocation: isLoadingAddressUserLocation,
|
||||
isiPesan:
|
||||
'Pengajuan presensi telah diajukan, mohon menunggu approval team leader! ',
|
||||
messageStatus: 'Clock In Berhasil',
|
||||
);
|
||||
},
|
||||
);
|
||||
requestLocationPermission();
|
||||
// requestLocationPermission();
|
||||
}
|
||||
// else{
|
||||
// if(next.model == "WARNING"){
|
||||
@@ -323,13 +324,14 @@ class PresensiSelfieScreen extends HookConsumerWidget {
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return CustomDialogPresensiSukses(
|
||||
isLoadingAddressUserLocation: isLoadingAddressUserLocation,
|
||||
isiPesan:
|
||||
'Pengajuan presensi telah diajukan, mohon menunggu approval team leader! ',
|
||||
messageStatus: 'Clock Out Berhasil',
|
||||
);
|
||||
},
|
||||
);
|
||||
requestLocationPermission();
|
||||
// requestLocationPermission();
|
||||
}
|
||||
// else{
|
||||
// if(next.model == "WARNING"){
|
||||
@@ -796,42 +798,48 @@ class PresensiSelfieScreen extends HookConsumerWidget {
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pushNamed(homeRoute);
|
||||
// },
|
||||
onPressed: () {
|
||||
final T_TransactionM_StaffID =
|
||||
selectedUser?.model.staffId ?? "";
|
||||
final T_TransactionM_CompanyID =
|
||||
selectedUser?.model.companyId ?? "";
|
||||
final T_TransactionCurrentLatitude =
|
||||
positionLatitude.value;
|
||||
final T_TransactionCurrentLongitude =
|
||||
positionLongitude.value;
|
||||
final T_TransactionCurrentDistance =
|
||||
varCurrentDistanceProvider
|
||||
?.currentDistance ??
|
||||
"";
|
||||
final T_TransactionSelfiePhoto =
|
||||
fileDataBase64.value;
|
||||
final token = selectedUser?.token ?? "";
|
||||
onPressed: (fileDataBase64.value.isEmpty)
|
||||
? () {}
|
||||
: () {
|
||||
final T_TransactionM_StaffID =
|
||||
selectedUser?.model.staffId ?? "";
|
||||
final T_TransactionM_CompanyID =
|
||||
selectedUser?.model.companyId ??
|
||||
"";
|
||||
final T_TransactionCurrentLatitude =
|
||||
positionLatitude.value;
|
||||
final T_TransactionCurrentLongitude =
|
||||
positionLongitude.value;
|
||||
final T_TransactionCurrentDistance =
|
||||
varCurrentDistanceProvider
|
||||
?.currentDistance ??
|
||||
"";
|
||||
final T_TransactionSelfiePhoto =
|
||||
fileDataBase64.value;
|
||||
final token =
|
||||
selectedUser?.token ?? "";
|
||||
|
||||
showConfirmationDialog(
|
||||
context,
|
||||
T_TransactionM_StaffID,
|
||||
T_TransactionM_CompanyID,
|
||||
T_TransactionCurrentLatitude,
|
||||
T_TransactionCurrentLongitude,
|
||||
T_TransactionCurrentDistance,
|
||||
T_TransactionSelfiePhoto,
|
||||
token,
|
||||
"Clock In");
|
||||
showConfirmationDialog(
|
||||
context,
|
||||
T_TransactionM_StaffID,
|
||||
T_TransactionM_CompanyID,
|
||||
T_TransactionCurrentLatitude,
|
||||
T_TransactionCurrentLongitude,
|
||||
T_TransactionCurrentDistance,
|
||||
T_TransactionSelfiePhoto,
|
||||
token,
|
||||
"Clock In");
|
||||
|
||||
// print(
|
||||
// fileDataBase64.value,
|
||||
// );
|
||||
},
|
||||
// print(
|
||||
// fileDataBase64.value,
|
||||
// );
|
||||
},
|
||||
style: ButtonStyle(
|
||||
backgroundColor:
|
||||
MaterialStateColor.resolveWith(
|
||||
(st) => Constant.textOrange),
|
||||
MaterialStateColor.resolveWith((st) =>
|
||||
(fileDataBase64.value.isEmpty)
|
||||
? Constant.textDarkGrey
|
||||
: Constant.textOrange),
|
||||
shape: MaterialStateProperty.all<
|
||||
RoundedRectangleBorder>(
|
||||
RoundedRectangleBorder(
|
||||
@@ -917,41 +925,48 @@ class PresensiSelfieScreen extends HookConsumerWidget {
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pushNamed(homeRoute);
|
||||
// },
|
||||
onPressed: () {
|
||||
final T_TransactionM_StaffID =
|
||||
selectedUser?.model.staffId ?? "";
|
||||
final T_TransactionM_CompanyID =
|
||||
selectedUser?.model.companyId ?? "";
|
||||
final T_TransactionCurrentLatitude =
|
||||
positionLatitude.value;
|
||||
final T_TransactionCurrentLongitude =
|
||||
positionLongitude.value;
|
||||
final T_TransactionCurrentDistance =
|
||||
varCurrentDistanceProvider
|
||||
?.currentDistance ??
|
||||
"";
|
||||
final T_TransactionSelfiePhoto =
|
||||
fileDataBase64.value;
|
||||
final token = selectedUser?.token ?? "";
|
||||
onPressed: (fileDataBase64.value.isEmpty)
|
||||
? () {}
|
||||
: () {
|
||||
final T_TransactionM_StaffID =
|
||||
selectedUser?.model.staffId ??
|
||||
"";
|
||||
final T_TransactionM_CompanyID =
|
||||
selectedUser?.model.companyId ??
|
||||
"";
|
||||
final T_TransactionCurrentLatitude =
|
||||
positionLatitude.value;
|
||||
final T_TransactionCurrentLongitude =
|
||||
positionLongitude.value;
|
||||
final T_TransactionCurrentDistance =
|
||||
varCurrentDistanceProvider
|
||||
?.currentDistance ??
|
||||
"";
|
||||
final T_TransactionSelfiePhoto =
|
||||
fileDataBase64.value;
|
||||
final token =
|
||||
selectedUser?.token ?? "";
|
||||
|
||||
showConfirmationDialog(
|
||||
context,
|
||||
T_TransactionM_StaffID,
|
||||
T_TransactionM_CompanyID,
|
||||
T_TransactionCurrentLatitude,
|
||||
T_TransactionCurrentLongitude,
|
||||
T_TransactionCurrentDistance,
|
||||
T_TransactionSelfiePhoto,
|
||||
token,
|
||||
"Clock Out");
|
||||
// print(
|
||||
// fileDataBase64.value,
|
||||
// );
|
||||
},
|
||||
showConfirmationDialog(
|
||||
context,
|
||||
T_TransactionM_StaffID,
|
||||
T_TransactionM_CompanyID,
|
||||
T_TransactionCurrentLatitude,
|
||||
T_TransactionCurrentLongitude,
|
||||
T_TransactionCurrentDistance,
|
||||
T_TransactionSelfiePhoto,
|
||||
token,
|
||||
"Clock Out");
|
||||
// print(
|
||||
// fileDataBase64.value,
|
||||
// );
|
||||
},
|
||||
style: ButtonStyle(
|
||||
backgroundColor:
|
||||
MaterialStateColor.resolveWith(
|
||||
(st) => Constant.textOrange),
|
||||
MaterialStateColor.resolveWith((st) =>
|
||||
(fileDataBase64.value.isEmpty)
|
||||
? Constant.textDarkGrey
|
||||
: Constant.textOrange),
|
||||
shape: MaterialStateProperty.all<
|
||||
RoundedRectangleBorder>(
|
||||
RoundedRectangleBorder(
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
import '../app/constant.dart';
|
||||
import '../app/route.dart';
|
||||
|
||||
class CustomDialogPresensiSukses extends HookConsumerWidget {
|
||||
final String messageStatus;
|
||||
final String isiPesan;
|
||||
final ValueNotifier<bool> isLoadingAddressUserLocation;
|
||||
|
||||
CustomDialogPresensiSukses({
|
||||
required this.isLoadingAddressUserLocation,
|
||||
required this.messageStatus,
|
||||
required this.isiPesan,
|
||||
});
|
||||
@@ -79,7 +84,10 @@ class CustomDialogPresensiSukses extends HookConsumerWidget {
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(); // Close the dialog
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
homeRoute,
|
||||
(route) => false,
|
||||
);
|
||||
},
|
||||
style: ButtonStyle(
|
||||
backgroundColor: MaterialStateColor.resolveWith(
|
||||
|
||||
Reference in New Issue
Block a user