fix saving and display of stocks
This commit is contained in:
parent
6c5e9f84d7
commit
e8d0f213e9
5 changed files with 255 additions and 138 deletions
27
lib/tables/prescriptions.dart
Normal file
27
lib/tables/prescriptions.dart
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class Prescriptions {
|
||||
final SupabaseClient _supabase = Supabase.instance.client;
|
||||
|
||||
Future<List> getPrescriptions(String uuid) async {
|
||||
try {
|
||||
final data = await _supabase.from('prescriptions').select('prescriptions_uuid').eq('user_id', uuid);
|
||||
return data.toList();
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> postPrescription(String userId, String medicineUuid) async {
|
||||
try {
|
||||
final prescriptionUUID = Uuid().v4();
|
||||
await _supabase
|
||||
.from('prescriptions')
|
||||
.insert({'prescriptions_uuid': prescriptionUUID, 'user_id': userId, 'ref_medicine_uuid': medicineUuid});
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue