add customers and staffs

This commit is contained in:
Sai Naw Wun
2020-09-13 21:49:39 +06:30
parent aa8a6765de
commit eccea7ee02
45 changed files with 2094 additions and 1027 deletions

View File

@@ -1,11 +1,13 @@
const ok_doc_id = "ok";
const setting_doc_id = "setting";
const config_collection = "configs";
const user_collection = "users";
const invitations_collection = "invitations";
const setting_doc_id = "setting";
const privilege_collection = "privileges";
const ok_doc_id = "ok";
const biz_collection = "bizs";
const product_collection = "products";
const user_collection = "users";
const privilege_collection = "privileges";
const user_level_collection = "user_levels";
const storage_collection = "storages";
const buyer_collection = "buyers";

View File

@@ -9,7 +9,6 @@ class Role {
roleID = json['role_id'];
privileges = json['privileges'];
}
}
class Parser {
@@ -63,10 +62,6 @@ class UserLevel {
UserLevel({this.id, this.name, this.level});
factory UserLevel.fromMap(Map<String, dynamic> map, String docID) {
return UserLevel(
id: docID,
name: map['name'],
level: map['level']
);
return UserLevel(id: docID, name: map['name'], level: map['level']);
}
}

View File

@@ -22,6 +22,8 @@ class Setting {
String mmContactNumber;
String emailAddress;
String facebookLink;
bool inviteRequired;
String appUrl;
final String okEnergyId;
final String about;
@@ -84,6 +86,8 @@ class Setting {
this.mmContactNumber,
this.emailAddress,
this.facebookLink,
this.inviteRequired,
this.appUrl,
this.about,
this.okEnergyId,
this.terms,
@@ -122,6 +126,8 @@ class Setting {
return Setting(
supportBuildNum: map['support_build_number'],
inviteRequired: map['invite_required'],
appUrl: map['app_url'],
usaAddress: map['usa_address'],
mmAddress: map['mm_address'],
usaContactNumber: map['usa_contact_number'],

View File

@@ -1,22 +1,28 @@
import 'package:fcs/fcs/common/helpers/const.dart';
class User {
String id;
String name;
String phoneNumber;
bool hasSignup;
bool invited;
List<String> privileges = [];
String status;
String fcsID;
List<String> privileges = [];
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;
String get share => "Your phone number:$phoneNumber";
User({
this.id,
this.name,
this.phoneNumber,
this.fcsID,
this.status,
this.privileges,
});
factory User.fromJson(Map<String, dynamic> json) {
@@ -24,6 +30,7 @@ class User {
id: json['id'],
name: json['user_name'],
phoneNumber: json['phone_number'],
status: json['status'],
);
}
@@ -41,11 +48,16 @@ class User {
}
factory User.fromMap(Map<String, dynamic> map, String docID) {
List<String> _privileges =
map['privileges'] == null ? [] : map['privileges'].cast<String>();
return User(
id: docID,
name: map['user_name'],
phoneNumber: map['phone_number'],
);
id: docID,
name: map['user_name'],
phoneNumber: map['phone_number'],
status: map['status'],
fcsID: map['fcs_id'],
privileges: _privileges);
}
bool isCustomer() {
@@ -60,16 +72,26 @@ class User {
return privileges != null ? privileges.contains('admin') : false;
}
bool hasMaintenance() {
return privileges != null ? privileges.contains('mt') : false;
bool hasCustomers() {
return hasSysAdmin() ||
hasAdmin() ||
(privileges != null ? privileges.contains('c') : false);
}
bool hasCustomers() {
return privileges != null ? privileges.contains('c') : false;
bool hasStaffs() {
return hasSysAdmin() ||
hasAdmin() ||
(privileges != null ? privileges.contains('s') : false);
}
bool hasSupport() {
return hasSysAdmin() ||
hasAdmin() ||
(privileges != null ? privileges.contains('sp') : false);
}
@override
String toString() {
return 'User{name: $name, phoneNumber: $phoneNumber,hasSignup:$hasSignup}';
return 'User{name: $name, phoneNumber: $phoneNumber,status:$status}';
}
}