feat: make server owner of tabs
This commit is contained in:
@@ -11,6 +11,8 @@ import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
import '../database/app_database.dart';
|
||||
import '../database/stock_queries.dart';
|
||||
import '../models/tab_event.dart';
|
||||
|
||||
class DefaultProductSeeder {
|
||||
final AppDatabase database;
|
||||
@@ -46,6 +48,7 @@ class DefaultProductSeeder {
|
||||
|
||||
await database.transaction(() async {
|
||||
final uuid = const Uuid();
|
||||
final events = TabEventFactory();
|
||||
|
||||
for (final (name, priceInCents, stock, category) in _defaultProducts) {
|
||||
String? imagePath;
|
||||
@@ -54,11 +57,12 @@ class DefaultProductSeeder {
|
||||
imagePath = await _copyBundledImage(name, imagesDir);
|
||||
}
|
||||
|
||||
final id = uuid.v4();
|
||||
await database
|
||||
.into(database.products)
|
||||
.insert(
|
||||
ProductsCompanion.insert(
|
||||
id: uuid.v4(),
|
||||
id: id,
|
||||
name: name,
|
||||
category: category,
|
||||
stockQuantity: stock,
|
||||
@@ -67,6 +71,9 @@ class DefaultProductSeeder {
|
||||
imagePath: Value(imagePath),
|
||||
),
|
||||
);
|
||||
await database.queueStockSet(
|
||||
events.stockSet(productId: id, quantity: stock),
|
||||
);
|
||||
}
|
||||
});
|
||||
} catch (e, stack) {
|
||||
|
||||
Reference in New Issue
Block a user