refactor nomi tabelle
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
const String resetPasswordUrl =
|
||||
'https://flux-web-invite.marco-6ba.workers.dev/';
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||
import 'package:flux/core/enums_and_consts/consts.dart';
|
||||
import 'package:flux/features/company/models/company_model.dart';
|
||||
import 'package:flux/features/master_data/store/models/store_model.dart';
|
||||
import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
|
||||
@@ -15,7 +16,7 @@ class CoreRepository {
|
||||
Future<CompanyModel?> getCompanyByOwnerId(String userId) async {
|
||||
try {
|
||||
final response = await _supabase
|
||||
.from('company')
|
||||
.from(Tables.companies)
|
||||
.select()
|
||||
.eq('user_id', userId) // <-- Assicurati di avere questo campo nel DB!
|
||||
.maybeSingle();
|
||||
@@ -31,7 +32,7 @@ class CoreRepository {
|
||||
Future<CompanyModel?> getCompanyById(String companyId) async {
|
||||
try {
|
||||
final response = await _supabase
|
||||
.from('company')
|
||||
.from(Tables.companies)
|
||||
.select()
|
||||
.eq('id', companyId)
|
||||
.maybeSingle();
|
||||
@@ -46,7 +47,7 @@ class CoreRepository {
|
||||
Future<List<StoreModel>> getStoresByCompanyId(String companyId) async {
|
||||
try {
|
||||
final response = await _supabase
|
||||
.from('store')
|
||||
.from(Tables.stores)
|
||||
.select()
|
||||
.eq('company_id', companyId)
|
||||
.eq('is_active', true) // Buona pratica
|
||||
@@ -62,7 +63,7 @@ class CoreRepository {
|
||||
Future<StaffMemberModel?> getStaffMemberByUserId(String userId) async {
|
||||
try {
|
||||
final response = await _supabase
|
||||
.from('staff_member')
|
||||
.from(Tables.staffMembers)
|
||||
.select()
|
||||
.eq('user_id', userId)
|
||||
.maybeSingle();
|
||||
@@ -80,7 +81,7 @@ class CoreRepository {
|
||||
Future<CompanyModel> createCompany(CompanyModel company) async {
|
||||
try {
|
||||
final response = await _supabase
|
||||
.from('company')
|
||||
.from(Tables.companies)
|
||||
.insert(company.toMap())
|
||||
.select()
|
||||
.single();
|
||||
@@ -94,7 +95,7 @@ class CoreRepository {
|
||||
Future<StoreModel> createStore(StoreModel store) async {
|
||||
try {
|
||||
final response = await _supabase
|
||||
.from('store')
|
||||
.from(Tables.stores)
|
||||
.insert(store.toMap())
|
||||
.select()
|
||||
.single();
|
||||
@@ -108,12 +109,12 @@ class CoreRepository {
|
||||
Future<StaffMemberModel> createStaffMember(StaffMemberModel staff) async {
|
||||
try {
|
||||
final response = await _supabase
|
||||
.from('staff_member')
|
||||
.from(Tables.staffMembers)
|
||||
.insert(staff.toMap())
|
||||
.select()
|
||||
.single();
|
||||
final StaffMemberModel staffMember = StaffMemberModel.fromMap(response);
|
||||
await _supabase.from('staff_in_stores').insert({
|
||||
await _supabase.from(Tables.staffInStores).insert({
|
||||
'staff_member_id': staffMember.id,
|
||||
'store_id': GetIt.I.get<SessionCubit>().state.currentStore!.id,
|
||||
});
|
||||
@@ -126,7 +127,7 @@ class CoreRepository {
|
||||
|
||||
// Assegna un membro a un negozio
|
||||
Future<void> assignStaffToStore(String staffId, String storeId) async {
|
||||
await _supabase.from('staff_in_stores').insert({
|
||||
await _supabase.from(Tables.staffInStores).insert({
|
||||
'staff_member_id': staffId,
|
||||
'store_id': storeId,
|
||||
});
|
||||
@@ -136,6 +137,6 @@ class CoreRepository {
|
||||
String staffId,
|
||||
Map<String, dynamic> data,
|
||||
) async {
|
||||
await _supabase.from('staff_member').update(data).eq('id', staffId);
|
||||
await _supabase.from(Tables.staffMembers).update(data).eq('id', staffId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user