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