feat: get table

This commit is contained in:
efrilm
2025-08-03 23:53:06 +07:00
parent 8431b07057
commit 6afd62b617
14 changed files with 769 additions and 478 deletions
@@ -39,8 +39,8 @@ class _CardTableWidgetState extends State<CardTableWidget> {
loadData() async {
if (widget.table.status != 'available') {
data = await ProductLocalDatasource.instance
.getDraftOrderById(widget.table.orderId);
// data = await ProductLocalDatasource.instance
// .getDraftOrderById(widget.table.orderId);
}
}
@@ -70,9 +70,10 @@ class _CardTableWidgetState extends State<CardTableWidget> {
),
),
Text(
widget.table.status == 'available'
? widget.table.status
: "${widget.table.status} - ${DateTime.parse(widget.table.startTime).toFormattedTime()}",
// widget.table.status == 'available'
// ? widget.table.status
// : "${widget.table.status} - ${DateTime.parse(widget.table.startTime).toFormattedTime()}",
"",
style: TextStyle(
color: AppColors.black,
fontSize: 24,
@@ -51,8 +51,8 @@ class _TableWidgetState extends State<TableWidget> {
loadData() async {
if (widget.table.status != 'available') {
data = await ProductLocalDatasource.instance
.getDraftOrderById(widget.table.orderId);
// data = await ProductLocalDatasource.instance
// .getDraftOrderById(widget.table.orderId);
}
}
@@ -136,33 +136,33 @@ class _TableWidgetState extends State<TableWidget> {
Expanded(
child: Button.filled(
onPressed: () {
final newData =
TableModel(
id: widget.table.id,
tableName:
tableNameController!
.text,
status:
widget.table.status,
startTime: widget
.table.startTime,
orderId: widget
.table.orderId,
paymentAmount: widget
.table
.paymentAmount,
position: widget
.table.position,
);
context
.read<
UpdateTableBloc>()
.add(
UpdateTableEvent
.updateTable(
newData,
),
);
// final newData =
// TableModel(
// id: widget.table.id,
// tableName:
// tableNameController!
// .text,
// status:
// widget.table.status,
// startTime: widget
// .table.startTime,
// orderId: widget
// .table.orderId,
// paymentAmount: widget
// .table
// .paymentAmount,
// position: widget
// .table.position,
// );
// context
// .read<
// UpdateTableBloc>()
// .add(
// UpdateTableEvent
// .updateTable(
// newData,
// ),
// );
context
.pop(); // close dialog after adding
},
@@ -194,16 +194,16 @@ class _TableWidgetState extends State<TableWidget> {
color: widget.table.status == 'available'
? Colors.green
: Colors.red),
widget.table.status == 'available'
? SizedBox.shrink()
: _buildInfoRow(
'Start Time:',
DateFormatter.formatDateTime2(
widget.table.startTime)),
widget.table.status == 'available'
? SizedBox.shrink()
: _buildInfoRow(
'Order ID:', widget.table.orderId.toString()),
// widget.table.status == 'available'
// ? SizedBox.shrink()
// : _buildInfoRow(
// 'Start Time:',
// DateFormatter.formatDateTime2(
// widget.table.startTime)),
// widget.table.status == 'available'
// ? SizedBox.shrink()
// : _buildInfoRow(
// 'Order ID:', widget.table.orderId.toString()),
widget.table.status == 'available'
? SizedBox.shrink()
: SpaceHeight(16),
@@ -267,29 +267,29 @@ class _TableWidgetState extends State<TableWidget> {
backgroundColor: AppColors.red,
),
onPressed: () {
// Void the order
final newTable = TableModel(
id: widget.table.id,
tableName:
widget.table.tableName,
status: 'available',
orderId: 0,
paymentAmount: 0,
startTime: DateTime.now()
.toIso8601String(),
position: widget.table.position,
);
context
.read<StatusTableBloc>()
.add(
StatusTableEvent
.statusTabel(newTable),
);
// Remove draft order from local storage
ProductLocalDatasource.instance
.removeDraftOrderById(
widget.table.orderId);
log("Voided order for table: ${widget.table.tableName}");
// // Void the order
// final newTable = TableModel(
// id: widget.table.id,
// tableName:
// widget.table.tableName,
// status: 'available',
// orderId: 0,
// paymentAmount: 0,
// startTime: DateTime.now()
// .toIso8601String(),
// position: widget.table.position,
// );
// context
// .read<StatusTableBloc>()
// .add(
// StatusTableEvent
// .statusTabel(newTable),
// );
// // Remove draft order from local storage
// ProductLocalDatasource.instance
// .removeDraftOrderById(
// widget.table.orderId);
// log("Voided order for table: ${widget.table.tableName}");
},
child: const Text(
"Ya, Batalkan",