update shipment type
This commit is contained in:
@@ -7,17 +7,12 @@ class FcsShipmentDataProvider {
|
|||||||
final log = Logger('FcsShipmentDataProvider');
|
final log = Logger('FcsShipmentDataProvider');
|
||||||
|
|
||||||
Future<void> createFcsShipment(FcsShipment fcsShipment) async {
|
Future<void> createFcsShipment(FcsShipment fcsShipment) async {
|
||||||
return await requestAPI("/fcs_shipments", "POST",
|
return await requestAPI("/shipments", "POST",
|
||||||
payload: fcsShipment.toMap(), token: await getToken());
|
payload: fcsShipment.toMap(), token: await getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateFcsShipment(FcsShipment fcsShipment) async {
|
Future<void> updateFcsShipment(FcsShipment fcsShipment) async {
|
||||||
return await requestAPI("/fcs_shipments", "PUT",
|
return await requestAPI("/shipments", "PUT",
|
||||||
payload: fcsShipment.toMap(), token: await getToken());
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> deleteFcsShipment(FcsShipment fcsShipment) async {
|
|
||||||
return await requestAPI("/fcs_shipments", "DELETE",
|
|
||||||
payload: fcsShipment.toMap(), token: await getToken());
|
payload: fcsShipment.toMap(), token: await getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,6 @@ class FcsShipmentServiceImp implements FcsShipmentService {
|
|||||||
return shipmentDataProvider.updateFcsShipment(fcsShipment);
|
return shipmentDataProvider.updateFcsShipment(fcsShipment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> deleteFcsShipment(FcsShipment fcsShipment) {
|
|
||||||
return shipmentDataProvider.deleteFcsShipment(fcsShipment);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<String> report(FcsShipment fcsShipment) {
|
Future<String> report(FcsShipment fcsShipment) {
|
||||||
return shipmentDataProvider.reportFcsShipment(fcsShipment);
|
return shipmentDataProvider.reportFcsShipment(fcsShipment);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'package:fcs/domain/entities/fcs_shipment.dart';
|
|||||||
abstract class FcsShipmentService {
|
abstract class FcsShipmentService {
|
||||||
Future<void> createFcsShipment(FcsShipment fcsShipment);
|
Future<void> createFcsShipment(FcsShipment fcsShipment);
|
||||||
Future<void> updateFcsShipment(FcsShipment fcsShipment);
|
Future<void> updateFcsShipment(FcsShipment fcsShipment);
|
||||||
Future<void> deleteFcsShipment(FcsShipment fcsShipment);
|
|
||||||
Future<String> report(FcsShipment fcsShipment);
|
Future<String> report(FcsShipment fcsShipment);
|
||||||
Future<void> processFcsShipment(String id);
|
Future<void> processFcsShipment(String id);
|
||||||
Future<void> cancelFcsShipment(String id);
|
Future<void> cancelFcsShipment(String id);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const invitations_collection = "invitations";
|
|||||||
const privilege_collection = "privileges";
|
const privilege_collection = "privileges";
|
||||||
const markets_collection = "markets";
|
const markets_collection = "markets";
|
||||||
const carton_sizes_collection = "carton_sizes";
|
const carton_sizes_collection = "carton_sizes";
|
||||||
|
const shipment_type_collection = "shipment_types";
|
||||||
|
|
||||||
const packages_collection = "packages";
|
const packages_collection = "packages";
|
||||||
const messages_collection = "messages";
|
const messages_collection = "messages";
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ class FcsShipment {
|
|||||||
String? id;
|
String? id;
|
||||||
String? shipmentNumber;
|
String? shipmentNumber;
|
||||||
DateTime? cutoffDate;
|
DateTime? cutoffDate;
|
||||||
|
String? shipmentTypeId;
|
||||||
String? shipType;
|
String? shipType;
|
||||||
DateTime? arrivalDate;
|
DateTime? arrivalDate;
|
||||||
DateTime? departureDate;
|
DateTime? departureDate;
|
||||||
@@ -19,6 +20,7 @@ class FcsShipment {
|
|||||||
this.id,
|
this.id,
|
||||||
this.shipmentNumber,
|
this.shipmentNumber,
|
||||||
this.cutoffDate,
|
this.cutoffDate,
|
||||||
|
this.shipmentTypeId,
|
||||||
this.shipType,
|
this.shipType,
|
||||||
this.status,
|
this.status,
|
||||||
this.arrivalDate,
|
this.arrivalDate,
|
||||||
@@ -34,17 +36,14 @@ class FcsShipment {
|
|||||||
map['cutoff_date'] == null ? null : (map['cutoff_date'] as Timestamp);
|
map['cutoff_date'] == null ? null : (map['cutoff_date'] as Timestamp);
|
||||||
var _arrivalDate =
|
var _arrivalDate =
|
||||||
map['arrival_date'] == null ? null : (map['arrival_date'] as Timestamp);
|
map['arrival_date'] == null ? null : (map['arrival_date'] as Timestamp);
|
||||||
var _departureDate = map['departure_date'] == null
|
|
||||||
? null
|
|
||||||
: (map['departure_date'] as Timestamp);
|
|
||||||
|
|
||||||
return FcsShipment(
|
return FcsShipment(
|
||||||
id: docID,
|
id: docID,
|
||||||
cutoffDate: _cutoffDate != null ? _cutoffDate.toDate() : null,
|
cutoffDate: _cutoffDate != null ? _cutoffDate.toDate() : null,
|
||||||
arrivalDate: _arrivalDate != null ? _arrivalDate.toDate() : null,
|
arrivalDate: _arrivalDate != null ? _arrivalDate.toDate() : null,
|
||||||
departureDate: _departureDate != null ? _departureDate.toDate() : null,
|
|
||||||
shipmentNumber: map['shipment_number'],
|
shipmentNumber: map['shipment_number'],
|
||||||
shipType: map['shipment_type'],
|
shipType: map['shipment_type'],
|
||||||
|
shipmentTypeId: map['shipment_type_id'] ?? "",
|
||||||
status: map['status'],
|
status: map['status'],
|
||||||
consignee: map['consignee'],
|
consignee: map['consignee'],
|
||||||
port: map['port'],
|
port: map['port'],
|
||||||
@@ -62,8 +61,8 @@ class FcsShipment {
|
|||||||
'consignee': consignee,
|
'consignee': consignee,
|
||||||
'port': port,
|
'port': port,
|
||||||
'destination': destination,
|
'destination': destination,
|
||||||
'status': status,
|
// 'status': status,
|
||||||
'report_name': reportName,
|
// 'report_name': reportName,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +74,7 @@ class FcsShipment {
|
|||||||
return fcsShipment.shipmentNumber != this.shipmentNumber ||
|
return fcsShipment.shipmentNumber != this.shipmentNumber ||
|
||||||
fcsShipment.cutoffDate != this.cutoffDate ||
|
fcsShipment.cutoffDate != this.cutoffDate ||
|
||||||
fcsShipment.arrivalDate != this.arrivalDate ||
|
fcsShipment.arrivalDate != this.arrivalDate ||
|
||||||
fcsShipment.shipType != this.shipType ||
|
fcsShipment.shipmentTypeId != this.shipmentTypeId ||
|
||||||
fcsShipment.consignee != this.consignee ||
|
fcsShipment.consignee != this.consignee ||
|
||||||
fcsShipment.port != this.port ||
|
fcsShipment.port != this.port ||
|
||||||
fcsShipment.destination != this.destination;
|
fcsShipment.destination != this.destination;
|
||||||
|
|||||||
10
lib/domain/entities/shipment_type.dart
Normal file
10
lib/domain/entities/shipment_type.dart
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
class ShipmentType {
|
||||||
|
String id;
|
||||||
|
String desc;
|
||||||
|
|
||||||
|
ShipmentType({required this.id, required this.desc});
|
||||||
|
|
||||||
|
factory ShipmentType.fromMap(Map<String, dynamic> map, String id) {
|
||||||
|
return ShipmentType(id: id, desc: map['desc'] ?? "");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ import 'package:intl/intl.dart';
|
|||||||
import '../constants.dart';
|
import '../constants.dart';
|
||||||
|
|
||||||
DateFormat dayFormat = DateFormat("MMM dd yyyy");
|
DateFormat dayFormat = DateFormat("MMM dd yyyy");
|
||||||
DateFormat timeFormat = DateFormat("HH:mm");
|
DateFormat timeFormat = DateFormat("hh:mm a");
|
||||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||||
|
|
||||||
class User {
|
class User {
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ Future<dynamic> requestAPI(String path, method,
|
|||||||
headers: headers,
|
headers: headers,
|
||||||
);
|
);
|
||||||
log.info("baseUrl:${options.baseUrl}, path:$path");
|
log.info("baseUrl:${options.baseUrl}, path:$path");
|
||||||
|
log.info("payload:$payload");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Dio dio = new Dio(options);
|
Dio dio = new Dio(options);
|
||||||
Response response = await dio.request(
|
Response response = await dio.request(
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ class _CustomerListState extends State<CustomerList> {
|
|||||||
),
|
),
|
||||||
customer.status == user_invited_status
|
customer.status == user_invited_status
|
||||||
? Padding(
|
? Padding(
|
||||||
padding: const EdgeInsets.only(right: 10.0),
|
padding: const EdgeInsets.only(right: 10),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 30,
|
height: 30,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
@@ -182,14 +182,14 @@ class _CustomerListState extends State<CustomerList> {
|
|||||||
decoration:
|
decoration:
|
||||||
BoxDecoration(shape: BoxShape.circle, color: secondaryColor),
|
BoxDecoration(shape: BoxShape.circle, color: secondaryColor),
|
||||||
child: Text(customer.getFcsUnseenCount,
|
child: Text(customer.getFcsUnseenCount,
|
||||||
style: TextStyle(color: Colors.white)),
|
style: TextStyle(color: Colors.white, fontSize: 12)),
|
||||||
)
|
)
|
||||||
: Container();
|
: Container();
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _status(String status) {
|
Widget _status(String status) {
|
||||||
return user_requested_status == status || user_disabled_status == status
|
return user_requested_status == status || user_disabled_status == status
|
||||||
? Text(status, style: TextStyle(color: primaryColor, fontSize: 14))
|
? Text(status, style: TextStyle(color: primaryColor, fontSize: 12))
|
||||||
: Container();
|
: Container();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,11 +60,13 @@ class DiscountListRow extends StatelessWidget {
|
|||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(discount.status ?? ''),
|
Text(discount.status ?? '',
|
||||||
|
style: TextStyle(
|
||||||
|
color: primaryColor,
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold)),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(top: 5),
|
||||||
top: 5,
|
|
||||||
),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Text(
|
new Text(
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'package:fcs/helpers/theme.dart';
|
|||||||
import 'package:fcs/localization/app_translations.dart';
|
import 'package:fcs/localization/app_translations.dart';
|
||||||
import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart';
|
import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart';
|
||||||
import 'package:fcs/pages/main/model/language_model.dart';
|
import 'package:fcs/pages/main/model/language_model.dart';
|
||||||
import 'package:fcs/pages/main/model/main_model.dart';
|
|
||||||
import 'package:fcs/pages/widgets/input_date.dart';
|
import 'package:fcs/pages/widgets/input_date.dart';
|
||||||
import 'package:fcs/pages/widgets/input_text.dart';
|
import 'package:fcs/pages/widgets/input_text.dart';
|
||||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||||
@@ -15,6 +14,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../../domain/entities/shipment_type.dart';
|
||||||
import '../main/util.dart';
|
import '../main/util.dart';
|
||||||
|
|
||||||
class FcsShipmentEditor extends StatefulWidget {
|
class FcsShipmentEditor extends StatefulWidget {
|
||||||
@@ -39,13 +39,14 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
|||||||
|
|
||||||
FcsShipment _shipment = new FcsShipment();
|
FcsShipment _shipment = new FcsShipment();
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
String? _currentShipmentType;
|
ShipmentType? _currentShipmentType;
|
||||||
bool _isNew = false;
|
bool _isNew = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_isNew = widget.shipment == null;
|
_isNew = widget.shipment == null;
|
||||||
|
var model = Provider.of<FcsShipmentModel>(context, listen: false);
|
||||||
if (widget.shipment != null) {
|
if (widget.shipment != null) {
|
||||||
_shipment = widget.shipment!;
|
_shipment = widget.shipment!;
|
||||||
_shipmentNumberController.text = _shipment.shipmentNumber ?? "";
|
_shipmentNumberController.text = _shipment.shipmentNumber ?? "";
|
||||||
@@ -59,13 +60,13 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
|||||||
_departureDateControler.text =
|
_departureDateControler.text =
|
||||||
dateFormatter.format(_shipment.departureDate!);
|
dateFormatter.format(_shipment.departureDate!);
|
||||||
_statusController.text = _shipment.status ?? "";
|
_statusController.text = _shipment.status ?? "";
|
||||||
_currentShipmentType = _shipment.shipType;
|
|
||||||
_consigneeController.text = _shipment.consignee ?? "";
|
_consigneeController.text = _shipment.consignee ?? "";
|
||||||
_portController.text = _shipment.port ?? "";
|
_portController.text = _shipment.port ?? "";
|
||||||
_destinationController.text = _shipment.destination ?? "";
|
_destinationController.text = _shipment.destination ?? "";
|
||||||
|
|
||||||
|
// _currentShipmentType = model.shipmentTypes.where((e) => e.id == _shipment.shipmentTypeId).first;
|
||||||
} else {
|
} else {
|
||||||
var mainModel = Provider.of<MainModel>(context, listen: false);
|
_currentShipmentType = model.shipmentTypes[0];
|
||||||
_currentShipmentType = mainModel.setting!.shipmentTypes[0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +78,8 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var languageModel = Provider.of<LanguageModel>(context);
|
var languageModel = Provider.of<LanguageModel>(context);
|
||||||
var mainModel = Provider.of<MainModel>(context);
|
List<ShipmentType> shipmentTypes =
|
||||||
|
context.watch<FcsShipmentModel>().shipmentTypes;
|
||||||
|
|
||||||
final createBtn = Padding(
|
final createBtn = Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 30),
|
padding: const EdgeInsets.symmetric(horizontal: 30),
|
||||||
@@ -171,10 +173,11 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
|||||||
labelText: AppTranslations.of(context)!
|
labelText: AppTranslations.of(context)!
|
||||||
.text('FCSshipment.shipment_type'),
|
.text('FCSshipment.shipment_type'),
|
||||||
icon: Icon(Ionicons.ios_airplane, color: primaryColor)),
|
icon: Icon(Ionicons.ios_airplane, color: primaryColor)),
|
||||||
items: mainModel.setting!.shipmentTypes
|
items: shipmentTypes
|
||||||
.map((e) => DropdownMenuItem(child: Text(e), value: e))
|
.map((e) =>
|
||||||
|
DropdownMenuItem(child: Text(e.desc), value: e))
|
||||||
.toList(),
|
.toList(),
|
||||||
onChanged: (String? selected) => {
|
onChanged: (selected) => {
|
||||||
setState(() {
|
setState(() {
|
||||||
_currentShipmentType = selected;
|
_currentShipmentType = selected;
|
||||||
})
|
})
|
||||||
@@ -206,7 +209,7 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
|||||||
FcsShipment fcsShipment = FcsShipment();
|
FcsShipment fcsShipment = FcsShipment();
|
||||||
fcsShipment.id = _shipment.id;
|
fcsShipment.id = _shipment.id;
|
||||||
fcsShipment.shipmentNumber = _shipmentNumberController.text;
|
fcsShipment.shipmentNumber = _shipmentNumberController.text;
|
||||||
fcsShipment.shipType = _currentShipmentType!;
|
fcsShipment.shipmentTypeId = _currentShipmentType?.id;
|
||||||
fcsShipment.consignee = _consigneeController.text;
|
fcsShipment.consignee = _consigneeController.text;
|
||||||
fcsShipment.port = _portController.text;
|
fcsShipment.port = _portController.text;
|
||||||
fcsShipment.destination = _destinationController.text;
|
fcsShipment.destination = _destinationController.text;
|
||||||
@@ -262,14 +265,14 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
|||||||
|
|
||||||
isDataChanged() {
|
isDataChanged() {
|
||||||
if (_isNew) {
|
if (_isNew) {
|
||||||
var mainModel = Provider.of<MainModel>(context, listen: false);
|
var shipmentModel = Provider.of<FcsShipmentModel>(context, listen: false);
|
||||||
return _shipmentNumberController.text != "" ||
|
return _shipmentNumberController.text != "" ||
|
||||||
_cutoffDateController.text != "" ||
|
_cutoffDateController.text != "" ||
|
||||||
_arrivalDateController.text != "" ||
|
_arrivalDateController.text != "" ||
|
||||||
_consigneeController.text != "" ||
|
_consigneeController.text != "" ||
|
||||||
_portController.text != "" ||
|
_portController.text != "" ||
|
||||||
_destinationController.text != "" ||
|
_destinationController.text != "" ||
|
||||||
_currentShipmentType != mainModel.setting!.shipmentTypes[0];
|
_currentShipmentType != shipmentModel.shipmentTypes[0];
|
||||||
} else {
|
} else {
|
||||||
FcsShipment fcsShipment = _getPayload();
|
FcsShipment fcsShipment = _getPayload();
|
||||||
return widget.shipment!.isChangedForEdit(fcsShipment);
|
return widget.shipment!.isChangedForEdit(fcsShipment);
|
||||||
|
|||||||
@@ -159,7 +159,9 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
|||||||
color: dangerColor,
|
color: dangerColor,
|
||||||
textKey: "FCSshipment.cancel.btn",
|
textKey: "FCSshipment.cancel.btn",
|
||||||
callBack: () {
|
callBack: () {
|
||||||
showConfirmDialog(context, "FCSshipment.cancel.confirm", () {});
|
showConfirmDialog(context, "FCSshipment.cancel.confirm", () {
|
||||||
|
_cancelFcsShipment();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -174,10 +176,12 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
|||||||
labelColor: primaryColor,
|
labelColor: primaryColor,
|
||||||
arrowColor: primaryColor,
|
arrowColor: primaryColor,
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
_fcsShipment?.status == fcs_shipment_pending_status
|
||||||
|
? IconButton(
|
||||||
icon: Icon(Icons.edit, color: primaryColor),
|
icon: Icon(Icons.edit, color: primaryColor),
|
||||||
onPressed: _edit,
|
onPressed: _edit,
|
||||||
),
|
)
|
||||||
|
: const SizedBox(),
|
||||||
//menuPopWidget(context)
|
//menuPopWidget(context)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -377,6 +381,24 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_cancelFcsShipment() async {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
FcsShipmentModel fcsShipmentModel =
|
||||||
|
Provider.of<FcsShipmentModel>(context, listen: false);
|
||||||
|
await fcsShipmentModel.cancel(_fcsShipment!.id!);
|
||||||
|
Navigator.pop(context, true);
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_showPDF(int id) async {
|
_showPDF(int id) async {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:fcs/domain/entities/fcs_shipment.dart';
|
|||||||
import 'package:fcs/pages/main/model/base_model.dart';
|
import 'package:fcs/pages/main/model/base_model.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
|
|
||||||
|
import '../../../domain/entities/shipment_type.dart';
|
||||||
import '../../../pagination/paginator_listener.dart';
|
import '../../../pagination/paginator_listener.dart';
|
||||||
|
|
||||||
class FcsShipmentModel extends BaseModel {
|
class FcsShipmentModel extends BaseModel {
|
||||||
@@ -15,6 +16,9 @@ class FcsShipmentModel extends BaseModel {
|
|||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
int selectedIndex = 0;
|
int selectedIndex = 0;
|
||||||
|
|
||||||
|
List<ShipmentType> shipmentTypes = [];
|
||||||
|
StreamSubscription<QuerySnapshot>? _shipmentTypeListener;
|
||||||
|
|
||||||
onChanged(int index) {
|
onChanged(int index) {
|
||||||
selectedIndex = index;
|
selectedIndex = index;
|
||||||
loadFcsShipments(selectedIndex);
|
loadFcsShipments(selectedIndex);
|
||||||
@@ -132,11 +136,35 @@ class FcsShipmentModel extends BaseModel {
|
|||||||
|
|
||||||
void initUser(user) {
|
void initUser(user) {
|
||||||
super.initUser(user);
|
super.initUser(user);
|
||||||
|
_loadShipmentTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
logout() async {
|
logout() async {
|
||||||
fcsShipments?.close();
|
fcsShipments?.close();
|
||||||
|
_shipmentTypeListener?.cancel();
|
||||||
|
shipmentTypes.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadShipmentTypes() async {
|
||||||
|
try {
|
||||||
|
_shipmentTypeListener = FirebaseFirestore.instance
|
||||||
|
.collection(
|
||||||
|
"/$config_collection/$setting_doc_id/$shipment_type_collection")
|
||||||
|
.snapshots()
|
||||||
|
.listen((QuerySnapshot snapshot) {
|
||||||
|
shipmentTypes.clear();
|
||||||
|
shipmentTypes = snapshot.docs.map((documentSnapshot) {
|
||||||
|
var privilege = ShipmentType.fromMap(
|
||||||
|
documentSnapshot.data() as Map<String, dynamic>,
|
||||||
|
documentSnapshot.id);
|
||||||
|
return privilege;
|
||||||
|
}).toList();
|
||||||
|
notifyListeners();
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
log.warning("Error!! $e");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> create(FcsShipment fcsShipment) {
|
Future<void> create(FcsShipment fcsShipment) {
|
||||||
@@ -163,6 +191,10 @@ class FcsShipmentModel extends BaseModel {
|
|||||||
return Services.instance.fcsShipmentService.invoiceFcsShipment(id);
|
return Services.instance.fcsShipmentService.invoiceFcsShipment(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> cancel(String id) {
|
||||||
|
return Services.instance.fcsShipmentService.cancelFcsShipment(id);
|
||||||
|
}
|
||||||
|
|
||||||
Future<String> report(FcsShipment fcsShipment) {
|
Future<String> report(FcsShipment fcsShipment) {
|
||||||
return Services.instance.fcsShipmentService.report(fcsShipment);
|
return Services.instance.fcsShipmentService.report(fcsShipment);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,13 +82,13 @@ class StaffModel extends BaseModel {
|
|||||||
{required String userID,
|
{required String userID,
|
||||||
required bool enablePin,
|
required bool enablePin,
|
||||||
required int? pin}) async {
|
required int? pin}) async {
|
||||||
// await request("/employee/pin", "PUT",
|
await request("/employee/pin", "PUT",
|
||||||
// payload: {
|
payload: {
|
||||||
// "id": userID,
|
"id": userID,
|
||||||
// "enable_pin_login": enablePin,
|
"enable_pin_login": enablePin,
|
||||||
// "new_pin": pin
|
"pin": pin
|
||||||
// },
|
},
|
||||||
// token: await getToken());
|
token: await getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<User?> findUser(String phoneNumber) {
|
Future<User?> findUser(String phoneNumber) {
|
||||||
|
|||||||
Reference in New Issue
Block a user