Fitur foto produk: image_picker + upload Supabase Storage (bucket product-images), thumbnail di daftar produk

This commit is contained in:
onie
2026-10-17 23:47:13 +07:00
parent 0121eca8bb
commit 60abcc1f5c
11 changed files with 311 additions and 9 deletions

View File

@@ -502,7 +502,8 @@ class AppState extends ChangeNotifier {
/* ---------- Produk ---------- */
Future<String?> addProduct(String name, String barcode, double price,
double priceReseller, int stock, int minStock, double hargaPokok) async {
double priceReseller, int stock, int minStock, double hargaPokok,
{String? imagePath}) async {
try {
final trimmed = barcode.trim();
if (trimmed.isNotEmpty &&
@@ -518,6 +519,7 @@ class AppState extends ChangeNotifier {
stock: stock,
minStock: minStock,
hargaPokok: hargaPokok,
imagePath: imagePath,
);
await _withTimeout(
_supabase.from('products').insert(product.toJson()..['store_id'] = _currentStoreId),
@@ -534,7 +536,8 @@ class AppState extends ChangeNotifier {
}
Future<String?> updateProduct(String id, String name, String barcode,
double price, double priceReseller, int stock, int minStock, double hargaPokok) async {
double price, double priceReseller, int stock, int minStock, double hargaPokok,
{String? imagePath}) async {
try {
final trimmed = barcode.trim();
if (trimmed.isNotEmpty &&
@@ -551,6 +554,7 @@ class AppState extends ChangeNotifier {
'min_stock': minStock,
'harga_pokok': hargaPokok,
'store_id': _currentStoreId,
'image_path': imagePath,
}).eq('id', id),
'Update product',
);