feat: update user

This commit is contained in:
efrilm 2025-08-19 15:05:08 +07:00
parent bfd4604897
commit 7919825955
37 changed files with 2531 additions and 897 deletions

View File

@ -1,9 +1,10 @@
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart'; import 'package:injectable/injectable.dart';
import '../../domain/auth/auth.dart'; import '../../domain/auth/auth.dart';
import '../../domain/user/user.dart';
part 'auth_event.dart'; part 'auth_event.dart';
part 'auth_state.dart'; part 'auth_state.dart';

View File

@ -0,0 +1,46 @@
import 'package:dartz/dartz.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/user/user.dart';
part 'user_edit_form_event.dart';
part 'user_edit_form_state.dart';
part 'user_edit_form_bloc.freezed.dart';
@injectable
class UserEditFormBloc extends Bloc<UserEditFormEvent, UserEditFormState> {
final IUserRepository _repository;
UserEditFormBloc(this._repository) : super(UserEditFormState.initial()) {
on<UserEditFormEvent>(_onUserEditFormEvent);
}
Future<void> _onUserEditFormEvent(
UserEditFormEvent event,
Emitter<UserEditFormState> emit,
) {
return event.map(
nameChanged: (e) async {
emit(state.copyWith(name: e.name));
},
submitted: (e) async {
Either<UserFailure, User>? failureOrUser;
emit(state.copyWith(isSubmitting: true, failureOrUserOption: none()));
final nameValid = state.name.isNotEmpty;
if (nameValid) {
failureOrUser = await _repository.editUser(name: state.name);
emit(
state.copyWith(
isSubmitting: false,
failureOrUserOption: optionOf(failureOrUser),
),
);
}
emit(state.copyWith(showErrorMessages: true, isSubmitting: false));
},
);
}
}

View File

@ -0,0 +1,542 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'user_edit_form_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
/// @nodoc
mixin _$UserEditFormEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String name) nameChanged,
required TResult Function() submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String name)? nameChanged,
TResult? Function()? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String name)? nameChanged,
TResult Function()? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NameChanged value) nameChanged,
required TResult Function(_Submitted value) submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NameChanged value)? nameChanged,
TResult? Function(_Submitted value)? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NameChanged value)? nameChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $UserEditFormEventCopyWith<$Res> {
factory $UserEditFormEventCopyWith(
UserEditFormEvent value,
$Res Function(UserEditFormEvent) then,
) = _$UserEditFormEventCopyWithImpl<$Res, UserEditFormEvent>;
}
/// @nodoc
class _$UserEditFormEventCopyWithImpl<$Res, $Val extends UserEditFormEvent>
implements $UserEditFormEventCopyWith<$Res> {
_$UserEditFormEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of UserEditFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$NameChangedImplCopyWith<$Res> {
factory _$$NameChangedImplCopyWith(
_$NameChangedImpl value,
$Res Function(_$NameChangedImpl) then,
) = __$$NameChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String name});
}
/// @nodoc
class __$$NameChangedImplCopyWithImpl<$Res>
extends _$UserEditFormEventCopyWithImpl<$Res, _$NameChangedImpl>
implements _$$NameChangedImplCopyWith<$Res> {
__$$NameChangedImplCopyWithImpl(
_$NameChangedImpl _value,
$Res Function(_$NameChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of UserEditFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? name = null}) {
return _then(
_$NameChangedImpl(
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$NameChangedImpl implements _NameChanged {
const _$NameChangedImpl(this.name);
@override
final String name;
@override
String toString() {
return 'UserEditFormEvent.nameChanged(name: $name)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$NameChangedImpl &&
(identical(other.name, name) || other.name == name));
}
@override
int get hashCode => Object.hash(runtimeType, name);
/// Create a copy of UserEditFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$NameChangedImplCopyWith<_$NameChangedImpl> get copyWith =>
__$$NameChangedImplCopyWithImpl<_$NameChangedImpl>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String name) nameChanged,
required TResult Function() submitted,
}) {
return nameChanged(name);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String name)? nameChanged,
TResult? Function()? submitted,
}) {
return nameChanged?.call(name);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String name)? nameChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (nameChanged != null) {
return nameChanged(name);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NameChanged value) nameChanged,
required TResult Function(_Submitted value) submitted,
}) {
return nameChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NameChanged value)? nameChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return nameChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NameChanged value)? nameChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (nameChanged != null) {
return nameChanged(this);
}
return orElse();
}
}
abstract class _NameChanged implements UserEditFormEvent {
const factory _NameChanged(final String name) = _$NameChangedImpl;
String get name;
/// Create a copy of UserEditFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$NameChangedImplCopyWith<_$NameChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$SubmittedImplCopyWith<$Res> {
factory _$$SubmittedImplCopyWith(
_$SubmittedImpl value,
$Res Function(_$SubmittedImpl) then,
) = __$$SubmittedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$SubmittedImplCopyWithImpl<$Res>
extends _$UserEditFormEventCopyWithImpl<$Res, _$SubmittedImpl>
implements _$$SubmittedImplCopyWith<$Res> {
__$$SubmittedImplCopyWithImpl(
_$SubmittedImpl _value,
$Res Function(_$SubmittedImpl) _then,
) : super(_value, _then);
/// Create a copy of UserEditFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$SubmittedImpl implements _Submitted {
const _$SubmittedImpl();
@override
String toString() {
return 'UserEditFormEvent.submitted()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$SubmittedImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String name) nameChanged,
required TResult Function() submitted,
}) {
return submitted();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String name)? nameChanged,
TResult? Function()? submitted,
}) {
return submitted?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String name)? nameChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NameChanged value) nameChanged,
required TResult Function(_Submitted value) submitted,
}) {
return submitted(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NameChanged value)? nameChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return submitted?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NameChanged value)? nameChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted(this);
}
return orElse();
}
}
abstract class _Submitted implements UserEditFormEvent {
const factory _Submitted() = _$SubmittedImpl;
}
/// @nodoc
mixin _$UserEditFormState {
String get name => throw _privateConstructorUsedError;
Option<Either<UserFailure, User>> get failureOrUserOption =>
throw _privateConstructorUsedError;
bool get isSubmitting => throw _privateConstructorUsedError;
bool get showErrorMessages => throw _privateConstructorUsedError;
/// Create a copy of UserEditFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$UserEditFormStateCopyWith<UserEditFormState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $UserEditFormStateCopyWith<$Res> {
factory $UserEditFormStateCopyWith(
UserEditFormState value,
$Res Function(UserEditFormState) then,
) = _$UserEditFormStateCopyWithImpl<$Res, UserEditFormState>;
@useResult
$Res call({
String name,
Option<Either<UserFailure, User>> failureOrUserOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class _$UserEditFormStateCopyWithImpl<$Res, $Val extends UserEditFormState>
implements $UserEditFormStateCopyWith<$Res> {
_$UserEditFormStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of UserEditFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? failureOrUserOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_value.copyWith(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
failureOrUserOption: null == failureOrUserOption
? _value.failureOrUserOption
: failureOrUserOption // ignore: cast_nullable_to_non_nullable
as Option<Either<UserFailure, User>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
showErrorMessages: null == showErrorMessages
? _value.showErrorMessages
: showErrorMessages // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$UserEditFormStateImplCopyWith<$Res>
implements $UserEditFormStateCopyWith<$Res> {
factory _$$UserEditFormStateImplCopyWith(
_$UserEditFormStateImpl value,
$Res Function(_$UserEditFormStateImpl) then,
) = __$$UserEditFormStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
String name,
Option<Either<UserFailure, User>> failureOrUserOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class __$$UserEditFormStateImplCopyWithImpl<$Res>
extends _$UserEditFormStateCopyWithImpl<$Res, _$UserEditFormStateImpl>
implements _$$UserEditFormStateImplCopyWith<$Res> {
__$$UserEditFormStateImplCopyWithImpl(
_$UserEditFormStateImpl _value,
$Res Function(_$UserEditFormStateImpl) _then,
) : super(_value, _then);
/// Create a copy of UserEditFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? failureOrUserOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_$UserEditFormStateImpl(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
failureOrUserOption: null == failureOrUserOption
? _value.failureOrUserOption
: failureOrUserOption // ignore: cast_nullable_to_non_nullable
as Option<Either<UserFailure, User>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
showErrorMessages: null == showErrorMessages
? _value.showErrorMessages
: showErrorMessages // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$UserEditFormStateImpl implements _UserEditFormState {
const _$UserEditFormStateImpl({
required this.name,
required this.failureOrUserOption,
this.isSubmitting = false,
this.showErrorMessages = false,
});
@override
final String name;
@override
final Option<Either<UserFailure, User>> failureOrUserOption;
@override
@JsonKey()
final bool isSubmitting;
@override
@JsonKey()
final bool showErrorMessages;
@override
String toString() {
return 'UserEditFormState(name: $name, failureOrUserOption: $failureOrUserOption, isSubmitting: $isSubmitting, showErrorMessages: $showErrorMessages)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$UserEditFormStateImpl &&
(identical(other.name, name) || other.name == name) &&
(identical(other.failureOrUserOption, failureOrUserOption) ||
other.failureOrUserOption == failureOrUserOption) &&
(identical(other.isSubmitting, isSubmitting) ||
other.isSubmitting == isSubmitting) &&
(identical(other.showErrorMessages, showErrorMessages) ||
other.showErrorMessages == showErrorMessages));
}
@override
int get hashCode => Object.hash(
runtimeType,
name,
failureOrUserOption,
isSubmitting,
showErrorMessages,
);
/// Create a copy of UserEditFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$UserEditFormStateImplCopyWith<_$UserEditFormStateImpl> get copyWith =>
__$$UserEditFormStateImplCopyWithImpl<_$UserEditFormStateImpl>(
this,
_$identity,
);
}
abstract class _UserEditFormState implements UserEditFormState {
const factory _UserEditFormState({
required final String name,
required final Option<Either<UserFailure, User>> failureOrUserOption,
final bool isSubmitting,
final bool showErrorMessages,
}) = _$UserEditFormStateImpl;
@override
String get name;
@override
Option<Either<UserFailure, User>> get failureOrUserOption;
@override
bool get isSubmitting;
@override
bool get showErrorMessages;
/// Create a copy of UserEditFormState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$UserEditFormStateImplCopyWith<_$UserEditFormStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -0,0 +1,7 @@
part of 'user_edit_form_bloc.dart';
@freezed
class UserEditFormEvent with _$UserEditFormEvent {
const factory UserEditFormEvent.nameChanged(String name) = _NameChanged;
const factory UserEditFormEvent.submitted() = _Submitted;
}

View File

@ -0,0 +1,14 @@
part of 'user_edit_form_bloc.dart';
@freezed
class UserEditFormState with _$UserEditFormState {
const factory UserEditFormState({
required String name,
required Option<Either<UserFailure, User>> failureOrUserOption,
@Default(false) bool isSubmitting,
@Default(false) bool showErrorMessages,
}) = _UserEditFormState;
factory UserEditFormState.initial() =>
UserEditFormState(name: '', failureOrUserOption: none());
}

View File

@ -30,4 +30,7 @@ class ApiPath {
// Outlet // Outlet
static const String outlet = '/api/v1/outlets'; static const String outlet = '/api/v1/outlets';
// User
static const String user = '/api/v1/users';
} }

View File

@ -2,10 +2,10 @@ import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
import '../../common/api/api_failure.dart'; import '../../common/api/api_failure.dart';
import '../user/user.dart';
part 'failures/auth_failure.dart'; part 'failures/auth_failure.dart';
part 'repositories/i_auth_repository.dart'; part 'repositories/i_auth_repository.dart';
part 'entities/auth_entity.dart'; part 'entities/auth_entity.dart';
part 'entities/user_entity.dart';
part 'auth.freezed.dart'; part 'auth.freezed.dart';

View File

@ -691,349 +691,3 @@ abstract class _Auth extends Auth {
_$$AuthImplCopyWith<_$AuthImpl> get copyWith => _$$AuthImplCopyWith<_$AuthImpl> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
/// @nodoc
mixin _$User {
String get id => throw _privateConstructorUsedError;
String get organizationId => throw _privateConstructorUsedError;
String get outletId => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
String get email => throw _privateConstructorUsedError;
String get role => throw _privateConstructorUsedError;
Map<String, dynamic> get permissions => throw _privateConstructorUsedError;
bool get isActive => throw _privateConstructorUsedError;
DateTime get createdAt => throw _privateConstructorUsedError;
DateTime get updatedAt => throw _privateConstructorUsedError;
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$UserCopyWith<User> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $UserCopyWith<$Res> {
factory $UserCopyWith(User value, $Res Function(User) then) =
_$UserCopyWithImpl<$Res, User>;
@useResult
$Res call({
String id,
String organizationId,
String outletId,
String name,
String email,
String role,
Map<String, dynamic> permissions,
bool isActive,
DateTime createdAt,
DateTime updatedAt,
});
}
/// @nodoc
class _$UserCopyWithImpl<$Res, $Val extends User>
implements $UserCopyWith<$Res> {
_$UserCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? organizationId = null,
Object? outletId = null,
Object? name = null,
Object? email = null,
Object? role = null,
Object? permissions = null,
Object? isActive = null,
Object? createdAt = null,
Object? updatedAt = null,
}) {
return _then(
_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
organizationId: null == organizationId
? _value.organizationId
: organizationId // ignore: cast_nullable_to_non_nullable
as String,
outletId: null == outletId
? _value.outletId
: outletId // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
email: null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
role: null == role
? _value.role
: role // ignore: cast_nullable_to_non_nullable
as String,
permissions: null == permissions
? _value.permissions
: permissions // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,
isActive: null == isActive
? _value.isActive
: isActive // ignore: cast_nullable_to_non_nullable
as bool,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
updatedAt: null == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$UserImplCopyWith<$Res> implements $UserCopyWith<$Res> {
factory _$$UserImplCopyWith(
_$UserImpl value,
$Res Function(_$UserImpl) then,
) = __$$UserImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
String id,
String organizationId,
String outletId,
String name,
String email,
String role,
Map<String, dynamic> permissions,
bool isActive,
DateTime createdAt,
DateTime updatedAt,
});
}
/// @nodoc
class __$$UserImplCopyWithImpl<$Res>
extends _$UserCopyWithImpl<$Res, _$UserImpl>
implements _$$UserImplCopyWith<$Res> {
__$$UserImplCopyWithImpl(_$UserImpl _value, $Res Function(_$UserImpl) _then)
: super(_value, _then);
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? organizationId = null,
Object? outletId = null,
Object? name = null,
Object? email = null,
Object? role = null,
Object? permissions = null,
Object? isActive = null,
Object? createdAt = null,
Object? updatedAt = null,
}) {
return _then(
_$UserImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
organizationId: null == organizationId
? _value.organizationId
: organizationId // ignore: cast_nullable_to_non_nullable
as String,
outletId: null == outletId
? _value.outletId
: outletId // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
email: null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
role: null == role
? _value.role
: role // ignore: cast_nullable_to_non_nullable
as String,
permissions: null == permissions
? _value._permissions
: permissions // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,
isActive: null == isActive
? _value.isActive
: isActive // ignore: cast_nullable_to_non_nullable
as bool,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
updatedAt: null == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime,
),
);
}
}
/// @nodoc
class _$UserImpl extends _User {
const _$UserImpl({
required this.id,
required this.organizationId,
required this.outletId,
required this.name,
required this.email,
required this.role,
required final Map<String, dynamic> permissions,
required this.isActive,
required this.createdAt,
required this.updatedAt,
}) : _permissions = permissions,
super._();
@override
final String id;
@override
final String organizationId;
@override
final String outletId;
@override
final String name;
@override
final String email;
@override
final String role;
final Map<String, dynamic> _permissions;
@override
Map<String, dynamic> get permissions {
if (_permissions is EqualUnmodifiableMapView) return _permissions;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(_permissions);
}
@override
final bool isActive;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
@override
String toString() {
return 'User(id: $id, organizationId: $organizationId, outletId: $outletId, name: $name, email: $email, role: $role, permissions: $permissions, isActive: $isActive, createdAt: $createdAt, updatedAt: $updatedAt)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$UserImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.organizationId, organizationId) ||
other.organizationId == organizationId) &&
(identical(other.outletId, outletId) ||
other.outletId == outletId) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.email, email) || other.email == email) &&
(identical(other.role, role) || other.role == role) &&
const DeepCollectionEquality().equals(
other._permissions,
_permissions,
) &&
(identical(other.isActive, isActive) ||
other.isActive == isActive) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt));
}
@override
int get hashCode => Object.hash(
runtimeType,
id,
organizationId,
outletId,
name,
email,
role,
const DeepCollectionEquality().hash(_permissions),
isActive,
createdAt,
updatedAt,
);
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$UserImplCopyWith<_$UserImpl> get copyWith =>
__$$UserImplCopyWithImpl<_$UserImpl>(this, _$identity);
}
abstract class _User extends User {
const factory _User({
required final String id,
required final String organizationId,
required final String outletId,
required final String name,
required final String email,
required final String role,
required final Map<String, dynamic> permissions,
required final bool isActive,
required final DateTime createdAt,
required final DateTime updatedAt,
}) = _$UserImpl;
const _User._() : super._();
@override
String get id;
@override
String get organizationId;
@override
String get outletId;
@override
String get name;
@override
String get email;
@override
String get role;
@override
Map<String, dynamic> get permissions;
@override
bool get isActive;
@override
DateTime get createdAt;
@override
DateTime get updatedAt;
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$UserImplCopyWith<_$UserImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,4 +1,4 @@
part of '../auth.dart'; part of '../user.dart';
@freezed @freezed
class User with _$User { class User with _$User {

View File

@ -0,0 +1,10 @@
part of '../user.dart';
@freezed
sealed class UserFailure with _$UserFailure {
const factory UserFailure.serverError(ApiFailure failure) = _ServerError;
const factory UserFailure.unexpectedError() = _UnexpectedError;
const factory UserFailure.empty() = _Empty;
const factory UserFailure.dynamicErrorMessage(String erroMessage) =
_DynamicErrorMessage;
}

View File

@ -0,0 +1,5 @@
part of '../user.dart';
abstract class IUserRepository {
Future<Either<UserFailure, User>> editUser({required String name});
}

10
lib/domain/user/user.dart Normal file
View File

@ -0,0 +1,10 @@
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../../common/api/api_failure.dart';
part 'user.freezed.dart';
part 'entities/user_entity.dart';
part 'failures/user_failure.dart';
part 'repositories/i_user_repository.dart';

View File

@ -0,0 +1,995 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'user.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
/// @nodoc
mixin _$User {
String get id => throw _privateConstructorUsedError;
String get organizationId => throw _privateConstructorUsedError;
String get outletId => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
String get email => throw _privateConstructorUsedError;
String get role => throw _privateConstructorUsedError;
Map<String, dynamic> get permissions => throw _privateConstructorUsedError;
bool get isActive => throw _privateConstructorUsedError;
DateTime get createdAt => throw _privateConstructorUsedError;
DateTime get updatedAt => throw _privateConstructorUsedError;
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$UserCopyWith<User> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $UserCopyWith<$Res> {
factory $UserCopyWith(User value, $Res Function(User) then) =
_$UserCopyWithImpl<$Res, User>;
@useResult
$Res call({
String id,
String organizationId,
String outletId,
String name,
String email,
String role,
Map<String, dynamic> permissions,
bool isActive,
DateTime createdAt,
DateTime updatedAt,
});
}
/// @nodoc
class _$UserCopyWithImpl<$Res, $Val extends User>
implements $UserCopyWith<$Res> {
_$UserCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? organizationId = null,
Object? outletId = null,
Object? name = null,
Object? email = null,
Object? role = null,
Object? permissions = null,
Object? isActive = null,
Object? createdAt = null,
Object? updatedAt = null,
}) {
return _then(
_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
organizationId: null == organizationId
? _value.organizationId
: organizationId // ignore: cast_nullable_to_non_nullable
as String,
outletId: null == outletId
? _value.outletId
: outletId // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
email: null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
role: null == role
? _value.role
: role // ignore: cast_nullable_to_non_nullable
as String,
permissions: null == permissions
? _value.permissions
: permissions // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,
isActive: null == isActive
? _value.isActive
: isActive // ignore: cast_nullable_to_non_nullable
as bool,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
updatedAt: null == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$UserImplCopyWith<$Res> implements $UserCopyWith<$Res> {
factory _$$UserImplCopyWith(
_$UserImpl value,
$Res Function(_$UserImpl) then,
) = __$$UserImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
String id,
String organizationId,
String outletId,
String name,
String email,
String role,
Map<String, dynamic> permissions,
bool isActive,
DateTime createdAt,
DateTime updatedAt,
});
}
/// @nodoc
class __$$UserImplCopyWithImpl<$Res>
extends _$UserCopyWithImpl<$Res, _$UserImpl>
implements _$$UserImplCopyWith<$Res> {
__$$UserImplCopyWithImpl(_$UserImpl _value, $Res Function(_$UserImpl) _then)
: super(_value, _then);
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? organizationId = null,
Object? outletId = null,
Object? name = null,
Object? email = null,
Object? role = null,
Object? permissions = null,
Object? isActive = null,
Object? createdAt = null,
Object? updatedAt = null,
}) {
return _then(
_$UserImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
organizationId: null == organizationId
? _value.organizationId
: organizationId // ignore: cast_nullable_to_non_nullable
as String,
outletId: null == outletId
? _value.outletId
: outletId // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
email: null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
role: null == role
? _value.role
: role // ignore: cast_nullable_to_non_nullable
as String,
permissions: null == permissions
? _value._permissions
: permissions // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,
isActive: null == isActive
? _value.isActive
: isActive // ignore: cast_nullable_to_non_nullable
as bool,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
updatedAt: null == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime,
),
);
}
}
/// @nodoc
class _$UserImpl extends _User {
const _$UserImpl({
required this.id,
required this.organizationId,
required this.outletId,
required this.name,
required this.email,
required this.role,
required final Map<String, dynamic> permissions,
required this.isActive,
required this.createdAt,
required this.updatedAt,
}) : _permissions = permissions,
super._();
@override
final String id;
@override
final String organizationId;
@override
final String outletId;
@override
final String name;
@override
final String email;
@override
final String role;
final Map<String, dynamic> _permissions;
@override
Map<String, dynamic> get permissions {
if (_permissions is EqualUnmodifiableMapView) return _permissions;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(_permissions);
}
@override
final bool isActive;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
@override
String toString() {
return 'User(id: $id, organizationId: $organizationId, outletId: $outletId, name: $name, email: $email, role: $role, permissions: $permissions, isActive: $isActive, createdAt: $createdAt, updatedAt: $updatedAt)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$UserImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.organizationId, organizationId) ||
other.organizationId == organizationId) &&
(identical(other.outletId, outletId) ||
other.outletId == outletId) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.email, email) || other.email == email) &&
(identical(other.role, role) || other.role == role) &&
const DeepCollectionEquality().equals(
other._permissions,
_permissions,
) &&
(identical(other.isActive, isActive) ||
other.isActive == isActive) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt));
}
@override
int get hashCode => Object.hash(
runtimeType,
id,
organizationId,
outletId,
name,
email,
role,
const DeepCollectionEquality().hash(_permissions),
isActive,
createdAt,
updatedAt,
);
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$UserImplCopyWith<_$UserImpl> get copyWith =>
__$$UserImplCopyWithImpl<_$UserImpl>(this, _$identity);
}
abstract class _User extends User {
const factory _User({
required final String id,
required final String organizationId,
required final String outletId,
required final String name,
required final String email,
required final String role,
required final Map<String, dynamic> permissions,
required final bool isActive,
required final DateTime createdAt,
required final DateTime updatedAt,
}) = _$UserImpl;
const _User._() : super._();
@override
String get id;
@override
String get organizationId;
@override
String get outletId;
@override
String get name;
@override
String get email;
@override
String get role;
@override
Map<String, dynamic> get permissions;
@override
bool get isActive;
@override
DateTime get createdAt;
@override
DateTime get updatedAt;
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$UserImplCopyWith<_$UserImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$UserFailure {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(ApiFailure failure) serverError,
required TResult Function() unexpectedError,
required TResult Function() empty,
required TResult Function(String erroMessage) dynamicErrorMessage,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(ApiFailure failure)? serverError,
TResult? Function()? unexpectedError,
TResult? Function()? empty,
TResult? Function(String erroMessage)? dynamicErrorMessage,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(ApiFailure failure)? serverError,
TResult Function()? unexpectedError,
TResult Function()? empty,
TResult Function(String erroMessage)? dynamicErrorMessage,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_ServerError value) serverError,
required TResult Function(_UnexpectedError value) unexpectedError,
required TResult Function(_Empty value) empty,
required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_ServerError value)? serverError,
TResult? Function(_UnexpectedError value)? unexpectedError,
TResult? Function(_Empty value)? empty,
TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_ServerError value)? serverError,
TResult Function(_UnexpectedError value)? unexpectedError,
TResult Function(_Empty value)? empty,
TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $UserFailureCopyWith<$Res> {
factory $UserFailureCopyWith(
UserFailure value,
$Res Function(UserFailure) then,
) = _$UserFailureCopyWithImpl<$Res, UserFailure>;
}
/// @nodoc
class _$UserFailureCopyWithImpl<$Res, $Val extends UserFailure>
implements $UserFailureCopyWith<$Res> {
_$UserFailureCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of UserFailure
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$ServerErrorImplCopyWith<$Res> {
factory _$$ServerErrorImplCopyWith(
_$ServerErrorImpl value,
$Res Function(_$ServerErrorImpl) then,
) = __$$ServerErrorImplCopyWithImpl<$Res>;
@useResult
$Res call({ApiFailure failure});
$ApiFailureCopyWith<$Res> get failure;
}
/// @nodoc
class __$$ServerErrorImplCopyWithImpl<$Res>
extends _$UserFailureCopyWithImpl<$Res, _$ServerErrorImpl>
implements _$$ServerErrorImplCopyWith<$Res> {
__$$ServerErrorImplCopyWithImpl(
_$ServerErrorImpl _value,
$Res Function(_$ServerErrorImpl) _then,
) : super(_value, _then);
/// Create a copy of UserFailure
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? failure = null}) {
return _then(
_$ServerErrorImpl(
null == failure
? _value.failure
: failure // ignore: cast_nullable_to_non_nullable
as ApiFailure,
),
);
}
/// Create a copy of UserFailure
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$ApiFailureCopyWith<$Res> get failure {
return $ApiFailureCopyWith<$Res>(_value.failure, (value) {
return _then(_value.copyWith(failure: value));
});
}
}
/// @nodoc
class _$ServerErrorImpl implements _ServerError {
const _$ServerErrorImpl(this.failure);
@override
final ApiFailure failure;
@override
String toString() {
return 'UserFailure.serverError(failure: $failure)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ServerErrorImpl &&
(identical(other.failure, failure) || other.failure == failure));
}
@override
int get hashCode => Object.hash(runtimeType, failure);
/// Create a copy of UserFailure
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith =>
__$$ServerErrorImplCopyWithImpl<_$ServerErrorImpl>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(ApiFailure failure) serverError,
required TResult Function() unexpectedError,
required TResult Function() empty,
required TResult Function(String erroMessage) dynamicErrorMessage,
}) {
return serverError(failure);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(ApiFailure failure)? serverError,
TResult? Function()? unexpectedError,
TResult? Function()? empty,
TResult? Function(String erroMessage)? dynamicErrorMessage,
}) {
return serverError?.call(failure);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(ApiFailure failure)? serverError,
TResult Function()? unexpectedError,
TResult Function()? empty,
TResult Function(String erroMessage)? dynamicErrorMessage,
required TResult orElse(),
}) {
if (serverError != null) {
return serverError(failure);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_ServerError value) serverError,
required TResult Function(_UnexpectedError value) unexpectedError,
required TResult Function(_Empty value) empty,
required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage,
}) {
return serverError(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_ServerError value)? serverError,
TResult? Function(_UnexpectedError value)? unexpectedError,
TResult? Function(_Empty value)? empty,
TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage,
}) {
return serverError?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_ServerError value)? serverError,
TResult Function(_UnexpectedError value)? unexpectedError,
TResult Function(_Empty value)? empty,
TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage,
required TResult orElse(),
}) {
if (serverError != null) {
return serverError(this);
}
return orElse();
}
}
abstract class _ServerError implements UserFailure {
const factory _ServerError(final ApiFailure failure) = _$ServerErrorImpl;
ApiFailure get failure;
/// Create a copy of UserFailure
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$UnexpectedErrorImplCopyWith<$Res> {
factory _$$UnexpectedErrorImplCopyWith(
_$UnexpectedErrorImpl value,
$Res Function(_$UnexpectedErrorImpl) then,
) = __$$UnexpectedErrorImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$UnexpectedErrorImplCopyWithImpl<$Res>
extends _$UserFailureCopyWithImpl<$Res, _$UnexpectedErrorImpl>
implements _$$UnexpectedErrorImplCopyWith<$Res> {
__$$UnexpectedErrorImplCopyWithImpl(
_$UnexpectedErrorImpl _value,
$Res Function(_$UnexpectedErrorImpl) _then,
) : super(_value, _then);
/// Create a copy of UserFailure
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$UnexpectedErrorImpl implements _UnexpectedError {
const _$UnexpectedErrorImpl();
@override
String toString() {
return 'UserFailure.unexpectedError()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$UnexpectedErrorImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(ApiFailure failure) serverError,
required TResult Function() unexpectedError,
required TResult Function() empty,
required TResult Function(String erroMessage) dynamicErrorMessage,
}) {
return unexpectedError();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(ApiFailure failure)? serverError,
TResult? Function()? unexpectedError,
TResult? Function()? empty,
TResult? Function(String erroMessage)? dynamicErrorMessage,
}) {
return unexpectedError?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(ApiFailure failure)? serverError,
TResult Function()? unexpectedError,
TResult Function()? empty,
TResult Function(String erroMessage)? dynamicErrorMessage,
required TResult orElse(),
}) {
if (unexpectedError != null) {
return unexpectedError();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_ServerError value) serverError,
required TResult Function(_UnexpectedError value) unexpectedError,
required TResult Function(_Empty value) empty,
required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage,
}) {
return unexpectedError(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_ServerError value)? serverError,
TResult? Function(_UnexpectedError value)? unexpectedError,
TResult? Function(_Empty value)? empty,
TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage,
}) {
return unexpectedError?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_ServerError value)? serverError,
TResult Function(_UnexpectedError value)? unexpectedError,
TResult Function(_Empty value)? empty,
TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage,
required TResult orElse(),
}) {
if (unexpectedError != null) {
return unexpectedError(this);
}
return orElse();
}
}
abstract class _UnexpectedError implements UserFailure {
const factory _UnexpectedError() = _$UnexpectedErrorImpl;
}
/// @nodoc
abstract class _$$EmptyImplCopyWith<$Res> {
factory _$$EmptyImplCopyWith(
_$EmptyImpl value,
$Res Function(_$EmptyImpl) then,
) = __$$EmptyImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$EmptyImplCopyWithImpl<$Res>
extends _$UserFailureCopyWithImpl<$Res, _$EmptyImpl>
implements _$$EmptyImplCopyWith<$Res> {
__$$EmptyImplCopyWithImpl(
_$EmptyImpl _value,
$Res Function(_$EmptyImpl) _then,
) : super(_value, _then);
/// Create a copy of UserFailure
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$EmptyImpl implements _Empty {
const _$EmptyImpl();
@override
String toString() {
return 'UserFailure.empty()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$EmptyImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(ApiFailure failure) serverError,
required TResult Function() unexpectedError,
required TResult Function() empty,
required TResult Function(String erroMessage) dynamicErrorMessage,
}) {
return empty();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(ApiFailure failure)? serverError,
TResult? Function()? unexpectedError,
TResult? Function()? empty,
TResult? Function(String erroMessage)? dynamicErrorMessage,
}) {
return empty?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(ApiFailure failure)? serverError,
TResult Function()? unexpectedError,
TResult Function()? empty,
TResult Function(String erroMessage)? dynamicErrorMessage,
required TResult orElse(),
}) {
if (empty != null) {
return empty();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_ServerError value) serverError,
required TResult Function(_UnexpectedError value) unexpectedError,
required TResult Function(_Empty value) empty,
required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage,
}) {
return empty(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_ServerError value)? serverError,
TResult? Function(_UnexpectedError value)? unexpectedError,
TResult? Function(_Empty value)? empty,
TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage,
}) {
return empty?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_ServerError value)? serverError,
TResult Function(_UnexpectedError value)? unexpectedError,
TResult Function(_Empty value)? empty,
TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage,
required TResult orElse(),
}) {
if (empty != null) {
return empty(this);
}
return orElse();
}
}
abstract class _Empty implements UserFailure {
const factory _Empty() = _$EmptyImpl;
}
/// @nodoc
abstract class _$$DynamicErrorMessageImplCopyWith<$Res> {
factory _$$DynamicErrorMessageImplCopyWith(
_$DynamicErrorMessageImpl value,
$Res Function(_$DynamicErrorMessageImpl) then,
) = __$$DynamicErrorMessageImplCopyWithImpl<$Res>;
@useResult
$Res call({String erroMessage});
}
/// @nodoc
class __$$DynamicErrorMessageImplCopyWithImpl<$Res>
extends _$UserFailureCopyWithImpl<$Res, _$DynamicErrorMessageImpl>
implements _$$DynamicErrorMessageImplCopyWith<$Res> {
__$$DynamicErrorMessageImplCopyWithImpl(
_$DynamicErrorMessageImpl _value,
$Res Function(_$DynamicErrorMessageImpl) _then,
) : super(_value, _then);
/// Create a copy of UserFailure
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? erroMessage = null}) {
return _then(
_$DynamicErrorMessageImpl(
null == erroMessage
? _value.erroMessage
: erroMessage // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$DynamicErrorMessageImpl implements _DynamicErrorMessage {
const _$DynamicErrorMessageImpl(this.erroMessage);
@override
final String erroMessage;
@override
String toString() {
return 'UserFailure.dynamicErrorMessage(erroMessage: $erroMessage)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$DynamicErrorMessageImpl &&
(identical(other.erroMessage, erroMessage) ||
other.erroMessage == erroMessage));
}
@override
int get hashCode => Object.hash(runtimeType, erroMessage);
/// Create a copy of UserFailure
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$DynamicErrorMessageImplCopyWith<_$DynamicErrorMessageImpl> get copyWith =>
__$$DynamicErrorMessageImplCopyWithImpl<_$DynamicErrorMessageImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(ApiFailure failure) serverError,
required TResult Function() unexpectedError,
required TResult Function() empty,
required TResult Function(String erroMessage) dynamicErrorMessage,
}) {
return dynamicErrorMessage(erroMessage);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(ApiFailure failure)? serverError,
TResult? Function()? unexpectedError,
TResult? Function()? empty,
TResult? Function(String erroMessage)? dynamicErrorMessage,
}) {
return dynamicErrorMessage?.call(erroMessage);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(ApiFailure failure)? serverError,
TResult Function()? unexpectedError,
TResult Function()? empty,
TResult Function(String erroMessage)? dynamicErrorMessage,
required TResult orElse(),
}) {
if (dynamicErrorMessage != null) {
return dynamicErrorMessage(erroMessage);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_ServerError value) serverError,
required TResult Function(_UnexpectedError value) unexpectedError,
required TResult Function(_Empty value) empty,
required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage,
}) {
return dynamicErrorMessage(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_ServerError value)? serverError,
TResult? Function(_UnexpectedError value)? unexpectedError,
TResult? Function(_Empty value)? empty,
TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage,
}) {
return dynamicErrorMessage?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_ServerError value)? serverError,
TResult Function(_UnexpectedError value)? unexpectedError,
TResult Function(_Empty value)? empty,
TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage,
required TResult orElse(),
}) {
if (dynamicErrorMessage != null) {
return dynamicErrorMessage(this);
}
return orElse();
}
}
abstract class _DynamicErrorMessage implements UserFailure {
const factory _DynamicErrorMessage(final String erroMessage) =
_$DynamicErrorMessageImpl;
String get erroMessage;
/// Create a copy of UserFailure
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$DynamicErrorMessageImplCopyWith<_$DynamicErrorMessageImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -5,7 +5,7 @@ import 'package:injectable/injectable.dart';
import '../../../domain/analytic/analytic.dart'; import '../../../domain/analytic/analytic.dart';
import '../../../domain/analytic/repositories/i_analytic_repository.dart'; import '../../../domain/analytic/repositories/i_analytic_repository.dart';
import '../../../domain/auth/auth.dart'; import '../../../domain/user/user.dart';
import '../../auth/datasources/local_data_provider.dart'; import '../../auth/datasources/local_data_provider.dart';
import '../datasource/remote_data_provider.dart'; import '../datasource/remote_data_provider.dart';

View File

@ -1,9 +1,10 @@
import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:freezed_annotation/freezed_annotation.dart';
import '../../domain/auth/auth.dart'; import '../../domain/auth/auth.dart';
import '../../domain/user/user.dart';
import '../user/user_dtos.dart';
part 'auth_dtos.freezed.dart'; part 'auth_dtos.freezed.dart';
part 'auth_dtos.g.dart'; part 'auth_dtos.g.dart';
part 'dto/auth_dto.dart'; part 'dto/auth_dto.dart';
part 'dto/user_dto.dart';

View File

@ -242,401 +242,3 @@ abstract class _AuthDto extends AuthDto {
_$$AuthDtoImplCopyWith<_$AuthDtoImpl> get copyWith => _$$AuthDtoImplCopyWith<_$AuthDtoImpl> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
UserDto _$UserDtoFromJson(Map<String, dynamic> json) {
return _UserDto.fromJson(json);
}
/// @nodoc
mixin _$UserDto {
@JsonKey(name: 'id')
String? get id => throw _privateConstructorUsedError;
@JsonKey(name: 'organization_id')
String? get organizationId => throw _privateConstructorUsedError;
@JsonKey(name: 'outlet_id')
String? get outletId => throw _privateConstructorUsedError;
@JsonKey(name: 'name')
String? get name => throw _privateConstructorUsedError;
@JsonKey(name: 'email')
String? get email => throw _privateConstructorUsedError;
@JsonKey(name: 'role')
String? get role => throw _privateConstructorUsedError;
@JsonKey(name: 'permissions')
Map<String, dynamic>? get permissions => throw _privateConstructorUsedError;
@JsonKey(name: 'is_active')
bool? get isActive => throw _privateConstructorUsedError;
@JsonKey(name: 'created_at')
String? get createdAt => throw _privateConstructorUsedError;
@JsonKey(name: 'updated_at')
String? get updatedAt => throw _privateConstructorUsedError;
/// Serializes this UserDto to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of UserDto
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$UserDtoCopyWith<UserDto> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $UserDtoCopyWith<$Res> {
factory $UserDtoCopyWith(UserDto value, $Res Function(UserDto) then) =
_$UserDtoCopyWithImpl<$Res, UserDto>;
@useResult
$Res call({
@JsonKey(name: 'id') String? id,
@JsonKey(name: 'organization_id') String? organizationId,
@JsonKey(name: 'outlet_id') String? outletId,
@JsonKey(name: 'name') String? name,
@JsonKey(name: 'email') String? email,
@JsonKey(name: 'role') String? role,
@JsonKey(name: 'permissions') Map<String, dynamic>? permissions,
@JsonKey(name: 'is_active') bool? isActive,
@JsonKey(name: 'created_at') String? createdAt,
@JsonKey(name: 'updated_at') String? updatedAt,
});
}
/// @nodoc
class _$UserDtoCopyWithImpl<$Res, $Val extends UserDto>
implements $UserDtoCopyWith<$Res> {
_$UserDtoCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of UserDto
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = freezed,
Object? organizationId = freezed,
Object? outletId = freezed,
Object? name = freezed,
Object? email = freezed,
Object? role = freezed,
Object? permissions = freezed,
Object? isActive = freezed,
Object? createdAt = freezed,
Object? updatedAt = freezed,
}) {
return _then(
_value.copyWith(
id: freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String?,
organizationId: freezed == organizationId
? _value.organizationId
: organizationId // ignore: cast_nullable_to_non_nullable
as String?,
outletId: freezed == outletId
? _value.outletId
: outletId // ignore: cast_nullable_to_non_nullable
as String?,
name: freezed == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String?,
email: freezed == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String?,
role: freezed == role
? _value.role
: role // ignore: cast_nullable_to_non_nullable
as String?,
permissions: freezed == permissions
? _value.permissions
: permissions // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
isActive: freezed == isActive
? _value.isActive
: isActive // ignore: cast_nullable_to_non_nullable
as bool?,
createdAt: freezed == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as String?,
updatedAt: freezed == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as String?,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$UserDtoImplCopyWith<$Res> implements $UserDtoCopyWith<$Res> {
factory _$$UserDtoImplCopyWith(
_$UserDtoImpl value,
$Res Function(_$UserDtoImpl) then,
) = __$$UserDtoImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
@JsonKey(name: 'id') String? id,
@JsonKey(name: 'organization_id') String? organizationId,
@JsonKey(name: 'outlet_id') String? outletId,
@JsonKey(name: 'name') String? name,
@JsonKey(name: 'email') String? email,
@JsonKey(name: 'role') String? role,
@JsonKey(name: 'permissions') Map<String, dynamic>? permissions,
@JsonKey(name: 'is_active') bool? isActive,
@JsonKey(name: 'created_at') String? createdAt,
@JsonKey(name: 'updated_at') String? updatedAt,
});
}
/// @nodoc
class __$$UserDtoImplCopyWithImpl<$Res>
extends _$UserDtoCopyWithImpl<$Res, _$UserDtoImpl>
implements _$$UserDtoImplCopyWith<$Res> {
__$$UserDtoImplCopyWithImpl(
_$UserDtoImpl _value,
$Res Function(_$UserDtoImpl) _then,
) : super(_value, _then);
/// Create a copy of UserDto
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = freezed,
Object? organizationId = freezed,
Object? outletId = freezed,
Object? name = freezed,
Object? email = freezed,
Object? role = freezed,
Object? permissions = freezed,
Object? isActive = freezed,
Object? createdAt = freezed,
Object? updatedAt = freezed,
}) {
return _then(
_$UserDtoImpl(
id: freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String?,
organizationId: freezed == organizationId
? _value.organizationId
: organizationId // ignore: cast_nullable_to_non_nullable
as String?,
outletId: freezed == outletId
? _value.outletId
: outletId // ignore: cast_nullable_to_non_nullable
as String?,
name: freezed == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String?,
email: freezed == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String?,
role: freezed == role
? _value.role
: role // ignore: cast_nullable_to_non_nullable
as String?,
permissions: freezed == permissions
? _value._permissions
: permissions // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
isActive: freezed == isActive
? _value.isActive
: isActive // ignore: cast_nullable_to_non_nullable
as bool?,
createdAt: freezed == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as String?,
updatedAt: freezed == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as String?,
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$UserDtoImpl extends _UserDto {
const _$UserDtoImpl({
@JsonKey(name: 'id') this.id,
@JsonKey(name: 'organization_id') this.organizationId,
@JsonKey(name: 'outlet_id') this.outletId,
@JsonKey(name: 'name') this.name,
@JsonKey(name: 'email') this.email,
@JsonKey(name: 'role') this.role,
@JsonKey(name: 'permissions') final Map<String, dynamic>? permissions,
@JsonKey(name: 'is_active') this.isActive,
@JsonKey(name: 'created_at') this.createdAt,
@JsonKey(name: 'updated_at') this.updatedAt,
}) : _permissions = permissions,
super._();
factory _$UserDtoImpl.fromJson(Map<String, dynamic> json) =>
_$$UserDtoImplFromJson(json);
@override
@JsonKey(name: 'id')
final String? id;
@override
@JsonKey(name: 'organization_id')
final String? organizationId;
@override
@JsonKey(name: 'outlet_id')
final String? outletId;
@override
@JsonKey(name: 'name')
final String? name;
@override
@JsonKey(name: 'email')
final String? email;
@override
@JsonKey(name: 'role')
final String? role;
final Map<String, dynamic>? _permissions;
@override
@JsonKey(name: 'permissions')
Map<String, dynamic>? get permissions {
final value = _permissions;
if (value == null) return null;
if (_permissions is EqualUnmodifiableMapView) return _permissions;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(value);
}
@override
@JsonKey(name: 'is_active')
final bool? isActive;
@override
@JsonKey(name: 'created_at')
final String? createdAt;
@override
@JsonKey(name: 'updated_at')
final String? updatedAt;
@override
String toString() {
return 'UserDto(id: $id, organizationId: $organizationId, outletId: $outletId, name: $name, email: $email, role: $role, permissions: $permissions, isActive: $isActive, createdAt: $createdAt, updatedAt: $updatedAt)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$UserDtoImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.organizationId, organizationId) ||
other.organizationId == organizationId) &&
(identical(other.outletId, outletId) ||
other.outletId == outletId) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.email, email) || other.email == email) &&
(identical(other.role, role) || other.role == role) &&
const DeepCollectionEquality().equals(
other._permissions,
_permissions,
) &&
(identical(other.isActive, isActive) ||
other.isActive == isActive) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType,
id,
organizationId,
outletId,
name,
email,
role,
const DeepCollectionEquality().hash(_permissions),
isActive,
createdAt,
updatedAt,
);
/// Create a copy of UserDto
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$UserDtoImplCopyWith<_$UserDtoImpl> get copyWith =>
__$$UserDtoImplCopyWithImpl<_$UserDtoImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$UserDtoImplToJson(this);
}
}
abstract class _UserDto extends UserDto {
const factory _UserDto({
@JsonKey(name: 'id') final String? id,
@JsonKey(name: 'organization_id') final String? organizationId,
@JsonKey(name: 'outlet_id') final String? outletId,
@JsonKey(name: 'name') final String? name,
@JsonKey(name: 'email') final String? email,
@JsonKey(name: 'role') final String? role,
@JsonKey(name: 'permissions') final Map<String, dynamic>? permissions,
@JsonKey(name: 'is_active') final bool? isActive,
@JsonKey(name: 'created_at') final String? createdAt,
@JsonKey(name: 'updated_at') final String? updatedAt,
}) = _$UserDtoImpl;
const _UserDto._() : super._();
factory _UserDto.fromJson(Map<String, dynamic> json) = _$UserDtoImpl.fromJson;
@override
@JsonKey(name: 'id')
String? get id;
@override
@JsonKey(name: 'organization_id')
String? get organizationId;
@override
@JsonKey(name: 'outlet_id')
String? get outletId;
@override
@JsonKey(name: 'name')
String? get name;
@override
@JsonKey(name: 'email')
String? get email;
@override
@JsonKey(name: 'role')
String? get role;
@override
@JsonKey(name: 'permissions')
Map<String, dynamic>? get permissions;
@override
@JsonKey(name: 'is_active')
bool? get isActive;
@override
@JsonKey(name: 'created_at')
String? get createdAt;
@override
@JsonKey(name: 'updated_at')
String? get updatedAt;
/// Create a copy of UserDto
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$UserDtoImplCopyWith<_$UserDtoImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -21,31 +21,3 @@ Map<String, dynamic> _$$AuthDtoImplToJson(_$AuthDtoImpl instance) =>
'expires_at': instance.expiresAt, 'expires_at': instance.expiresAt,
'user': instance.user, 'user': instance.user,
}; };
_$UserDtoImpl _$$UserDtoImplFromJson(Map<String, dynamic> json) =>
_$UserDtoImpl(
id: json['id'] as String?,
organizationId: json['organization_id'] as String?,
outletId: json['outlet_id'] as String?,
name: json['name'] as String?,
email: json['email'] as String?,
role: json['role'] as String?,
permissions: json['permissions'] as Map<String, dynamic>?,
isActive: json['is_active'] as bool?,
createdAt: json['created_at'] as String?,
updatedAt: json['updated_at'] as String?,
);
Map<String, dynamic> _$$UserDtoImplToJson(_$UserDtoImpl instance) =>
<String, dynamic>{
'id': instance.id,
'organization_id': instance.organizationId,
'outlet_id': instance.outletId,
'name': instance.name,
'email': instance.email,
'role': instance.role,
'permissions': instance.permissions,
'is_active': instance.isActive,
'created_at': instance.createdAt,
'updated_at': instance.updatedAt,
};

View File

@ -5,8 +5,8 @@ import 'package:injectable/injectable.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import '../../../common/constant/local_storage_key.dart'; import '../../../common/constant/local_storage_key.dart';
import '../../../domain/auth/auth.dart'; import '../../../domain/user/user.dart';
import '../auth_dtos.dart'; import '../../user/user_dtos.dart';
@injectable @injectable
class AuthLocalDataProvider { class AuthLocalDataProvider {

View File

@ -4,6 +4,7 @@ import 'package:dartz/dartz.dart';
import 'package:injectable/injectable.dart'; import 'package:injectable/injectable.dart';
import '../../../domain/auth/auth.dart'; import '../../../domain/auth/auth.dart';
import '../../../domain/user/user.dart';
import '../datasources/local_data_provider.dart'; import '../datasources/local_data_provider.dart';
import '../datasources/remote_data_provider.dart'; import '../datasources/remote_data_provider.dart';

View File

@ -0,0 +1,50 @@
import 'dart:developer';
import 'package:data_channel/data_channel.dart';
import 'package:injectable/injectable.dart';
import '../../../common/api/api_client.dart';
import '../../../common/api/api_failure.dart';
import '../../../common/function/app_function.dart';
import '../../../common/url/api_path.dart';
import '../../../domain/user/user.dart';
import '../user_dtos.dart';
@injectable
class UserRemoteDataProvider {
final ApiClient _apiClient;
static const _logName = 'UserRemoteDataProvider';
UserRemoteDataProvider(this._apiClient);
Future<DC<UserFailure, UserDto>> updateUser({
required String name,
required String userId,
}) async {
try {
final response = await _apiClient.put(
'${ApiPath.user}/$userId',
data: {'name': name, 'is_active': true},
headers: getAuthorizationHeader(),
);
if (response.statusCode == 400) {
return DC.error(UserFailure.unexpectedError());
}
if (response.statusCode != 200) {
return DC.error(
UserFailure.dynamicErrorMessage(response.data['message']),
);
}
final dto = UserDto.fromJson(response.data);
return DC.data(dto);
} on ApiFailure catch (e, s) {
log('updateUser', name: _logName, error: e, stackTrace: s);
return DC.error(UserFailure.serverError(e));
}
}
}

View File

@ -1,4 +1,4 @@
part of '../auth_dtos.dart'; part of '../user_dtos.dart';
@freezed @freezed
class UserDto with _$UserDto { class UserDto with _$UserDto {

View File

@ -0,0 +1,42 @@
import 'dart:developer';
import 'package:dartz/dartz.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/user/user.dart';
import '../../auth/datasources/local_data_provider.dart';
import '../datasource/remote_data_provider.dart';
@Injectable(as: IUserRepository)
class UserRepository implements IUserRepository {
final UserRemoteDataProvider _dataProvider;
final AuthLocalDataProvider _authLocalDataProvider;
final String _logName = 'UserRepository';
UserRepository(this._dataProvider, this._authLocalDataProvider);
@override
Future<Either<UserFailure, User>> editUser({required String name}) async {
try {
User currentUser = await _authLocalDataProvider.currentUser();
final result = await _dataProvider.updateUser(
name: name,
userId: currentUser.id,
);
if (result.hasError) {
return left(result.error!);
}
final auth = result.data!.toDomain();
await _authLocalDataProvider.saveCurrentUser(result.data!);
return right(auth);
} catch (e, s) {
log('editUserError', name: _logName, error: e, stackTrace: s);
return left(const UserFailure.unexpectedError());
}
}
}

View File

@ -0,0 +1,8 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import '../../domain/user/user.dart';
part 'user_dtos.freezed.dart';
part 'user_dtos.g.dart';
part 'dto/user_dto.dart';

View File

@ -0,0 +1,414 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'user_dtos.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
UserDto _$UserDtoFromJson(Map<String, dynamic> json) {
return _UserDto.fromJson(json);
}
/// @nodoc
mixin _$UserDto {
@JsonKey(name: 'id')
String? get id => throw _privateConstructorUsedError;
@JsonKey(name: 'organization_id')
String? get organizationId => throw _privateConstructorUsedError;
@JsonKey(name: 'outlet_id')
String? get outletId => throw _privateConstructorUsedError;
@JsonKey(name: 'name')
String? get name => throw _privateConstructorUsedError;
@JsonKey(name: 'email')
String? get email => throw _privateConstructorUsedError;
@JsonKey(name: 'role')
String? get role => throw _privateConstructorUsedError;
@JsonKey(name: 'permissions')
Map<String, dynamic>? get permissions => throw _privateConstructorUsedError;
@JsonKey(name: 'is_active')
bool? get isActive => throw _privateConstructorUsedError;
@JsonKey(name: 'created_at')
String? get createdAt => throw _privateConstructorUsedError;
@JsonKey(name: 'updated_at')
String? get updatedAt => throw _privateConstructorUsedError;
/// Serializes this UserDto to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of UserDto
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$UserDtoCopyWith<UserDto> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $UserDtoCopyWith<$Res> {
factory $UserDtoCopyWith(UserDto value, $Res Function(UserDto) then) =
_$UserDtoCopyWithImpl<$Res, UserDto>;
@useResult
$Res call({
@JsonKey(name: 'id') String? id,
@JsonKey(name: 'organization_id') String? organizationId,
@JsonKey(name: 'outlet_id') String? outletId,
@JsonKey(name: 'name') String? name,
@JsonKey(name: 'email') String? email,
@JsonKey(name: 'role') String? role,
@JsonKey(name: 'permissions') Map<String, dynamic>? permissions,
@JsonKey(name: 'is_active') bool? isActive,
@JsonKey(name: 'created_at') String? createdAt,
@JsonKey(name: 'updated_at') String? updatedAt,
});
}
/// @nodoc
class _$UserDtoCopyWithImpl<$Res, $Val extends UserDto>
implements $UserDtoCopyWith<$Res> {
_$UserDtoCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of UserDto
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = freezed,
Object? organizationId = freezed,
Object? outletId = freezed,
Object? name = freezed,
Object? email = freezed,
Object? role = freezed,
Object? permissions = freezed,
Object? isActive = freezed,
Object? createdAt = freezed,
Object? updatedAt = freezed,
}) {
return _then(
_value.copyWith(
id: freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String?,
organizationId: freezed == organizationId
? _value.organizationId
: organizationId // ignore: cast_nullable_to_non_nullable
as String?,
outletId: freezed == outletId
? _value.outletId
: outletId // ignore: cast_nullable_to_non_nullable
as String?,
name: freezed == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String?,
email: freezed == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String?,
role: freezed == role
? _value.role
: role // ignore: cast_nullable_to_non_nullable
as String?,
permissions: freezed == permissions
? _value.permissions
: permissions // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
isActive: freezed == isActive
? _value.isActive
: isActive // ignore: cast_nullable_to_non_nullable
as bool?,
createdAt: freezed == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as String?,
updatedAt: freezed == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as String?,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$UserDtoImplCopyWith<$Res> implements $UserDtoCopyWith<$Res> {
factory _$$UserDtoImplCopyWith(
_$UserDtoImpl value,
$Res Function(_$UserDtoImpl) then,
) = __$$UserDtoImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
@JsonKey(name: 'id') String? id,
@JsonKey(name: 'organization_id') String? organizationId,
@JsonKey(name: 'outlet_id') String? outletId,
@JsonKey(name: 'name') String? name,
@JsonKey(name: 'email') String? email,
@JsonKey(name: 'role') String? role,
@JsonKey(name: 'permissions') Map<String, dynamic>? permissions,
@JsonKey(name: 'is_active') bool? isActive,
@JsonKey(name: 'created_at') String? createdAt,
@JsonKey(name: 'updated_at') String? updatedAt,
});
}
/// @nodoc
class __$$UserDtoImplCopyWithImpl<$Res>
extends _$UserDtoCopyWithImpl<$Res, _$UserDtoImpl>
implements _$$UserDtoImplCopyWith<$Res> {
__$$UserDtoImplCopyWithImpl(
_$UserDtoImpl _value,
$Res Function(_$UserDtoImpl) _then,
) : super(_value, _then);
/// Create a copy of UserDto
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = freezed,
Object? organizationId = freezed,
Object? outletId = freezed,
Object? name = freezed,
Object? email = freezed,
Object? role = freezed,
Object? permissions = freezed,
Object? isActive = freezed,
Object? createdAt = freezed,
Object? updatedAt = freezed,
}) {
return _then(
_$UserDtoImpl(
id: freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String?,
organizationId: freezed == organizationId
? _value.organizationId
: organizationId // ignore: cast_nullable_to_non_nullable
as String?,
outletId: freezed == outletId
? _value.outletId
: outletId // ignore: cast_nullable_to_non_nullable
as String?,
name: freezed == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String?,
email: freezed == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String?,
role: freezed == role
? _value.role
: role // ignore: cast_nullable_to_non_nullable
as String?,
permissions: freezed == permissions
? _value._permissions
: permissions // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
isActive: freezed == isActive
? _value.isActive
: isActive // ignore: cast_nullable_to_non_nullable
as bool?,
createdAt: freezed == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as String?,
updatedAt: freezed == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as String?,
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$UserDtoImpl extends _UserDto {
const _$UserDtoImpl({
@JsonKey(name: 'id') this.id,
@JsonKey(name: 'organization_id') this.organizationId,
@JsonKey(name: 'outlet_id') this.outletId,
@JsonKey(name: 'name') this.name,
@JsonKey(name: 'email') this.email,
@JsonKey(name: 'role') this.role,
@JsonKey(name: 'permissions') final Map<String, dynamic>? permissions,
@JsonKey(name: 'is_active') this.isActive,
@JsonKey(name: 'created_at') this.createdAt,
@JsonKey(name: 'updated_at') this.updatedAt,
}) : _permissions = permissions,
super._();
factory _$UserDtoImpl.fromJson(Map<String, dynamic> json) =>
_$$UserDtoImplFromJson(json);
@override
@JsonKey(name: 'id')
final String? id;
@override
@JsonKey(name: 'organization_id')
final String? organizationId;
@override
@JsonKey(name: 'outlet_id')
final String? outletId;
@override
@JsonKey(name: 'name')
final String? name;
@override
@JsonKey(name: 'email')
final String? email;
@override
@JsonKey(name: 'role')
final String? role;
final Map<String, dynamic>? _permissions;
@override
@JsonKey(name: 'permissions')
Map<String, dynamic>? get permissions {
final value = _permissions;
if (value == null) return null;
if (_permissions is EqualUnmodifiableMapView) return _permissions;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(value);
}
@override
@JsonKey(name: 'is_active')
final bool? isActive;
@override
@JsonKey(name: 'created_at')
final String? createdAt;
@override
@JsonKey(name: 'updated_at')
final String? updatedAt;
@override
String toString() {
return 'UserDto(id: $id, organizationId: $organizationId, outletId: $outletId, name: $name, email: $email, role: $role, permissions: $permissions, isActive: $isActive, createdAt: $createdAt, updatedAt: $updatedAt)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$UserDtoImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.organizationId, organizationId) ||
other.organizationId == organizationId) &&
(identical(other.outletId, outletId) ||
other.outletId == outletId) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.email, email) || other.email == email) &&
(identical(other.role, role) || other.role == role) &&
const DeepCollectionEquality().equals(
other._permissions,
_permissions,
) &&
(identical(other.isActive, isActive) ||
other.isActive == isActive) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType,
id,
organizationId,
outletId,
name,
email,
role,
const DeepCollectionEquality().hash(_permissions),
isActive,
createdAt,
updatedAt,
);
/// Create a copy of UserDto
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$UserDtoImplCopyWith<_$UserDtoImpl> get copyWith =>
__$$UserDtoImplCopyWithImpl<_$UserDtoImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$UserDtoImplToJson(this);
}
}
abstract class _UserDto extends UserDto {
const factory _UserDto({
@JsonKey(name: 'id') final String? id,
@JsonKey(name: 'organization_id') final String? organizationId,
@JsonKey(name: 'outlet_id') final String? outletId,
@JsonKey(name: 'name') final String? name,
@JsonKey(name: 'email') final String? email,
@JsonKey(name: 'role') final String? role,
@JsonKey(name: 'permissions') final Map<String, dynamic>? permissions,
@JsonKey(name: 'is_active') final bool? isActive,
@JsonKey(name: 'created_at') final String? createdAt,
@JsonKey(name: 'updated_at') final String? updatedAt,
}) = _$UserDtoImpl;
const _UserDto._() : super._();
factory _UserDto.fromJson(Map<String, dynamic> json) = _$UserDtoImpl.fromJson;
@override
@JsonKey(name: 'id')
String? get id;
@override
@JsonKey(name: 'organization_id')
String? get organizationId;
@override
@JsonKey(name: 'outlet_id')
String? get outletId;
@override
@JsonKey(name: 'name')
String? get name;
@override
@JsonKey(name: 'email')
String? get email;
@override
@JsonKey(name: 'role')
String? get role;
@override
@JsonKey(name: 'permissions')
Map<String, dynamic>? get permissions;
@override
@JsonKey(name: 'is_active')
bool? get isActive;
@override
@JsonKey(name: 'created_at')
String? get createdAt;
@override
@JsonKey(name: 'updated_at')
String? get updatedAt;
/// Create a copy of UserDto
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$UserDtoImplCopyWith<_$UserDtoImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -0,0 +1,35 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'user_dtos.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$UserDtoImpl _$$UserDtoImplFromJson(Map<String, dynamic> json) =>
_$UserDtoImpl(
id: json['id'] as String?,
organizationId: json['organization_id'] as String?,
outletId: json['outlet_id'] as String?,
name: json['name'] as String?,
email: json['email'] as String?,
role: json['role'] as String?,
permissions: json['permissions'] as Map<String, dynamic>?,
isActive: json['is_active'] as bool?,
createdAt: json['created_at'] as String?,
updatedAt: json['updated_at'] as String?,
);
Map<String, dynamic> _$$UserDtoImplToJson(_$UserDtoImpl instance) =>
<String, dynamic>{
'id': instance.id,
'organization_id': instance.organizationId,
'outlet_id': instance.outletId,
'name': instance.name,
'email': instance.email,
'role': instance.role,
'permissions': instance.permissions,
'is_active': instance.isActive,
'created_at': instance.createdAt,
'updated_at': instance.updatedAt,
};

View File

@ -41,6 +41,8 @@ import 'package:apskel_owner_flutter/application/outlet/current_outlet_loader/cu
as _i337; as _i337;
import 'package:apskel_owner_flutter/application/product/product_loader/product_loader_bloc.dart' import 'package:apskel_owner_flutter/application/product/product_loader/product_loader_bloc.dart'
as _i458; as _i458;
import 'package:apskel_owner_flutter/application/user/user_edit_form/user_edit_form_bloc.dart'
as _i147;
import 'package:apskel_owner_flutter/common/api/api_client.dart' as _i115; import 'package:apskel_owner_flutter/common/api/api_client.dart' as _i115;
import 'package:apskel_owner_flutter/common/di/di_auto_route.dart' as _i311; import 'package:apskel_owner_flutter/common/di/di_auto_route.dart' as _i311;
import 'package:apskel_owner_flutter/common/di/di_connectivity.dart' as _i586; import 'package:apskel_owner_flutter/common/di/di_connectivity.dart' as _i586;
@ -58,6 +60,7 @@ import 'package:apskel_owner_flutter/domain/customer/customer.dart' as _i48;
import 'package:apskel_owner_flutter/domain/order/order.dart' as _i219; import 'package:apskel_owner_flutter/domain/order/order.dart' as _i219;
import 'package:apskel_owner_flutter/domain/outlet/outlet.dart' as _i197; import 'package:apskel_owner_flutter/domain/outlet/outlet.dart' as _i197;
import 'package:apskel_owner_flutter/domain/product/product.dart' as _i419; import 'package:apskel_owner_flutter/domain/product/product.dart' as _i419;
import 'package:apskel_owner_flutter/domain/user/user.dart' as _i635;
import 'package:apskel_owner_flutter/env.dart' as _i6; import 'package:apskel_owner_flutter/env.dart' as _i6;
import 'package:apskel_owner_flutter/infrastructure/analytic/datasource/remote_data_provider.dart' import 'package:apskel_owner_flutter/infrastructure/analytic/datasource/remote_data_provider.dart'
as _i866; as _i866;
@ -89,6 +92,10 @@ import 'package:apskel_owner_flutter/infrastructure/product/datasources/remote_d
as _i823; as _i823;
import 'package:apskel_owner_flutter/infrastructure/product/repositories/product_repository.dart' import 'package:apskel_owner_flutter/infrastructure/product/repositories/product_repository.dart'
as _i121; as _i121;
import 'package:apskel_owner_flutter/infrastructure/user/datasource/remote_data_provider.dart'
as _i785;
import 'package:apskel_owner_flutter/infrastructure/user/repositories/user_repository.dart'
as _i754;
import 'package:apskel_owner_flutter/presentation/router/app_router.dart' import 'package:apskel_owner_flutter/presentation/router/app_router.dart'
as _i258; as _i258;
import 'package:connectivity_plus/connectivity_plus.dart' as _i895; import 'package:connectivity_plus/connectivity_plus.dart' as _i895;
@ -159,6 +166,9 @@ extension GetItInjectableX on _i174.GetIt {
gh.factory<_i27.OutletRemoteDataProvider>( gh.factory<_i27.OutletRemoteDataProvider>(
() => _i27.OutletRemoteDataProvider(gh<_i115.ApiClient>()), () => _i27.OutletRemoteDataProvider(gh<_i115.ApiClient>()),
); );
gh.factory<_i785.UserRemoteDataProvider>(
() => _i785.UserRemoteDataProvider(gh<_i115.ApiClient>()),
);
gh.factory<_i48.ICustomerRepository>( gh.factory<_i48.ICustomerRepository>(
() => _i550.CustomerRepository(gh<_i1006.CustomerRemoteDataProvider>()), () => _i550.CustomerRepository(gh<_i1006.CustomerRemoteDataProvider>()),
); );
@ -171,6 +181,12 @@ extension GetItInjectableX on _i174.GetIt {
gh<_i17.AuthRemoteDataProvider>(), gh<_i17.AuthRemoteDataProvider>(),
), ),
); );
gh.factory<_i635.IUserRepository>(
() => _i754.UserRepository(
gh<_i785.UserRemoteDataProvider>(),
gh<_i991.AuthLocalDataProvider>(),
),
);
gh.factory<_i419.IProductRepository>( gh.factory<_i419.IProductRepository>(
() => _i121.ProductRepository(gh<_i823.ProductRemoteDataProvider>()), () => _i121.ProductRepository(gh<_i823.ProductRemoteDataProvider>()),
); );
@ -239,6 +255,9 @@ extension GetItInjectableX on _i174.GetIt {
gh.factory<_i1058.OrderLoaderBloc>( gh.factory<_i1058.OrderLoaderBloc>(
() => _i1058.OrderLoaderBloc(gh<_i219.IOrderRepository>()), () => _i1058.OrderLoaderBloc(gh<_i219.IOrderRepository>()),
); );
gh.factory<_i147.UserEditFormBloc>(
() => _i147.UserEditFormBloc(gh<_i635.IUserRepository>()),
);
return this; return this;
} }
} }

View File

@ -7,17 +7,20 @@ class AppElevatedButton extends StatelessWidget {
required this.isLoading, required this.isLoading,
required this.onPressed, required this.onPressed,
this.height = 50, this.height = 50,
this.width = double.infinity,
}); });
final String text; final String text;
final bool isLoading; final bool isLoading;
final Function()? onPressed; final Function()? onPressed;
final double height; final double height;
final double width;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
height: height, height: height,
width: width,
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: const LinearGradient(colors: AppColor.primaryGradient), gradient: const LinearGradient(colors: AppColor.primaryGradient),
borderRadius: BorderRadius.circular(AppValue.radius), borderRadius: BorderRadius.circular(AppValue.radius),

View File

@ -9,6 +9,7 @@ class AppTextFormField extends StatelessWidget {
required this.prefixIcon, required this.prefixIcon,
this.validator, this.validator,
this.onChanged, this.onChanged,
this.keyboardType = TextInputType.text,
}); });
final TextEditingController? controller; final TextEditingController? controller;
@ -17,6 +18,7 @@ class AppTextFormField extends StatelessWidget {
final IconData prefixIcon; final IconData prefixIcon;
final String? Function(String?)? validator; final String? Function(String?)? validator;
final Function(String)? onChanged; final Function(String)? onChanged;
final TextInputType keyboardType;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -33,7 +35,7 @@ class AppTextFormField extends StatelessWidget {
const SpaceHeight(8), const SpaceHeight(8),
TextFormField( TextFormField(
controller: controller, controller: controller,
keyboardType: TextInputType.emailAddress, keyboardType: keyboardType,
cursorColor: AppColor.primary, cursorColor: AppColor.primary,
onChanged: onChanged, onChanged: onChanged,
style: AppStyle.md.copyWith(color: AppColor.textPrimary), style: AppStyle.md.copyWith(color: AppColor.textPrimary),

View File

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import '../../../common/theme/theme.dart'; import '../../../common/theme/theme.dart';
import '../../../domain/auth/auth.dart'; import '../../../domain/auth/auth.dart';
import '../../../domain/user/user.dart';
class AppFlushbar { class AppFlushbar {
static void showSuccess(BuildContext context, String message) { static void showSuccess(BuildContext context, String message) {
@ -51,4 +52,15 @@ class AppFlushbar {
unexpectedError: (value) => 'Error has eccoured', unexpectedError: (value) => 'Error has eccoured',
), ),
); );
static void showUserFailureToast(BuildContext context, UserFailure failure) =>
showError(
context,
failure.map(
serverError: (value) => value.failure.toStringFormatted(context),
dynamicErrorMessage: (value) => value.erroMessage,
unexpectedError: (value) => 'Error has eccoured',
empty: (value) => 'Data not found',
),
);
} }

View File

@ -7,7 +7,7 @@ import '../../../../common/constant/app_constant.dart';
import '../../../../common/extension/extension.dart'; import '../../../../common/extension/extension.dart';
import '../../../../common/painter/wave_painter.dart'; import '../../../../common/painter/wave_painter.dart';
import '../../../../common/theme/theme.dart'; import '../../../../common/theme/theme.dart';
import '../../../../domain/auth/auth.dart'; import '../../../../domain/user/user.dart';
import '../../../components/spacer/spacer.dart'; import '../../../components/spacer/spacer.dart';
class HomeHeader extends StatefulWidget { class HomeHeader extends StatefulWidget {

View File

@ -0,0 +1,108 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../../../application/auth/auth_bloc.dart';
import '../../../../../application/user/user_edit_form/user_edit_form_bloc.dart';
import '../../../../../common/theme/theme.dart';
import '../../../../../domain/user/user.dart';
import '../../../../../injection.dart';
import '../../../../components/appbar/appbar.dart';
import '../../../../components/button/button.dart';
import '../../../../components/spacer/spacer.dart';
import '../../../../components/toast/flushbar.dart';
import 'widgets/name_field.dart';
@RoutePage()
class ProfileEditPage extends StatefulWidget implements AutoRouteWrapper {
final User user;
const ProfileEditPage({super.key, required this.user});
@override
State<ProfileEditPage> createState() => _ProfileEditPageState();
@override
Widget wrappedRoute(BuildContext context) =>
BlocProvider(create: (_) => getIt<UserEditFormBloc>(), child: this);
}
class _ProfileEditPageState extends State<ProfileEditPage> {
TextEditingController nameController = TextEditingController();
@override
void initState() {
super.initState();
nameController = TextEditingController(text: widget.user.name);
}
@override
Widget build(BuildContext context) {
return BlocListener<UserEditFormBloc, UserEditFormState>(
listenWhen: (p, c) => p.failureOrUserOption != c.failureOrUserOption,
listener: (context, state) {
state.failureOrUserOption.fold(
() => null,
(either) => either.fold(
(f) => AppFlushbar.showUserFailureToast(context, f),
(user) {
if (context.mounted) {
context.read<AuthBloc>().add(AuthEvent.fetchCurrentUser());
context.router.back();
}
},
),
);
},
child: Scaffold(
backgroundColor: AppColor.background,
body: CustomScrollView(
slivers: [
// SliverAppBar with gradient
SliverAppBar(
expandedHeight: 120,
floating: false,
pinned: true,
elevation: 0,
backgroundColor: AppColor.primary,
flexibleSpace: CustomAppBar(title: 'Profile Edit'),
),
SliverToBoxAdapter(
child: BlocBuilder<UserEditFormBloc, UserEditFormState>(
builder: (context, state) {
return Container(
margin: EdgeInsets.all(AppValue.margin),
padding: EdgeInsets.all(AppValue.padding),
decoration: BoxDecoration(
color: AppColor.white,
borderRadius: BorderRadius.circular(AppValue.radius),
),
child: Form(
autovalidateMode: state.showErrorMessages
? AutovalidateMode.always
: AutovalidateMode.disabled,
child: Column(
children: [
ProfileEditNameField(controller: nameController),
SpaceHeight(24),
AppElevatedButton(
text: 'Save',
isLoading: state.isSubmitting,
onPressed: () {
context.read<UserEditFormBloc>().add(
UserEditFormEvent.submitted(),
);
},
),
],
),
),
);
},
),
),
],
),
),
);
}
}

View File

@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:line_icons/line_icons.dart';
import '../../../../../../application/user/user_edit_form/user_edit_form_bloc.dart';
import '../../../../../components/field/field.dart';
class ProfileEditNameField extends StatelessWidget {
final TextEditingController controller;
const ProfileEditNameField({super.key, required this.controller});
@override
Widget build(BuildContext context) {
return AppTextFormField(
title: 'Name',
prefixIcon: LineIcons.user,
hintText: 'Please enter your name',
controller: controller,
onChanged: (value) {
context.read<UserEditFormBloc>().add(
UserEditFormEvent.nameChanged(value),
);
},
validator: (value) {
if (context.read<UserEditFormBloc>().state.name.isEmpty) {
return 'Please enter your name';
}
return null;
},
);
}
}

View File

@ -98,7 +98,9 @@ class ProfilePage extends StatelessWidget implements AutoRouteWrapper {
), ),
), ),
ActionIconButton( ActionIconButton(
onTap: () {}, onTap: () => context.router.push(
ProfileEditRoute(user: state.user),
),
icon: LineIcons.userEdit, icon: LineIcons.userEdit,
), ),
], ],

View File

@ -1,9 +1,11 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:line_icons/line_icons.dart'; import 'package:line_icons/line_icons.dart';
import '../../../../common/extension/extension.dart'; import '../../../../common/extension/extension.dart';
import '../../../../common/theme/theme.dart'; import '../../../../common/theme/theme.dart';
import '../../../../domain/auth/auth.dart'; import '../../../../domain/user/user.dart';
import '../../../router/app_router.gr.dart';
import 'divider.dart'; import 'divider.dart';
import 'profile_tile.dart'; import 'profile_tile.dart';
@ -45,9 +47,7 @@ class ProfileAccountInfo extends StatelessWidget {
icon: LineIcons.envelope, icon: LineIcons.envelope,
title: 'Email', title: 'Email',
subtitle: user.email, subtitle: user.email,
onTap: () { showArrow: false,
// Edit email
},
), ),
ProfileDivider(), ProfileDivider(),
@ -64,7 +64,7 @@ class ProfileAccountInfo extends StatelessWidget {
icon: LineIcons.userEdit, icon: LineIcons.userEdit,
title: 'Ubah Profil', title: 'Ubah Profil',
subtitle: 'Ubah profil kamu', subtitle: 'Ubah profil kamu',
showArrow: false, onTap: () => context.router.push(ProfileEditRoute(user: user)),
), ),
], ],
), ),

View File

@ -4,7 +4,7 @@ import 'dart:math' as math;
import '../../../../common/extension/extension.dart'; import '../../../../common/extension/extension.dart';
import '../../../../common/painter/wave_painter.dart'; import '../../../../common/painter/wave_painter.dart';
import '../../../../common/theme/theme.dart'; import '../../../../common/theme/theme.dart';
import '../../../../domain/auth/auth.dart'; import '../../../../domain/user/user.dart';
import '../../../components/spacer/spacer.dart'; import '../../../components/spacer/spacer.dart';
class ProfileHeader extends StatefulWidget { class ProfileHeader extends StatefulWidget {

View File

@ -59,6 +59,9 @@ class AppRouter extends RootStackRouter {
// Download Report // Download Report
AutoRoute(page: DownloadReportRoute.page), AutoRoute(page: DownloadReportRoute.page),
// Profile
AutoRoute(page: ProfileEditRoute.page),
// Error // Error
AutoRoute(page: ErrorRoute.page), AutoRoute(page: ErrorRoute.page),

View File

@ -9,7 +9,8 @@
// coverage:ignore-file // coverage:ignore-file
// ignore_for_file: no_leading_underscores_for_library_prefixes // ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:apskel_owner_flutter/domain/order/order.dart' as _i25; import 'package:apskel_owner_flutter/domain/order/order.dart' as _i26;
import 'package:apskel_owner_flutter/domain/user/user.dart' as _i27;
import 'package:apskel_owner_flutter/presentation/pages/auth/login/login_page.dart' import 'package:apskel_owner_flutter/presentation/pages/auth/login/login_page.dart'
as _i10; as _i10;
import 'package:apskel_owner_flutter/presentation/pages/coming_soon/coming_soon_page.dart' import 'package:apskel_owner_flutter/presentation/pages/coming_soon/coming_soon_page.dart'
@ -42,30 +43,32 @@ import 'package:apskel_owner_flutter/presentation/pages/product/product_analytic
as _i15; as _i15;
import 'package:apskel_owner_flutter/presentation/pages/product/product_list/product_page.dart' import 'package:apskel_owner_flutter/presentation/pages/product/product_list/product_page.dart'
as _i16; as _i16;
import 'package:apskel_owner_flutter/presentation/pages/profile/profile_page.dart' import 'package:apskel_owner_flutter/presentation/pages/profile/pages/profile_edit/profile_edit_page.dart'
as _i17; as _i17;
import 'package:apskel_owner_flutter/presentation/pages/purchase/purchase_page.dart' import 'package:apskel_owner_flutter/presentation/pages/profile/profile_page.dart'
as _i18; as _i18;
import 'package:apskel_owner_flutter/presentation/pages/report/report_page.dart' import 'package:apskel_owner_flutter/presentation/pages/purchase/purchase_page.dart'
as _i19; as _i19;
import 'package:apskel_owner_flutter/presentation/pages/sales/sales_page.dart' import 'package:apskel_owner_flutter/presentation/pages/report/report_page.dart'
as _i20; as _i20;
import 'package:apskel_owner_flutter/presentation/pages/schedule/schedule_page.dart' import 'package:apskel_owner_flutter/presentation/pages/sales/sales_page.dart'
as _i21; as _i21;
import 'package:apskel_owner_flutter/presentation/pages/splash/splash_page.dart' import 'package:apskel_owner_flutter/presentation/pages/schedule/schedule_page.dart'
as _i22; as _i22;
import 'package:auto_route/auto_route.dart' as _i23; import 'package:apskel_owner_flutter/presentation/pages/splash/splash_page.dart'
import 'package:flutter/material.dart' as _i24; as _i23;
import 'package:auto_route/auto_route.dart' as _i24;
import 'package:flutter/material.dart' as _i25;
/// generated route for /// generated route for
/// [_i1.ComingSoonPage] /// [_i1.ComingSoonPage]
class ComingSoonRoute extends _i23.PageRouteInfo<void> { class ComingSoonRoute extends _i24.PageRouteInfo<void> {
const ComingSoonRoute({List<_i23.PageRouteInfo>? children}) const ComingSoonRoute({List<_i24.PageRouteInfo>? children})
: super(ComingSoonRoute.name, initialChildren: children); : super(ComingSoonRoute.name, initialChildren: children);
static const String name = 'ComingSoonRoute'; static const String name = 'ComingSoonRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i1.ComingSoonPage(); return const _i1.ComingSoonPage();
@ -75,29 +78,29 @@ class ComingSoonRoute extends _i23.PageRouteInfo<void> {
/// generated route for /// generated route for
/// [_i2.CustomerPage] /// [_i2.CustomerPage]
class CustomerRoute extends _i23.PageRouteInfo<void> { class CustomerRoute extends _i24.PageRouteInfo<void> {
const CustomerRoute({List<_i23.PageRouteInfo>? children}) const CustomerRoute({List<_i24.PageRouteInfo>? children})
: super(CustomerRoute.name, initialChildren: children); : super(CustomerRoute.name, initialChildren: children);
static const String name = 'CustomerRoute'; static const String name = 'CustomerRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i23.WrappedRoute(child: const _i2.CustomerPage()); return _i24.WrappedRoute(child: const _i2.CustomerPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i3.DailyTasksFormPage] /// [_i3.DailyTasksFormPage]
class DailyTasksFormRoute extends _i23.PageRouteInfo<void> { class DailyTasksFormRoute extends _i24.PageRouteInfo<void> {
const DailyTasksFormRoute({List<_i23.PageRouteInfo>? children}) const DailyTasksFormRoute({List<_i24.PageRouteInfo>? children})
: super(DailyTasksFormRoute.name, initialChildren: children); : super(DailyTasksFormRoute.name, initialChildren: children);
static const String name = 'DailyTasksFormRoute'; static const String name = 'DailyTasksFormRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i3.DailyTasksFormPage(); return const _i3.DailyTasksFormPage();
@ -107,13 +110,13 @@ class DailyTasksFormRoute extends _i23.PageRouteInfo<void> {
/// generated route for /// generated route for
/// [_i4.DownloadReportPage] /// [_i4.DownloadReportPage]
class DownloadReportRoute extends _i23.PageRouteInfo<void> { class DownloadReportRoute extends _i24.PageRouteInfo<void> {
const DownloadReportRoute({List<_i23.PageRouteInfo>? children}) const DownloadReportRoute({List<_i24.PageRouteInfo>? children})
: super(DownloadReportRoute.name, initialChildren: children); : super(DownloadReportRoute.name, initialChildren: children);
static const String name = 'DownloadReportRoute'; static const String name = 'DownloadReportRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i4.DownloadReportPage(); return const _i4.DownloadReportPage();
@ -123,16 +126,16 @@ class DownloadReportRoute extends _i23.PageRouteInfo<void> {
/// generated route for /// generated route for
/// [_i5.ErrorPage] /// [_i5.ErrorPage]
class ErrorRoute extends _i23.PageRouteInfo<ErrorRouteArgs> { class ErrorRoute extends _i24.PageRouteInfo<ErrorRouteArgs> {
ErrorRoute({ ErrorRoute({
_i24.Key? key, _i25.Key? key,
String? title, String? title,
String? message, String? message,
_i24.VoidCallback? onRetry, _i25.VoidCallback? onRetry,
_i24.VoidCallback? onBack, _i25.VoidCallback? onBack,
String? errorCode, String? errorCode,
_i24.IconData? errorIcon, _i25.IconData? errorIcon,
List<_i23.PageRouteInfo>? children, List<_i24.PageRouteInfo>? children,
}) : super( }) : super(
ErrorRoute.name, ErrorRoute.name,
args: ErrorRouteArgs( args: ErrorRouteArgs(
@ -149,7 +152,7 @@ class ErrorRoute extends _i23.PageRouteInfo<ErrorRouteArgs> {
static const String name = 'ErrorRoute'; static const String name = 'ErrorRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
final args = data.argsAs<ErrorRouteArgs>( final args = data.argsAs<ErrorRouteArgs>(
@ -179,19 +182,19 @@ class ErrorRouteArgs {
this.errorIcon, this.errorIcon,
}); });
final _i24.Key? key; final _i25.Key? key;
final String? title; final String? title;
final String? message; final String? message;
final _i24.VoidCallback? onRetry; final _i25.VoidCallback? onRetry;
final _i24.VoidCallback? onBack; final _i25.VoidCallback? onBack;
final String? errorCode; final String? errorCode;
final _i24.IconData? errorIcon; final _i25.IconData? errorIcon;
@override @override
String toString() { String toString() {
@ -201,61 +204,61 @@ class ErrorRouteArgs {
/// generated route for /// generated route for
/// [_i6.FinancePage] /// [_i6.FinancePage]
class FinanceRoute extends _i23.PageRouteInfo<void> { class FinanceRoute extends _i24.PageRouteInfo<void> {
const FinanceRoute({List<_i23.PageRouteInfo>? children}) const FinanceRoute({List<_i24.PageRouteInfo>? children})
: super(FinanceRoute.name, initialChildren: children); : super(FinanceRoute.name, initialChildren: children);
static const String name = 'FinanceRoute'; static const String name = 'FinanceRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i23.WrappedRoute(child: const _i6.FinancePage()); return _i24.WrappedRoute(child: const _i6.FinancePage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i7.HomePage] /// [_i7.HomePage]
class HomeRoute extends _i23.PageRouteInfo<void> { class HomeRoute extends _i24.PageRouteInfo<void> {
const HomeRoute({List<_i23.PageRouteInfo>? children}) const HomeRoute({List<_i24.PageRouteInfo>? children})
: super(HomeRoute.name, initialChildren: children); : super(HomeRoute.name, initialChildren: children);
static const String name = 'HomeRoute'; static const String name = 'HomeRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i23.WrappedRoute(child: const _i7.HomePage()); return _i24.WrappedRoute(child: const _i7.HomePage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i8.InventoryPage] /// [_i8.InventoryPage]
class InventoryRoute extends _i23.PageRouteInfo<void> { class InventoryRoute extends _i24.PageRouteInfo<void> {
const InventoryRoute({List<_i23.PageRouteInfo>? children}) const InventoryRoute({List<_i24.PageRouteInfo>? children})
: super(InventoryRoute.name, initialChildren: children); : super(InventoryRoute.name, initialChildren: children);
static const String name = 'InventoryRoute'; static const String name = 'InventoryRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i23.WrappedRoute(child: const _i8.InventoryPage()); return _i24.WrappedRoute(child: const _i8.InventoryPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i9.LanguagePage] /// [_i9.LanguagePage]
class LanguageRoute extends _i23.PageRouteInfo<void> { class LanguageRoute extends _i24.PageRouteInfo<void> {
const LanguageRoute({List<_i23.PageRouteInfo>? children}) const LanguageRoute({List<_i24.PageRouteInfo>? children})
: super(LanguageRoute.name, initialChildren: children); : super(LanguageRoute.name, initialChildren: children);
static const String name = 'LanguageRoute'; static const String name = 'LanguageRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i9.LanguagePage(); return const _i9.LanguagePage();
@ -265,29 +268,29 @@ class LanguageRoute extends _i23.PageRouteInfo<void> {
/// generated route for /// generated route for
/// [_i10.LoginPage] /// [_i10.LoginPage]
class LoginRoute extends _i23.PageRouteInfo<void> { class LoginRoute extends _i24.PageRouteInfo<void> {
const LoginRoute({List<_i23.PageRouteInfo>? children}) const LoginRoute({List<_i24.PageRouteInfo>? children})
: super(LoginRoute.name, initialChildren: children); : super(LoginRoute.name, initialChildren: children);
static const String name = 'LoginRoute'; static const String name = 'LoginRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i23.WrappedRoute(child: const _i10.LoginPage()); return _i24.WrappedRoute(child: const _i10.LoginPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i11.MainPage] /// [_i11.MainPage]
class MainRoute extends _i23.PageRouteInfo<void> { class MainRoute extends _i24.PageRouteInfo<void> {
const MainRoute({List<_i23.PageRouteInfo>? children}) const MainRoute({List<_i24.PageRouteInfo>? children})
: super(MainRoute.name, initialChildren: children); : super(MainRoute.name, initialChildren: children);
static const String name = 'MainRoute'; static const String name = 'MainRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i11.MainPage(); return const _i11.MainPage();
@ -297,11 +300,11 @@ class MainRoute extends _i23.PageRouteInfo<void> {
/// generated route for /// generated route for
/// [_i12.OrderDetailPage] /// [_i12.OrderDetailPage]
class OrderDetailRoute extends _i23.PageRouteInfo<OrderDetailRouteArgs> { class OrderDetailRoute extends _i24.PageRouteInfo<OrderDetailRouteArgs> {
OrderDetailRoute({ OrderDetailRoute({
_i24.Key? key, _i25.Key? key,
required _i25.Order order, required _i26.Order order,
List<_i23.PageRouteInfo>? children, List<_i24.PageRouteInfo>? children,
}) : super( }) : super(
OrderDetailRoute.name, OrderDetailRoute.name,
args: OrderDetailRouteArgs(key: key, order: order), args: OrderDetailRouteArgs(key: key, order: order),
@ -310,7 +313,7 @@ class OrderDetailRoute extends _i23.PageRouteInfo<OrderDetailRouteArgs> {
static const String name = 'OrderDetailRoute'; static const String name = 'OrderDetailRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
final args = data.argsAs<OrderDetailRouteArgs>(); final args = data.argsAs<OrderDetailRouteArgs>();
@ -322,9 +325,9 @@ class OrderDetailRoute extends _i23.PageRouteInfo<OrderDetailRouteArgs> {
class OrderDetailRouteArgs { class OrderDetailRouteArgs {
const OrderDetailRouteArgs({this.key, required this.order}); const OrderDetailRouteArgs({this.key, required this.order});
final _i24.Key? key; final _i25.Key? key;
final _i25.Order order; final _i26.Order order;
@override @override
String toString() { String toString() {
@ -334,160 +337,197 @@ class OrderDetailRouteArgs {
/// generated route for /// generated route for
/// [_i13.OrderPage] /// [_i13.OrderPage]
class OrderRoute extends _i23.PageRouteInfo<void> { class OrderRoute extends _i24.PageRouteInfo<void> {
const OrderRoute({List<_i23.PageRouteInfo>? children}) const OrderRoute({List<_i24.PageRouteInfo>? children})
: super(OrderRoute.name, initialChildren: children); : super(OrderRoute.name, initialChildren: children);
static const String name = 'OrderRoute'; static const String name = 'OrderRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i23.WrappedRoute(child: const _i13.OrderPage()); return _i24.WrappedRoute(child: const _i13.OrderPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i14.OutletInformationPage] /// [_i14.OutletInformationPage]
class OutletInformationRoute extends _i23.PageRouteInfo<void> { class OutletInformationRoute extends _i24.PageRouteInfo<void> {
const OutletInformationRoute({List<_i23.PageRouteInfo>? children}) const OutletInformationRoute({List<_i24.PageRouteInfo>? children})
: super(OutletInformationRoute.name, initialChildren: children); : super(OutletInformationRoute.name, initialChildren: children);
static const String name = 'OutletInformationRoute'; static const String name = 'OutletInformationRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i23.WrappedRoute(child: const _i14.OutletInformationPage()); return _i24.WrappedRoute(child: const _i14.OutletInformationPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i15.ProductAnalyticPage] /// [_i15.ProductAnalyticPage]
class ProductAnalyticRoute extends _i23.PageRouteInfo<void> { class ProductAnalyticRoute extends _i24.PageRouteInfo<void> {
const ProductAnalyticRoute({List<_i23.PageRouteInfo>? children}) const ProductAnalyticRoute({List<_i24.PageRouteInfo>? children})
: super(ProductAnalyticRoute.name, initialChildren: children); : super(ProductAnalyticRoute.name, initialChildren: children);
static const String name = 'ProductAnalyticRoute'; static const String name = 'ProductAnalyticRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i23.WrappedRoute(child: const _i15.ProductAnalyticPage()); return _i24.WrappedRoute(child: const _i15.ProductAnalyticPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i16.ProductPage] /// [_i16.ProductPage]
class ProductRoute extends _i23.PageRouteInfo<void> { class ProductRoute extends _i24.PageRouteInfo<void> {
const ProductRoute({List<_i23.PageRouteInfo>? children}) const ProductRoute({List<_i24.PageRouteInfo>? children})
: super(ProductRoute.name, initialChildren: children); : super(ProductRoute.name, initialChildren: children);
static const String name = 'ProductRoute'; static const String name = 'ProductRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i23.WrappedRoute(child: const _i16.ProductPage()); return _i24.WrappedRoute(child: const _i16.ProductPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i17.ProfilePage] /// [_i17.ProfileEditPage]
class ProfileRoute extends _i23.PageRouteInfo<void> { class ProfileEditRoute extends _i24.PageRouteInfo<ProfileEditRouteArgs> {
const ProfileRoute({List<_i23.PageRouteInfo>? children}) ProfileEditRoute({
_i25.Key? key,
required _i27.User user,
List<_i24.PageRouteInfo>? children,
}) : super(
ProfileEditRoute.name,
args: ProfileEditRouteArgs(key: key, user: user),
initialChildren: children,
);
static const String name = 'ProfileEditRoute';
static _i24.PageInfo page = _i24.PageInfo(
name,
builder: (data) {
final args = data.argsAs<ProfileEditRouteArgs>();
return _i17.ProfileEditPage(key: args.key, user: args.user);
},
);
}
class ProfileEditRouteArgs {
const ProfileEditRouteArgs({this.key, required this.user});
final _i25.Key? key;
final _i27.User user;
@override
String toString() {
return 'ProfileEditRouteArgs{key: $key, user: $user}';
}
}
/// generated route for
/// [_i18.ProfilePage]
class ProfileRoute extends _i24.PageRouteInfo<void> {
const ProfileRoute({List<_i24.PageRouteInfo>? children})
: super(ProfileRoute.name, initialChildren: children); : super(ProfileRoute.name, initialChildren: children);
static const String name = 'ProfileRoute'; static const String name = 'ProfileRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i23.WrappedRoute(child: const _i17.ProfilePage()); return _i24.WrappedRoute(child: const _i18.ProfilePage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i18.PurchasePage] /// [_i19.PurchasePage]
class PurchaseRoute extends _i23.PageRouteInfo<void> { class PurchaseRoute extends _i24.PageRouteInfo<void> {
const PurchaseRoute({List<_i23.PageRouteInfo>? children}) const PurchaseRoute({List<_i24.PageRouteInfo>? children})
: super(PurchaseRoute.name, initialChildren: children); : super(PurchaseRoute.name, initialChildren: children);
static const String name = 'PurchaseRoute'; static const String name = 'PurchaseRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i18.PurchasePage(); return const _i19.PurchasePage();
}, },
); );
} }
/// generated route for /// generated route for
/// [_i19.ReportPage] /// [_i20.ReportPage]
class ReportRoute extends _i23.PageRouteInfo<void> { class ReportRoute extends _i24.PageRouteInfo<void> {
const ReportRoute({List<_i23.PageRouteInfo>? children}) const ReportRoute({List<_i24.PageRouteInfo>? children})
: super(ReportRoute.name, initialChildren: children); : super(ReportRoute.name, initialChildren: children);
static const String name = 'ReportRoute'; static const String name = 'ReportRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i23.WrappedRoute(child: const _i19.ReportPage()); return _i24.WrappedRoute(child: const _i20.ReportPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i20.SalesPage] /// [_i21.SalesPage]
class SalesRoute extends _i23.PageRouteInfo<void> { class SalesRoute extends _i24.PageRouteInfo<void> {
const SalesRoute({List<_i23.PageRouteInfo>? children}) const SalesRoute({List<_i24.PageRouteInfo>? children})
: super(SalesRoute.name, initialChildren: children); : super(SalesRoute.name, initialChildren: children);
static const String name = 'SalesRoute'; static const String name = 'SalesRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i23.WrappedRoute(child: const _i20.SalesPage()); return _i24.WrappedRoute(child: const _i21.SalesPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i21.SchedulePage] /// [_i22.SchedulePage]
class ScheduleRoute extends _i23.PageRouteInfo<void> { class ScheduleRoute extends _i24.PageRouteInfo<void> {
const ScheduleRoute({List<_i23.PageRouteInfo>? children}) const ScheduleRoute({List<_i24.PageRouteInfo>? children})
: super(ScheduleRoute.name, initialChildren: children); : super(ScheduleRoute.name, initialChildren: children);
static const String name = 'ScheduleRoute'; static const String name = 'ScheduleRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i21.SchedulePage(); return const _i22.SchedulePage();
}, },
); );
} }
/// generated route for /// generated route for
/// [_i22.SplashPage] /// [_i23.SplashPage]
class SplashRoute extends _i23.PageRouteInfo<void> { class SplashRoute extends _i24.PageRouteInfo<void> {
const SplashRoute({List<_i23.PageRouteInfo>? children}) const SplashRoute({List<_i24.PageRouteInfo>? children})
: super(SplashRoute.name, initialChildren: children); : super(SplashRoute.name, initialChildren: children);
static const String name = 'SplashRoute'; static const String name = 'SplashRoute';
static _i23.PageInfo page = _i23.PageInfo( static _i24.PageInfo page = _i24.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i22.SplashPage(); return const _i23.SplashPage();
}, },
); );
} }