add disable customer function
This commit is contained in:
@@ -123,6 +123,8 @@
|
||||
"customer.status":"Status",
|
||||
"customer.fcs.id":"FCS ID",
|
||||
"customer.invitation.request.confirm":"Accept customer",
|
||||
"customer.disable.btn":"Disable",
|
||||
"customer.enable.btn":"Enable",
|
||||
"Customer End ================================================================":"",
|
||||
|
||||
"Invitation Start ================================================================":"",
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
"faq.edit.question":"မေးခွန်း",
|
||||
"faq.edit.answer":"အဖြေ",
|
||||
"faq.edit.sn":"S/N",
|
||||
"faq.edit.delete.confirm":"Delete this FAQ?",
|
||||
"faq.edit.delete.confirm":"မေးခွန်းကို ဖျက်မလား?",
|
||||
"faq.edit.page":"Additional Page",
|
||||
"faq.edit.page.label":"Page label",
|
||||
"faq.edit.page.label.eng":"Page label in English",
|
||||
@@ -94,7 +94,7 @@
|
||||
|
||||
"Home Start ================================================================":"",
|
||||
"home.invitation.request.msg":"ဖိတ်ကြားမှု တောင်းဆိုသည်ကို လုပ်ဆောင်နေပါသည်!",
|
||||
"home.search":"Tracking number ရိုက်ထဲ့ပါ",
|
||||
"home.search":"Tracking number ရိုက်ထည့်ပါ",
|
||||
"home.search.btn":"ရှာမည်",
|
||||
"Home End ================================================================":"",
|
||||
|
||||
@@ -123,6 +123,8 @@
|
||||
"customer.status":"အခြေအနေ",
|
||||
"customer.fcs.id":"FCS ID",
|
||||
"customer.invitation.request.confirm":"လက်ခံ လိုက်ပါ",
|
||||
"customer.disable.btn":"ပိတ်ပါ",
|
||||
"customer.enable.btn":"ဖွင့်ပါ",
|
||||
"Customer End ================================================================":"",
|
||||
|
||||
"Invitation Start ================================================================":"",
|
||||
@@ -367,8 +369,8 @@
|
||||
"rate.custom_duty":"အကောက်ခွန်",
|
||||
"rate.cargo.type":"ကုန်ပစ္စည်းအမျိုးအစား",
|
||||
"rate.discount_by_weight":"အထူးလျှော့စျေး",
|
||||
"rate.discount_by_weight.edit.delete.confirm":"Delete this discount by weight?",
|
||||
"rate.custom.edit.delete.confirm":"Delete this custom duty?",
|
||||
"rate.discount_by_weight.edit.delete.confirm":"လျှော့စျေးနှုန်းကို ဖျက်မလား?",
|
||||
"rate.custom.edit.delete.confirm":"အကောက်ခွန်ကို ဖျက်မလား?",
|
||||
"Rate End ================================================================":"",
|
||||
|
||||
"Cargo Start ================================================================":"",
|
||||
@@ -377,6 +379,7 @@
|
||||
"cargo.weight":"အလေးချိန်",
|
||||
"cargo.rate":"စျေးနှုန်း",
|
||||
"cargo.amount":"ပမာဏ",
|
||||
"cargo.edit.delete.confirm":"ကုန်ပစ္စည်းကို ဖျက်မလား?",
|
||||
"Cargo End ================================================================":"",
|
||||
|
||||
"Invoices Start ================================================================":"",
|
||||
@@ -432,7 +435,7 @@
|
||||
"discount.name":"ဝယ်ယူသူအမည်",
|
||||
"discount.amount":"ပမာဏ",
|
||||
"discount.status":"အခြေအနေ",
|
||||
"discount.edit.delete.confirm":"Delete this discount?",
|
||||
"discount.edit.delete.confirm":"လျှော့စျေးကို ဖျက်မလား?",
|
||||
"Discount End ================================================================":"",
|
||||
|
||||
"delivery_addresses Start ================================================================":"",
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:fcs/domain/entities/setting.dart';
|
||||
import 'package:fcs/domain/entities/user.dart';
|
||||
import 'package:fcs/domain/exceiptions/signin_exception.dart';
|
||||
import 'package:fcs/helpers/api_helper.dart';
|
||||
import 'package:fcs/helpers/firebase_helper.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
@@ -113,12 +114,11 @@ class AuthFb {
|
||||
Future<void> _addUserToStream({bool refreshIdToken = false}) async {
|
||||
FirebaseUser firebaseUser = await _fb.currentUser();
|
||||
if (firebaseUser == null) return null;
|
||||
IdTokenResult idToken =
|
||||
await firebaseUser.getIdToken(refresh: refreshIdToken);
|
||||
Map claims = await getClaims(refreshIdToken: refreshIdToken);
|
||||
|
||||
log.info("Claims:${idToken.claims}");
|
||||
log.info("Claims:$claims");
|
||||
|
||||
String cid = idToken.claims["cid"];
|
||||
String cid = claims["cid"];
|
||||
User user;
|
||||
if (cid != null && cid != "") {
|
||||
user = await _getUserFromFirestore(cid);
|
||||
@@ -129,7 +129,7 @@ class AuthFb {
|
||||
}
|
||||
|
||||
// add privileges
|
||||
String privileges = idToken.claims["pr"];
|
||||
String privileges = claims["pr"];
|
||||
if (privileges != null && privileges != "") {
|
||||
user.privileges = privileges.split(":").toList();
|
||||
} else {
|
||||
@@ -194,12 +194,6 @@ class AuthFb {
|
||||
payload: {"preferred_currency": currency}, token: await getToken());
|
||||
}
|
||||
|
||||
Future<String> getToken() async {
|
||||
FirebaseUser firebaseUser = await _fb.currentUser();
|
||||
IdTokenResult token = await firebaseUser.getIdToken();
|
||||
return token.token;
|
||||
}
|
||||
|
||||
Stream<Setting> settings() async* {
|
||||
Stream<DocumentSnapshot> snapshot = Firestore.instance
|
||||
.collection(config_collection)
|
||||
@@ -215,8 +209,8 @@ class AuthFb {
|
||||
Future<String> _getCurrentUserID() async {
|
||||
FirebaseUser firebaseUser = await _fb.currentUser();
|
||||
if (firebaseUser == null) return null;
|
||||
IdTokenResult idToken = await firebaseUser.getIdToken();
|
||||
String cid = idToken.claims["cid"];
|
||||
Map claims = await getClaims();
|
||||
String cid = claims["cid"];
|
||||
return cid;
|
||||
}
|
||||
|
||||
@@ -239,14 +233,17 @@ class AuthFb {
|
||||
userListener.cancel();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// get privilege from claim
|
||||
IdTokenResult idToken = await firebaseUser.getIdToken(refresh: true);
|
||||
String privileges = idToken.claims["pr"];
|
||||
if (privileges != null && privileges != "") {
|
||||
user.privileges = privileges.split(":").toList();
|
||||
}
|
||||
|
||||
controller.add(user);
|
||||
} catch (e) {
|
||||
controller.add(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -80,4 +80,9 @@ class UserDataProvider {
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
Future<void> enableUser(String userID, bool enabled) async {
|
||||
return await requestAPI("/enable_user", "PUT",
|
||||
payload: {"id": userID, "enabled": enabled}, token: await getToken());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,11 +51,6 @@ class AuthServiceImp implements AuthService {
|
||||
return authFb.joinInvite(userName);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> getToken() {
|
||||
return authFb.getToken();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> hasInvite() {
|
||||
return authFb.hasInvite();
|
||||
|
||||
@@ -13,5 +13,4 @@ abstract class AuthService {
|
||||
Future<bool> hasInvite();
|
||||
Stream<User> getUserStream();
|
||||
Stream<Setting> getSetting();
|
||||
Future<String> getToken();
|
||||
}
|
||||
|
||||
@@ -48,4 +48,9 @@ class UserServiceImp implements UserService {
|
||||
Future<void> uploadMsgToken(String token) {
|
||||
return userDataProvider.uploadMsgToken(token);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> enableUser(String userID, bool enabled) {
|
||||
return userDataProvider.enableUser(userID, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,5 @@ abstract class UserService {
|
||||
Future<List<User>> searchUser(String term);
|
||||
Future<void> uploadMsgToken(String token);
|
||||
Future<void> removeMsgToken(String token);
|
||||
Future<void> enableUser(String userID, bool enabled);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ const rate_doc_id = "rate";
|
||||
|
||||
const user_requested_status = "requested";
|
||||
const user_invited_status = "invited";
|
||||
const user_disabled_status = "disabled";
|
||||
const user_joined_status = "joined";
|
||||
|
||||
const pkg_files_path = "/packages";
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:fcs/helpers/const.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
@@ -53,9 +52,11 @@ class User {
|
||||
String get phone => phoneNumber != null && phoneNumber.startsWith("959")
|
||||
? "0${phoneNumber.substring(2)}"
|
||||
: phoneNumber;
|
||||
bool get joined => status != null && status == userStatusJoined;
|
||||
bool get invited => status != null && status == userStatusInvited;
|
||||
bool get requested => status != null && status == userStatusRequested;
|
||||
bool get joined => status != null && status == user_joined_status;
|
||||
bool get invited => status != null && status == user_invited_status;
|
||||
bool get requested => status != null && status == user_requested_status;
|
||||
bool get disabled => status != null && status == user_disabled_status;
|
||||
|
||||
String get share => "Your phone number:$phoneNumber";
|
||||
User(
|
||||
{this.id,
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
const userStatusInvited = "invited";
|
||||
const userStatusJoined = "joined";
|
||||
const userStatusRequested = "requested";
|
||||
@@ -15,6 +15,14 @@ Future<String> getToken() async {
|
||||
return token.token;
|
||||
}
|
||||
|
||||
Future<Map> getClaims({bool refreshIdToken = false}) async {
|
||||
FirebaseUser firebaseUser = await auth.currentUser();
|
||||
if (firebaseUser == null) return null;
|
||||
IdTokenResult idToken =
|
||||
await firebaseUser.getIdToken(refresh: refreshIdToken);
|
||||
return idToken.claims;
|
||||
}
|
||||
|
||||
Future<String> uploadStorage(String path, File file, {String fileName}) async {
|
||||
if (fileName == null) {
|
||||
fileName = Uuid().v4();
|
||||
|
||||
@@ -29,7 +29,7 @@ class _BuyingOnlinePagetate extends State<BuyingOnlinePage>
|
||||
|
||||
final phoneNumberBox = DisplayText(
|
||||
text: mainModel.user.phone,
|
||||
labelTextKey: getLocalString(context, "contact.phone"),
|
||||
labelTextKey: "contact.phone",
|
||||
iconData: Icons.location_on,
|
||||
);
|
||||
final nameBox = Center(
|
||||
@@ -39,12 +39,12 @@ class _BuyingOnlinePagetate extends State<BuyingOnlinePage>
|
||||
));
|
||||
final fcsIdBox = DisplayText(
|
||||
text: mainModel.user.fcsID,
|
||||
labelTextKey: getLocalString(context, "customer.fcs.id"),
|
||||
labelTextKey: "customer.fcs.id",
|
||||
icon: FcsIDIcon(),
|
||||
);
|
||||
final shippingAddressBox = DisplayText(
|
||||
text: mainModel.setting.usaAddress,
|
||||
labelTextKey: getLocalString(context, "profile.usa.shipping.address"),
|
||||
labelTextKey: "profile.usa.shipping.address",
|
||||
iconData: Icons.location_on,
|
||||
);
|
||||
final instructionBox = Container(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fcs/data/services/services.dart';
|
||||
import 'package:fcs/domain/vo/contact.dart';
|
||||
import 'package:fcs/helpers/firebase_helper.dart';
|
||||
import 'package:fcs/pages/main/model/base_model.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
@@ -10,8 +10,7 @@ class ContactModel extends BaseModel {
|
||||
|
||||
Future<void> saveContact(Contact contact) async {
|
||||
await request("/contact", "PUT",
|
||||
payload: contact.toMap(),
|
||||
token: await Services.instance.authService.getToken());
|
||||
payload: contact.toMap(), token: await getToken());
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import 'package:fcs/domain/constants.dart';
|
||||
import 'package:fcs/domain/entities/user.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/customer/model/customer_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/display_text.dart';
|
||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||
import 'package:fcs/pages/widgets/local_button.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -42,6 +44,13 @@ class _CustomerEditorState extends State<CustomerEditor> {
|
||||
],
|
||||
);
|
||||
|
||||
final enabled = widget.customer.status != user_disabled_status;
|
||||
final enableBox = LocalButton(
|
||||
textKey: enabled ? "customer.disable.btn" : "customer.enable.btn",
|
||||
iconData: enabled ? Icons.lock : Icons.lock_open,
|
||||
color: enabled ? primaryColor : Colors.grey,
|
||||
callBack: () => _enable(!enabled),
|
||||
);
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: SafeArea(
|
||||
@@ -90,6 +99,9 @@ class _CustomerEditorState extends State<CustomerEditor> {
|
||||
getLocalString(
|
||||
context, "customer.invitation.request.confirm"),
|
||||
callack: _add)
|
||||
: Container(),
|
||||
widget.customer.joined || widget.customer.disabled
|
||||
? enableBox
|
||||
: Container()
|
||||
],
|
||||
),
|
||||
@@ -118,4 +130,23 @@ class _CustomerEditorState extends State<CustomerEditor> {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_enable(bool enabled) async {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
if (widget.customer == null) return;
|
||||
CustomerModel customerModel =
|
||||
Provider.of<CustomerModel>(context, listen: false);
|
||||
try {
|
||||
await customerModel.enableUser(widget.customer, enabled);
|
||||
Navigator.pop(context);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
} finally {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,10 @@ import 'package:fcs/pages/customer/customer_editor.dart';
|
||||
import 'package:fcs/pages/customer/model/customer_model.dart';
|
||||
import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/user_search/user_serach.dart';
|
||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons/flutter_icons.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:share/share.dart';
|
||||
@@ -59,7 +57,8 @@ class _CustomerListState extends State<CustomerList> {
|
||||
),
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(builder: (context) => InvitationCreate()));
|
||||
Navigator.of(context).push(
|
||||
CupertinoPageRoute(builder: (context) => InvitationCreate()));
|
||||
},
|
||||
icon: Icon(Icons.add),
|
||||
label: LocalText(context, "invitation.new", color: Colors.white),
|
||||
@@ -147,20 +146,10 @@ class _CustomerListState extends State<CustomerList> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 5),
|
||||
child: _status(customer.status),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 5),
|
||||
child: Text(customer.getLastMessageTime),
|
||||
),
|
||||
getCount(customer),
|
||||
customer.status == user_invited_status
|
||||
? FlatButton(
|
||||
? Padding(
|
||||
padding: const EdgeInsets.only(right: 8.0),
|
||||
child: FlatButton(
|
||||
onPressed: () => _share(customer),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(18.0),
|
||||
@@ -174,8 +163,21 @@ class _CustomerListState extends State<CustomerList> {
|
||||
Icon(Icons.share, color: primaryColor),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 5),
|
||||
child: _status(customer.status),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 5),
|
||||
child: Text(customer.getLastMessageTime),
|
||||
),
|
||||
getCount(customer),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -197,14 +199,14 @@ class _CustomerListState extends State<CustomerList> {
|
||||
}
|
||||
|
||||
Widget _status(String status) {
|
||||
return user_requested_status == status
|
||||
return user_requested_status == status || user_disabled_status == status
|
||||
? Text(status, style: TextStyle(color: primaryColor, fontSize: 14))
|
||||
: Container();
|
||||
}
|
||||
|
||||
_select(User customer) {
|
||||
Navigator.of(context)
|
||||
.push(CupertinoPageRoute(builder: (context) => CustomerEditor(customer: customer)));
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => CustomerEditor(customer: customer)));
|
||||
}
|
||||
|
||||
_gotoMsg(User customer) {
|
||||
@@ -212,7 +214,8 @@ class _CustomerListState extends State<CustomerList> {
|
||||
Provider.of<MessageModel>(context, listen: false);
|
||||
messageModel.initQuery(customer.id);
|
||||
Navigator.of(context)
|
||||
.push(CupertinoPageRoute(builder: (context) => MessageDetail(
|
||||
.push(CupertinoPageRoute(
|
||||
builder: (context) => MessageDetail(
|
||||
receiverID: customer.id,
|
||||
receiverName: customer.name,
|
||||
messageModel: messageModel,
|
||||
|
||||
@@ -95,4 +95,8 @@ class CustomerModel extends BaseModel {
|
||||
var snap = await Firestore.instance.collection(path).document(id).get();
|
||||
return User.fromMap(snap.data, snap.documentID);
|
||||
}
|
||||
|
||||
Future<void> enableUser(User user, bool enabled) {
|
||||
return Services.instance.userService.enableUser(user.id, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,10 @@ class _FAQEditorState extends State<FAQEditor> {
|
||||
color: primaryColor, fontSize: 20),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.delete),
|
||||
icon: Icon(
|
||||
Icons.delete,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: _delete,
|
||||
)
|
||||
],
|
||||
@@ -176,80 +179,6 @@ class _FAQEditorState extends State<FAQEditor> {
|
||||
),
|
||||
),
|
||||
)));
|
||||
|
||||
LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
body: CustomScrollView(slivers: [
|
||||
SliverAppBar(
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
CupertinoIcons.back,
|
||||
size: 30,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
expandedHeight: 150.0,
|
||||
floating: true,
|
||||
pinned: true,
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
centerTitle: true,
|
||||
titlePadding: EdgeInsets.symmetric(vertical: 10),
|
||||
title: LocalText(
|
||||
context,
|
||||
_isNew ? 'faq.add.title' : 'faq.edit.title',
|
||||
fontSize: 20,
|
||||
color: Colors.white,
|
||||
)),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.delete),
|
||||
onPressed: _delete,
|
||||
)
|
||||
],
|
||||
),
|
||||
SliverList(
|
||||
delegate: SliverChildListDelegate([
|
||||
Form(
|
||||
key: _formKey,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 24.0, right: 24.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
snBox,
|
||||
Center(child: itemTitle(context, "faq.edit.eng")),
|
||||
subItemTitle(context, "faq.edit.question",
|
||||
iconData: SimpleLineIcons.question),
|
||||
questionEngBox,
|
||||
subItemTitle(context, "faq.edit.answer",
|
||||
iconData: MaterialCommunityIcons.message_reply_text),
|
||||
answerEngBox,
|
||||
Divider(),
|
||||
Center(child: itemTitle(context, "faq.edit.mm")),
|
||||
subItemTitle(context, "faq.edit.question",
|
||||
iconData: SimpleLineIcons.question),
|
||||
questionMmBox,
|
||||
subItemTitle(context, "faq.edit.answer",
|
||||
iconData: MaterialCommunityIcons.message_reply_text),
|
||||
answerMmBox,
|
||||
Divider(),
|
||||
Center(child: itemTitle(context, "faq.edit.page")),
|
||||
pageLinkBox,
|
||||
pageLabelEngBox,
|
||||
pageLabelMmBox,
|
||||
fcsButton(context, getLocalString(context, "btn.save"),
|
||||
callack: _save),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
]))
|
||||
])));
|
||||
}
|
||||
|
||||
_save() async {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:fcs/data/services/services.dart';
|
||||
import 'package:fcs/domain/entities/faq.dart';
|
||||
import 'package:fcs/helpers/firebase_helper.dart';
|
||||
import 'package:fcs/pages/main/model/base_model.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
@@ -38,19 +38,16 @@ class FAQModel extends BaseModel {
|
||||
|
||||
Future<void> addFAQ(FAQ faq) async {
|
||||
await request("/faqs", "POST",
|
||||
payload: faq.toMap(),
|
||||
token: await Services.instance.authService.getToken());
|
||||
payload: faq.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> updateFAQ(FAQ faq) async {
|
||||
await request("/faqs", "PUT",
|
||||
payload: faq.toMap(),
|
||||
token: await Services.instance.authService.getToken());
|
||||
payload: faq.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> deleteFAQ(FAQ faq) async {
|
||||
await request("/faqs", "DELETE",
|
||||
payload: faq.toMap(),
|
||||
token: await Services.instance.authService.getToken());
|
||||
payload: faq.toMap(), token: await getToken());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pdfview/flutter_pdfview.dart';
|
||||
import 'package:image_downloader/image_downloader.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:share/share.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class PaymentPDFScreen extends StatefulWidget {
|
||||
final String path;
|
||||
|
||||
@@ -205,6 +205,8 @@ class _HomePageState extends State<HomePage> {
|
||||
Widget build(BuildContext context) {
|
||||
User user = Provider.of<MainModel>(context).user;
|
||||
if (user == null) {
|
||||
Future.microtask(
|
||||
() => Navigator.pushNamedAndRemoveUntil(context, "/", (r) => false));
|
||||
return Container();
|
||||
}
|
||||
|
||||
@@ -313,13 +315,13 @@ class _HomePageState extends State<HomePage> {
|
||||
CupertinoPageRoute(builder: (context) => DeliverList())));
|
||||
|
||||
List<Widget> widgets = [];
|
||||
List<Widget> widgetsFcs = [];
|
||||
widgets.add(notiBtn);
|
||||
if (user.joined) {
|
||||
widgets.add(packagesBtn);
|
||||
widgets.add(shipmentBtn);
|
||||
widgets.add(invoicesBtn);
|
||||
widgets.add(faqBtn);
|
||||
|
||||
List<Widget> widgetsFcs = [];
|
||||
if (user.hasPackages()) widgetsFcs.add(packagesBtnFcs);
|
||||
if (user.hasShipment()) widgetsFcs.add(shipmentBtnFcs);
|
||||
if (user.hasInvoices()) widgetsFcs.add(invoicesBtnFcs);
|
||||
@@ -332,6 +334,8 @@ class _HomePageState extends State<HomePage> {
|
||||
if (user.hasCustomers()) widgetsFcs.add(customersBtn);
|
||||
if (user.hasAdmin()) widgetsFcs.add(discountBtn);
|
||||
if (user.hasStaffs()) widgetsFcs.add(staffBtn);
|
||||
}
|
||||
widgets.add(faqBtn);
|
||||
|
||||
final fcsToggle = ToggleButtons(
|
||||
selectedColor: Colors.white,
|
||||
|
||||
@@ -10,7 +10,6 @@ import 'package:provider/provider.dart';
|
||||
import '../../helpers/theme.dart';
|
||||
import '../signin/signin_page.dart';
|
||||
import '../widgets/banner.dart';
|
||||
import '../widgets/bottom_up_page_route.dart';
|
||||
import '../widgets/offline_redirect.dart';
|
||||
|
||||
final msgLog = Logger('backgroundMessageHandler');
|
||||
|
||||
@@ -135,7 +135,7 @@ class _PaymentMethodPageState extends State<PaymentMethodPage> {
|
||||
Expanded(
|
||||
child: DisplayText(
|
||||
text: text,
|
||||
labelTextKey: getLocalString(context, labelKey),
|
||||
labelTextKey: labelKey,
|
||||
iconData: iconData,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -120,8 +120,7 @@ class _CargoEditorState extends State<CargoEditor> {
|
||||
}
|
||||
|
||||
_delete() {
|
||||
showConfirmDialog(
|
||||
context, "cargo_type.edit.delete.confirm", _deleteCargoType);
|
||||
showConfirmDialog(context, "cargo.edit.delete.confirm", _deleteCargoType);
|
||||
}
|
||||
|
||||
_deleteCargoType() async {
|
||||
|
||||
@@ -126,7 +126,8 @@ class _CustomEditorState extends State<CustomEditor> {
|
||||
}
|
||||
|
||||
_delete() {
|
||||
showConfirmDialog(context, "cargo.edit.delete.confirm", _deleteCustomDuty);
|
||||
showConfirmDialog(
|
||||
context, "rate.custom.edit.delete.confirm", _deleteCustomDuty);
|
||||
}
|
||||
|
||||
_deleteCustomDuty() async {
|
||||
|
||||
@@ -77,7 +77,8 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
||||
child: ListView(
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
fcsButton(context, getLocalString(context, "rate.cal.title"), callack: () {
|
||||
fcsButton(context, getLocalString(context, "rate.cal.title"),
|
||||
callack: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => ShipmentRatesCal()));
|
||||
}),
|
||||
@@ -93,12 +94,14 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15),
|
||||
Spacer(),
|
||||
IconButton(
|
||||
isEditable
|
||||
? IconButton(
|
||||
icon: Icon(Icons.edit, color: primaryColor),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => CargoTypeList()));
|
||||
})
|
||||
: Container()
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -117,12 +120,15 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15),
|
||||
Spacer(),
|
||||
IconButton(
|
||||
isEditable
|
||||
? IconButton(
|
||||
icon: Icon(Icons.edit, color: primaryColor),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => DiscountByWeightList()));
|
||||
builder: (context) =>
|
||||
DiscountByWeightList()));
|
||||
})
|
||||
: Container()
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -151,12 +157,14 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15),
|
||||
Spacer(),
|
||||
IconButton(
|
||||
isEditable
|
||||
? IconButton(
|
||||
icon: Icon(Icons.edit, color: primaryColor),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => CustomList()));
|
||||
})
|
||||
: Container()
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fcs/data/services/services.dart';
|
||||
import 'package:fcs/domain/vo/term.dart';
|
||||
import 'package:fcs/helpers/firebase_helper.dart';
|
||||
import 'package:fcs/pages/main/model/base_model.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
@@ -10,7 +10,6 @@ class TermModel extends BaseModel {
|
||||
|
||||
Future<void> saveTerm(Term term) async {
|
||||
await request("/terms", "PUT",
|
||||
payload: term.toMap(),
|
||||
token: await Services.instance.authService.getToken());
|
||||
payload: term.toMap(), token: await getToken());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,14 @@ class LocalButton extends StatelessWidget {
|
||||
final CallBack callBack;
|
||||
final IconData iconData;
|
||||
final String textKey;
|
||||
final Color color;
|
||||
|
||||
const LocalButton({Key key, this.callBack, this.iconData, this.textKey})
|
||||
const LocalButton(
|
||||
{Key key,
|
||||
this.callBack,
|
||||
this.iconData,
|
||||
this.textKey,
|
||||
this.color = primaryColor})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -20,7 +26,7 @@ class LocalButton extends StatelessWidget {
|
||||
child: Container(
|
||||
height: 45.0,
|
||||
decoration: BoxDecoration(
|
||||
color: primaryColor,
|
||||
color: color,
|
||||
shape: BoxShape.rectangle,
|
||||
),
|
||||
child: ButtonTheme(
|
||||
|
||||
Reference in New Issue
Block a user