feat: outlet information page
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../domain/outlet/outlet.dart';
|
||||
import '../../auth/datasources/local_data_provider.dart';
|
||||
import '../datasource/remote_data_provider.dart';
|
||||
|
||||
@Injectable(as: IOutletRepository)
|
||||
class OutletRepository implements IOutletRepository {
|
||||
final OutletRemoteDataProvider _dataProvider;
|
||||
final AuthLocalDataProvider _authLocalDataProvider;
|
||||
final String _logName = 'OutletRepository';
|
||||
|
||||
OutletRepository(this._dataProvider, this._authLocalDataProvider);
|
||||
|
||||
@override
|
||||
Future<Either<OutletFailure, Outlet>> currentOutlet() async {
|
||||
try {
|
||||
final authData = await _authLocalDataProvider.currentUser();
|
||||
final result = await _dataProvider.fetchById(outletId: authData.outletId);
|
||||
|
||||
if (result.hasError) {
|
||||
return left(result.error!);
|
||||
}
|
||||
|
||||
final auth = result.data!.toDomain();
|
||||
|
||||
return right(auth);
|
||||
} catch (e, s) {
|
||||
log('currentOutletError', name: _logName, error: e, stackTrace: s);
|
||||
return left(const OutletFailure.unexpectedError());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user