feat: add setting for auto-lock fix: fix sideswipe
This commit is contained in:
@@ -17,6 +17,11 @@ abstract class BarTabService {
|
||||
|
||||
Future<BarTab> createTab({required String customerName});
|
||||
|
||||
Future<void> renameTab({required String tabId, required String customerName});
|
||||
|
||||
/// Deletes an open tab and returns its items to inventory.
|
||||
Future<List<TabItem>> deleteTab(String tabId);
|
||||
|
||||
Future<void> addProductToTab({
|
||||
required String tabId,
|
||||
required Product product,
|
||||
@@ -203,6 +208,61 @@ class DriftBarTabService implements BarTabService {
|
||||
return tab;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> renameTab({
|
||||
required String tabId,
|
||||
required String customerName,
|
||||
}) async {
|
||||
final name = customerName.trim();
|
||||
if (name.isEmpty) {
|
||||
throw ArgumentError.value(
|
||||
customerName,
|
||||
'customerName',
|
||||
'Must not be empty',
|
||||
);
|
||||
}
|
||||
|
||||
final updatedRows =
|
||||
await (database.update(database.barTabs)
|
||||
..where((tab) => tab.id.equals(tabId)))
|
||||
.write(BarTabsCompanion(customerName: Value(name)));
|
||||
|
||||
if (updatedRows != 1) {
|
||||
throw StateError('Tab not found.');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<TabItem>> deleteTab(String tabId) async {
|
||||
return database.transaction(() async {
|
||||
final tab = await (database.select(
|
||||
database.barTabs,
|
||||
)..where((row) => row.id.equals(tabId))).getSingleOrNull();
|
||||
|
||||
if (tab == null) return <TabItem>[];
|
||||
|
||||
final items = await _getItemsForTab(tabId);
|
||||
|
||||
for (final item in items) {
|
||||
await _increaseProductStock(item.productId, item.quantity);
|
||||
}
|
||||
|
||||
await (database.delete(
|
||||
database.tabItems,
|
||||
)..where((item) => item.tabId.equals(tabId))).go();
|
||||
|
||||
final deletedRows = await (database.delete(
|
||||
database.barTabs,
|
||||
)..where((row) => row.id.equals(tabId))).go();
|
||||
|
||||
if (deletedRows != 1) {
|
||||
throw StateError('Tab was changed before it could be deleted');
|
||||
}
|
||||
|
||||
return items;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> addProductToTab({
|
||||
required String tabId,
|
||||
|
||||
Reference in New Issue
Block a user