8bbc9dbff2
- Flutter + PocketBase dental lab management system - Clinic & lab dashboards, job tracking, patient management - Product catalog, finance tracking, multi-language support - AI assistant integration, realtime notifications - Windows installer (Inno Setup) included - Developed by kovakyazilim.com
33 lines
860 B
Dart
33 lines
860 B
Dart
import 'package:pocketbase/pocketbase.dart';
|
|
import '../../core/api/pocketbase_client.dart';
|
|
import '../../core/auth/auth_repository.dart';
|
|
|
|
class OnboardingRepository {
|
|
OnboardingRepository._();
|
|
static final instance = OnboardingRepository._();
|
|
|
|
PocketBase get _pb => PocketBaseClient.instance.pb;
|
|
|
|
Future<AuthResult> createTenantAndJoin({
|
|
required String kind,
|
|
required String companyName,
|
|
}) async {
|
|
final userId = _pb.authStore.record!.id;
|
|
|
|
final tenant = await _pb.collection('tenants').create(body: {
|
|
'kind': kind,
|
|
'company_name': companyName,
|
|
'status': 'active',
|
|
'default_currency': 'TRY',
|
|
});
|
|
|
|
await _pb.collection('tenant_members').create(body: {
|
|
'tenant_id': tenant.id,
|
|
'user_id': userId,
|
|
'role': 'owner',
|
|
});
|
|
|
|
return AuthRepository.instance.refreshSession();
|
|
}
|
|
}
|