fix: formatting
This commit is contained in:
@@ -23,6 +23,7 @@ abstract class ProductService {
|
||||
Future<void> deleteProduct(String id);
|
||||
|
||||
Future<void> decreaseStock(String productId, int amount);
|
||||
|
||||
Future<void> increaseStock(String productId, int amount);
|
||||
}
|
||||
|
||||
@@ -30,9 +31,7 @@ class DriftProductService implements ProductService {
|
||||
final AppDatabase database;
|
||||
final _uuid = const Uuid();
|
||||
|
||||
DriftProductService({
|
||||
required this.database,
|
||||
});
|
||||
DriftProductService({required this.database});
|
||||
|
||||
Product _mapRowToProduct(ProductRow row) {
|
||||
return Product(
|
||||
@@ -51,9 +50,7 @@ class DriftProductService implements ProductService {
|
||||
Future<List<Product>> getProducts() async {
|
||||
final query = database.select(database.products)
|
||||
..where((product) => product.active.equals(true))
|
||||
..orderBy([
|
||||
(product) => OrderingTerm.asc(product.name),
|
||||
]);
|
||||
..orderBy([(product) => OrderingTerm.asc(product.name)]);
|
||||
|
||||
final rows = await query.get();
|
||||
|
||||
@@ -83,17 +80,19 @@ class DriftProductService implements ProductService {
|
||||
required int priceInCents,
|
||||
required String? imagePath,
|
||||
}) async {
|
||||
await database.into(database.products).insert(
|
||||
ProductsCompanion.insert(
|
||||
id: _uuid.v4(),
|
||||
name: name,
|
||||
category: category,
|
||||
stockQuantity: stockQuantity,
|
||||
lowStockThreshold: lowStockThreshold,
|
||||
priceInCents: priceInCents,
|
||||
imagePath: Value(imagePath),
|
||||
),
|
||||
);
|
||||
await database
|
||||
.into(database.products)
|
||||
.insert(
|
||||
ProductsCompanion.insert(
|
||||
id: _uuid.v4(),
|
||||
name: name,
|
||||
category: category,
|
||||
stockQuantity: stockQuantity,
|
||||
lowStockThreshold: lowStockThreshold,
|
||||
priceInCents: priceInCents,
|
||||
imagePath: Value(imagePath),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -135,9 +134,7 @@ class DriftProductService implements ProductService {
|
||||
}
|
||||
|
||||
await updateProduct(
|
||||
product.copyWith(
|
||||
stockQuantity: product.stockQuantity - amount,
|
||||
),
|
||||
product.copyWith(stockQuantity: product.stockQuantity - amount),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -150,10 +147,7 @@ class DriftProductService implements ProductService {
|
||||
}
|
||||
|
||||
await updateProduct(
|
||||
product.copyWith(
|
||||
stockQuantity: product.stockQuantity + amount,
|
||||
),
|
||||
product.copyWith(stockQuantity: product.stockQuantity + amount),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user