Commit 77a3594d authored by Dio Maulana's avatar Dio Maulana

jagain absen masuk keluar di frontend

parent 6ae1e7c8
...@@ -5,6 +5,7 @@ import 'package:excelso_attendance/helper/pref.dart'; ...@@ -5,6 +5,7 @@ import 'package:excelso_attendance/helper/pref.dart';
import 'package:excelso_attendance/main.dart'; import 'package:excelso_attendance/main.dart';
import 'package:excelso_attendance/models/absent.dart'; import 'package:excelso_attendance/models/absent.dart';
import 'package:excelso_attendance/models/branch.dart'; import 'package:excelso_attendance/models/branch.dart';
import 'package:excelso_attendance/models/profile.dart';
import 'package:excelso_attendance/models/shift.dart'; import 'package:excelso_attendance/models/shift.dart';
import 'package:excelso_attendance/resource/strings.dart'; import 'package:excelso_attendance/resource/strings.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
...@@ -113,9 +114,11 @@ class Api { ...@@ -113,9 +114,11 @@ class Api {
return ApiResponse(error: true, msg: Strings.cantConnectToServer); return ApiResponse(error: true, msg: Strings.cantConnectToServer);
} else { } else {
if (jsonObject['status'] == "ok") { if (jsonObject['status'] == "ok") {
Map<String, dynamic> user = jsonObject['data']['user'];
return ApiResponse( return ApiResponse(
error: false, error: false,
msg: Strings.succesGetData, msg: Strings.succesGetData,
data: ProfileModel.json(user),
); );
} else { } else {
return ApiResponse( return ApiResponse(
......
import 'package:excelso_attendance/helper/component/button.dart';
import 'package:excelso_attendance/resource/font.dart';
import 'package:excelso_attendance/resource/style.dart';
import 'package:flutter/material.dart';
Future<dynamic> modalDialogGlobal({
required BuildContext context,
required Size size,
required String title,
required String contentBody,
required String buttonText,
required void Function() tapButton,
bool isActiveCancelButton = false,
bool isCustomSecondButton = false,
String customSecondButtonText = '',
Widget? navigateToCustomButton,
}) async {
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext ctxDialog) => AlertDialog(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(15))),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: getBoldStyle(
color: Colors.black,
fontFamily: FontConstants.montserrat,
fontSize: FontSize.s24,
),
),
const SizedBox(
height: 16,
),
Text(
contentBody,
style: getMediumStyle(
color: Colors.black,
fontFamily: FontConstants.openSans,
fontSize: FontSize.s16,
),
),
const SizedBox(
height: 42,
),
InkWell(
onTap: () {
tapButton();
},
child: CustomButton(
text: buttonText,
),
),
(isActiveCancelButton)
? InkWell(
onTap: () {
Navigator.pop(context);
},
child: const CustomButton(
text: "Cancel",
colorButton: Colors.transparent,
colorText: Colors.black,
),
)
: const SizedBox(),
(isCustomSecondButton)
? Column(
children: [
const SizedBox(
height: 10,
),
InkWell(
onTap: () {
Navigator.pop(context);
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => navigateToCustomButton!),
);
},
child: CustomButton(
text: customSecondButtonText,
),
),
],
)
: const SizedBox()
],
),
),
);
}
class ProfileModel {
String id;
String brand;
String name;
bool attendanceIn;
bool attendanceOut;
ProfileModel({
required this.id,
required this.brand,
required this.name,
required this.attendanceIn,
required this.attendanceOut,
});
factory ProfileModel.json(Map<String, dynamic> json) {
return ProfileModel(
id: json['id'],
brand: json['brand'],
name: json['name'],
attendanceIn: json['today_attendance_in'],
attendanceOut: json['today_attendance_out'],
);
}
}
This diff is collapsed.
...@@ -6,9 +6,11 @@ import 'package:excelso_attendance/helper/arguments/route_args.dart'; ...@@ -6,9 +6,11 @@ import 'package:excelso_attendance/helper/arguments/route_args.dart';
import 'package:excelso_attendance/helper/component/button.dart'; import 'package:excelso_attendance/helper/component/button.dart';
// import 'package:excelso_attendance/helper/component/text_field.dart'; // import 'package:excelso_attendance/helper/component/text_field.dart';
import 'package:excelso_attendance/helper/global_function/date_time.dart'; import 'package:excelso_attendance/helper/global_function/date_time.dart';
import 'package:excelso_attendance/helper/modal_dialog.dart';
import 'package:excelso_attendance/helper/pref.dart'; import 'package:excelso_attendance/helper/pref.dart';
import 'package:excelso_attendance/helper/widget_responsive.dart'; import 'package:excelso_attendance/helper/widget_responsive.dart';
import 'package:excelso_attendance/models/branch.dart'; import 'package:excelso_attendance/models/branch.dart';
import 'package:excelso_attendance/models/profile.dart';
import 'package:excelso_attendance/models/shift.dart'; import 'package:excelso_attendance/models/shift.dart';
import 'package:excelso_attendance/resource/assets.dart'; import 'package:excelso_attendance/resource/assets.dart';
import 'package:excelso_attendance/resource/colors.dart'; import 'package:excelso_attendance/resource/colors.dart';
...@@ -349,8 +351,42 @@ class _BodyWidgetState extends State<BodyWidget> { ...@@ -349,8 +351,42 @@ class _BodyWidgetState extends State<BodyWidget> {
).then((apiResponse) { ).then((apiResponse) {
EasyLoading.dismiss(); EasyLoading.dismiss();
if (apiResponse.error) { if (apiResponse.error) {
EasyLoading.showToast(apiResponse.msg); modalDialogGlobal(
context: context,
size: MediaQuery.of(context).size,
title: "Gagal",
contentBody: apiResponse.msg,
buttonText: "Ok",
tapButton: () {
Navigator.pop(context);
});
} else { } else {
ProfileModel profileUser =
apiResponse.data as ProfileModel;
if (profileUser.attendanceOut) {
modalDialogGlobal(
context: context,
size: MediaQuery.of(context).size,
title: "Gagal",
contentBody: Strings.alreadyOut,
buttonText: "Ok",
tapButton: () {
Navigator.pop(context);
});
return;
}
if (profileUser.attendanceIn == false) {
modalDialogGlobal(
context: context,
size: MediaQuery.of(context).size,
title: "Gagal",
contentBody: Strings.outButNotIn,
buttonText: "Ok",
tapButton: () {
Navigator.pop(context);
});
return;
}
Navigator.pushNamed( Navigator.pushNamed(
context, context,
Routes.absentCamera, Routes.absentCamera,
...@@ -966,8 +1002,30 @@ class _WidgetSelectShiftState extends State<WidgetSelectShift> { ...@@ -966,8 +1002,30 @@ class _WidgetSelectShiftState extends State<WidgetSelectShift> {
EasyLoading.dismiss(); EasyLoading.dismiss();
if (apiResponse.error) { if (apiResponse.error) {
Navigator.pop(context); Navigator.pop(context);
EasyLoading.showToast(apiResponse.msg); modalDialogGlobal(
context: context,
size: MediaQuery.of(context).size,
title: "Gagal",
contentBody: apiResponse.msg,
buttonText: "Ok",
tapButton: () {
Navigator.pop(context);
});
} else { } else {
ProfileModel profileUser = apiResponse.data as ProfileModel;
if (profileUser.attendanceIn) {
modalDialogGlobal(
context: context,
size: MediaQuery.of(context).size,
title: "Gagal",
contentBody: Strings.alreadyIn,
buttonText: "Ok",
tapButton: () {
Navigator.pop(context);
Navigator.pop(context);
});
return;
}
Navigator.popAndPushNamed( Navigator.popAndPushNamed(
context, context,
Routes.absentCamera, Routes.absentCamera,
......
This diff is collapsed.
...@@ -13,4 +13,9 @@ class Strings { ...@@ -13,4 +13,9 @@ class Strings {
static String serverError = "Something wrong with our server, refresh page"; static String serverError = "Something wrong with our server, refresh page";
static String succesGetData = "Success get data"; static String succesGetData = "Success get data";
static String pleaseWait = "Please wait..."; static String pleaseWait = "Please wait...";
static String cameraNotMounted = "Kamera tidak berhasil di load";
static String alreadyIn = "Anda sudah melakukan absen masuk hari ini";
static String alreadyOut = "Anda sudah melakukan absen keluar hari ini";
static String outButNotIn = "Anda belum melaukan absen masuk";
} }
...@@ -74,7 +74,7 @@ packages: ...@@ -74,7 +74,7 @@ packages:
source: hosted source: hosted
version: "2.5.1" version: "2.5.1"
camera_web: camera_web:
dependency: transitive dependency: "direct main"
description: description:
name: camera_web name: camera_web
sha256: bcbd775fb3a9d51cc3ece899d54ad66f6306410556bac5759f78e13f9228841f sha256: bcbd775fb3a9d51cc3ece899d54ad66f6306410556bac5759f78e13f9228841f
...@@ -425,7 +425,7 @@ packages: ...@@ -425,7 +425,7 @@ packages:
source: hosted source: hosted
version: "4.2.4" version: "4.2.4"
quiver: quiver:
dependency: transitive dependency: "direct main"
description: description:
name: quiver name: quiver
sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47 sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47
......
...@@ -31,6 +31,7 @@ environment: ...@@ -31,6 +31,7 @@ environment:
dependencies: dependencies:
autocomplete_textfield: ^2.0.1 autocomplete_textfield: ^2.0.1
camera: ^0.10.5+2 camera: ^0.10.5+2
camera_web: ^0.3.1+4
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2
dropdown_button2: ^2.1.3 dropdown_button2: ^2.1.3
flutter: flutter:
...@@ -39,6 +40,7 @@ dependencies: ...@@ -39,6 +40,7 @@ dependencies:
flutter_native_splash: ^2.3.0 flutter_native_splash: ^2.3.0
geolocator: ^9.0.2 geolocator: ^9.0.2
http: ^0.13.5 http: ^0.13.5
quiver: ^3.2.1
shared_preferences: ^2.1.1 shared_preferences: ^2.1.1
url_strategy: ^0.2.0 url_strategy: ^0.2.0
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
This is a placeholder for base href that will be replaced by the value of This is a placeholder for base href that will be replaced by the value of
the `--base-href` argument provided to `flutter build`. the `--base-href` argument provided to `flutter build`.
--> -->
<base href="$FLUTTER_BASE_HREF" /> <base href="/attendance/" />
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta content="IE=Edge" http-equiv="X-UA-Compatible" /> <meta content="IE=Edge" http-equiv="X-UA-Compatible" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment