step 16 : add M_CompanyID for trans, menu drawer, fix bug overflow btn
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../app/constant.dart';
|
||||
import '../model/auth_model.dart';
|
||||
import 'base_repository.dart';
|
||||
@@ -82,7 +86,7 @@ class AuthRepository extends BaseRepository {
|
||||
// model: AuthDoctorModel.fromJson(resp["data"]["user"]),
|
||||
// );
|
||||
// return result;
|
||||
|
||||
|
||||
if (resp["status"] == "OK") {
|
||||
return resp['message'];
|
||||
} else {
|
||||
|
||||
@@ -2,11 +2,33 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../app/constant.dart';
|
||||
|
||||
abstract class BaseRepository {
|
||||
final Dio dio;
|
||||
BaseRepository({required this.dio});
|
||||
|
||||
Future<String> getCompanyID() async {
|
||||
final shared = await SharedPreferences.getInstance();
|
||||
String M_CompanyID = "0";
|
||||
|
||||
if (shared != null) {
|
||||
final bearerString = shared.get(Constant.bearerName).toString();
|
||||
final xmodel = jsonDecode(bearerString);
|
||||
if (xmodel != null) {
|
||||
M_CompanyID = xmodel["model"]["M_CompanyID"];
|
||||
}
|
||||
}
|
||||
|
||||
if (M_CompanyID == "0") {
|
||||
throw BaseRepositoryException(message: 'Invalid Company ID');
|
||||
}
|
||||
|
||||
return M_CompanyID;
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> post({
|
||||
required Map<String, dynamic> param,
|
||||
required String service,
|
||||
|
||||
@@ -58,6 +58,7 @@ class TransaksiRepository extends BaseRepository {
|
||||
String sender,
|
||||
String url) async {
|
||||
String paramPostInUrl = "";
|
||||
String M_CompanyID = await getCompanyID();
|
||||
if (tipe == "DEBIT") {
|
||||
sender = "";
|
||||
paramPostInUrl =
|
||||
@@ -69,6 +70,8 @@ class TransaksiRepository extends BaseRepository {
|
||||
"?tanggal=$tanggal&tipe=$tipe&kategoriid=$kategoriid&jumlah=$jumlah&catatan=$catatan&url=$url&userid=$userid&sender=$sender";
|
||||
}
|
||||
}
|
||||
|
||||
paramPostInUrl += "&companyid=$M_CompanyID";
|
||||
// /?tanggal=2023-12-29&tipe=KREDIT&kategoriid=3&jumlah=5000&catatan=Lakban%20Besar&url=&userid=1&sender=
|
||||
|
||||
final service =
|
||||
|
||||
Reference in New Issue
Block a user