feat: profit sharing
Build & Deploy iOS to TestFlight / build-and-deploy (push) Canceled after 0s

This commit is contained in:
efrilm
2026-08-21 22:31:54 +07:00
parent f9bfb69254
commit 2e4c77888e
48 changed files with 12553 additions and 162 deletions
@@ -0,0 +1,65 @@
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/analytic/analytic.dart';
import '../../../domain/analytic/repositories/i_analytic_repository.dart';
part 'profit_sharing_detail_loader_event.dart';
part 'profit_sharing_detail_loader_state.dart';
part 'profit_sharing_detail_loader_bloc.freezed.dart';
@injectable
class ProfitSharingDetailLoaderBloc
extends
Bloc<ProfitSharingDetailLoaderEvent, ProfitSharingDetailLoaderState> {
final IAnalyticRepository _repository;
ProfitSharingDetailLoaderBloc(this._repository)
: super(ProfitSharingDetailLoaderState.initial()) {
on<ProfitSharingDetailLoaderEvent>(_onProfitSharingDetailLoaderEvent);
}
Future<void> _onProfitSharingDetailLoaderEvent(
ProfitSharingDetailLoaderEvent event,
Emitter<ProfitSharingDetailLoaderState> emit,
) {
return event.map(
expandedCategoryChanged: (e) async {
final isSame = state.expandedCategoryId == e.categoryId;
emit(state.copyWith(expandedCategoryId: isSame ? '' : e.categoryId));
},
fetched: (e) async {
emit(
state.copyWith(
isFetching: true,
failureOption: none(),
parentCategoryId: e.parentCategoryId,
dateFrom: e.dateFrom,
dateTo: e.dateTo,
),
);
final result = await _repository.getProfitSharingDetail(
parentCategoryId: e.parentCategoryId,
dateFrom: e.dateFrom,
dateTo: e.dateTo,
);
final newState = result.fold(
(f) => state.copyWith(failureOption: optionOf(f)),
(detail) => state.copyWith(
detail: detail,
// Sub kategori pertama langsung terbuka supaya produknya kelihatan.
expandedCategoryId: detail.categories.isEmpty
? ''
: detail.categories.first.categoryId,
),
);
emit(newState.copyWith(isFetching: false));
},
);
}
}
@@ -0,0 +1,772 @@
// 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 'profit_sharing_detail_loader_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 _$ProfitSharingDetailLoaderEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(
String parentCategoryId,
DateTime dateFrom,
DateTime dateTo,
)
fetched,
required TResult Function(String categoryId) expandedCategoryChanged,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(
String parentCategoryId,
DateTime dateFrom,
DateTime dateTo,
)?
fetched,
TResult? Function(String categoryId)? expandedCategoryChanged,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(
String parentCategoryId,
DateTime dateFrom,
DateTime dateTo,
)?
fetched,
TResult Function(String categoryId)? expandedCategoryChanged,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Fetched value) fetched,
required TResult Function(_ExpandedCategoryChanged value)
expandedCategoryChanged,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Fetched value)? fetched,
TResult? Function(_ExpandedCategoryChanged value)? expandedCategoryChanged,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Fetched value)? fetched,
TResult Function(_ExpandedCategoryChanged value)? expandedCategoryChanged,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ProfitSharingDetailLoaderEventCopyWith<$Res> {
factory $ProfitSharingDetailLoaderEventCopyWith(
ProfitSharingDetailLoaderEvent value,
$Res Function(ProfitSharingDetailLoaderEvent) then,
) =
_$ProfitSharingDetailLoaderEventCopyWithImpl<
$Res,
ProfitSharingDetailLoaderEvent
>;
}
/// @nodoc
class _$ProfitSharingDetailLoaderEventCopyWithImpl<
$Res,
$Val extends ProfitSharingDetailLoaderEvent
>
implements $ProfitSharingDetailLoaderEventCopyWith<$Res> {
_$ProfitSharingDetailLoaderEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ProfitSharingDetailLoaderEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$FetchedImplCopyWith<$Res> {
factory _$$FetchedImplCopyWith(
_$FetchedImpl value,
$Res Function(_$FetchedImpl) then,
) = __$$FetchedImplCopyWithImpl<$Res>;
@useResult
$Res call({String parentCategoryId, DateTime dateFrom, DateTime dateTo});
}
/// @nodoc
class __$$FetchedImplCopyWithImpl<$Res>
extends _$ProfitSharingDetailLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
implements _$$FetchedImplCopyWith<$Res> {
__$$FetchedImplCopyWithImpl(
_$FetchedImpl _value,
$Res Function(_$FetchedImpl) _then,
) : super(_value, _then);
/// Create a copy of ProfitSharingDetailLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? parentCategoryId = null,
Object? dateFrom = null,
Object? dateTo = null,
}) {
return _then(
_$FetchedImpl(
parentCategoryId: null == parentCategoryId
? _value.parentCategoryId
: parentCategoryId // ignore: cast_nullable_to_non_nullable
as String,
dateFrom: null == dateFrom
? _value.dateFrom
: dateFrom // ignore: cast_nullable_to_non_nullable
as DateTime,
dateTo: null == dateTo
? _value.dateTo
: dateTo // ignore: cast_nullable_to_non_nullable
as DateTime,
),
);
}
}
/// @nodoc
class _$FetchedImpl implements _Fetched {
const _$FetchedImpl({
required this.parentCategoryId,
required this.dateFrom,
required this.dateTo,
});
@override
final String parentCategoryId;
@override
final DateTime dateFrom;
@override
final DateTime dateTo;
@override
String toString() {
return 'ProfitSharingDetailLoaderEvent.fetched(parentCategoryId: $parentCategoryId, dateFrom: $dateFrom, dateTo: $dateTo)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$FetchedImpl &&
(identical(other.parentCategoryId, parentCategoryId) ||
other.parentCategoryId == parentCategoryId) &&
(identical(other.dateFrom, dateFrom) ||
other.dateFrom == dateFrom) &&
(identical(other.dateTo, dateTo) || other.dateTo == dateTo));
}
@override
int get hashCode =>
Object.hash(runtimeType, parentCategoryId, dateFrom, dateTo);
/// Create a copy of ProfitSharingDetailLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(
String parentCategoryId,
DateTime dateFrom,
DateTime dateTo,
)
fetched,
required TResult Function(String categoryId) expandedCategoryChanged,
}) {
return fetched(parentCategoryId, dateFrom, dateTo);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(
String parentCategoryId,
DateTime dateFrom,
DateTime dateTo,
)?
fetched,
TResult? Function(String categoryId)? expandedCategoryChanged,
}) {
return fetched?.call(parentCategoryId, dateFrom, dateTo);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(
String parentCategoryId,
DateTime dateFrom,
DateTime dateTo,
)?
fetched,
TResult Function(String categoryId)? expandedCategoryChanged,
required TResult orElse(),
}) {
if (fetched != null) {
return fetched(parentCategoryId, dateFrom, dateTo);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Fetched value) fetched,
required TResult Function(_ExpandedCategoryChanged value)
expandedCategoryChanged,
}) {
return fetched(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Fetched value)? fetched,
TResult? Function(_ExpandedCategoryChanged value)? expandedCategoryChanged,
}) {
return fetched?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Fetched value)? fetched,
TResult Function(_ExpandedCategoryChanged value)? expandedCategoryChanged,
required TResult orElse(),
}) {
if (fetched != null) {
return fetched(this);
}
return orElse();
}
}
abstract class _Fetched implements ProfitSharingDetailLoaderEvent {
const factory _Fetched({
required final String parentCategoryId,
required final DateTime dateFrom,
required final DateTime dateTo,
}) = _$FetchedImpl;
String get parentCategoryId;
DateTime get dateFrom;
DateTime get dateTo;
/// Create a copy of ProfitSharingDetailLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$ExpandedCategoryChangedImplCopyWith<$Res> {
factory _$$ExpandedCategoryChangedImplCopyWith(
_$ExpandedCategoryChangedImpl value,
$Res Function(_$ExpandedCategoryChangedImpl) then,
) = __$$ExpandedCategoryChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String categoryId});
}
/// @nodoc
class __$$ExpandedCategoryChangedImplCopyWithImpl<$Res>
extends
_$ProfitSharingDetailLoaderEventCopyWithImpl<
$Res,
_$ExpandedCategoryChangedImpl
>
implements _$$ExpandedCategoryChangedImplCopyWith<$Res> {
__$$ExpandedCategoryChangedImplCopyWithImpl(
_$ExpandedCategoryChangedImpl _value,
$Res Function(_$ExpandedCategoryChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of ProfitSharingDetailLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? categoryId = null}) {
return _then(
_$ExpandedCategoryChangedImpl(
null == categoryId
? _value.categoryId
: categoryId // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$ExpandedCategoryChangedImpl implements _ExpandedCategoryChanged {
const _$ExpandedCategoryChangedImpl(this.categoryId);
@override
final String categoryId;
@override
String toString() {
return 'ProfitSharingDetailLoaderEvent.expandedCategoryChanged(categoryId: $categoryId)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ExpandedCategoryChangedImpl &&
(identical(other.categoryId, categoryId) ||
other.categoryId == categoryId));
}
@override
int get hashCode => Object.hash(runtimeType, categoryId);
/// Create a copy of ProfitSharingDetailLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ExpandedCategoryChangedImplCopyWith<_$ExpandedCategoryChangedImpl>
get copyWith =>
__$$ExpandedCategoryChangedImplCopyWithImpl<
_$ExpandedCategoryChangedImpl
>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(
String parentCategoryId,
DateTime dateFrom,
DateTime dateTo,
)
fetched,
required TResult Function(String categoryId) expandedCategoryChanged,
}) {
return expandedCategoryChanged(categoryId);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(
String parentCategoryId,
DateTime dateFrom,
DateTime dateTo,
)?
fetched,
TResult? Function(String categoryId)? expandedCategoryChanged,
}) {
return expandedCategoryChanged?.call(categoryId);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(
String parentCategoryId,
DateTime dateFrom,
DateTime dateTo,
)?
fetched,
TResult Function(String categoryId)? expandedCategoryChanged,
required TResult orElse(),
}) {
if (expandedCategoryChanged != null) {
return expandedCategoryChanged(categoryId);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Fetched value) fetched,
required TResult Function(_ExpandedCategoryChanged value)
expandedCategoryChanged,
}) {
return expandedCategoryChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Fetched value)? fetched,
TResult? Function(_ExpandedCategoryChanged value)? expandedCategoryChanged,
}) {
return expandedCategoryChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Fetched value)? fetched,
TResult Function(_ExpandedCategoryChanged value)? expandedCategoryChanged,
required TResult orElse(),
}) {
if (expandedCategoryChanged != null) {
return expandedCategoryChanged(this);
}
return orElse();
}
}
abstract class _ExpandedCategoryChanged
implements ProfitSharingDetailLoaderEvent {
const factory _ExpandedCategoryChanged(final String categoryId) =
_$ExpandedCategoryChangedImpl;
String get categoryId;
/// Create a copy of ProfitSharingDetailLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ExpandedCategoryChangedImplCopyWith<_$ExpandedCategoryChangedImpl>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$ProfitSharingDetailLoaderState {
ProfitSharingDetail get detail => throw _privateConstructorUsedError;
Option<AnalyticFailure> get failureOption =>
throw _privateConstructorUsedError;
bool get isFetching => throw _privateConstructorUsedError;
String get parentCategoryId => throw _privateConstructorUsedError;
String get expandedCategoryId => throw _privateConstructorUsedError;
DateTime get dateFrom => throw _privateConstructorUsedError;
DateTime get dateTo => throw _privateConstructorUsedError;
/// Create a copy of ProfitSharingDetailLoaderState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ProfitSharingDetailLoaderStateCopyWith<ProfitSharingDetailLoaderState>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ProfitSharingDetailLoaderStateCopyWith<$Res> {
factory $ProfitSharingDetailLoaderStateCopyWith(
ProfitSharingDetailLoaderState value,
$Res Function(ProfitSharingDetailLoaderState) then,
) =
_$ProfitSharingDetailLoaderStateCopyWithImpl<
$Res,
ProfitSharingDetailLoaderState
>;
@useResult
$Res call({
ProfitSharingDetail detail,
Option<AnalyticFailure> failureOption,
bool isFetching,
String parentCategoryId,
String expandedCategoryId,
DateTime dateFrom,
DateTime dateTo,
});
$ProfitSharingDetailCopyWith<$Res> get detail;
}
/// @nodoc
class _$ProfitSharingDetailLoaderStateCopyWithImpl<
$Res,
$Val extends ProfitSharingDetailLoaderState
>
implements $ProfitSharingDetailLoaderStateCopyWith<$Res> {
_$ProfitSharingDetailLoaderStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ProfitSharingDetailLoaderState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? detail = null,
Object? failureOption = null,
Object? isFetching = null,
Object? parentCategoryId = null,
Object? expandedCategoryId = null,
Object? dateFrom = null,
Object? dateTo = null,
}) {
return _then(
_value.copyWith(
detail: null == detail
? _value.detail
: detail // ignore: cast_nullable_to_non_nullable
as ProfitSharingDetail,
failureOption: null == failureOption
? _value.failureOption
: failureOption // ignore: cast_nullable_to_non_nullable
as Option<AnalyticFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
parentCategoryId: null == parentCategoryId
? _value.parentCategoryId
: parentCategoryId // ignore: cast_nullable_to_non_nullable
as String,
expandedCategoryId: null == expandedCategoryId
? _value.expandedCategoryId
: expandedCategoryId // ignore: cast_nullable_to_non_nullable
as String,
dateFrom: null == dateFrom
? _value.dateFrom
: dateFrom // ignore: cast_nullable_to_non_nullable
as DateTime,
dateTo: null == dateTo
? _value.dateTo
: dateTo // ignore: cast_nullable_to_non_nullable
as DateTime,
)
as $Val,
);
}
/// Create a copy of ProfitSharingDetailLoaderState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$ProfitSharingDetailCopyWith<$Res> get detail {
return $ProfitSharingDetailCopyWith<$Res>(_value.detail, (value) {
return _then(_value.copyWith(detail: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$ProfitSharingDetailLoaderStateImplCopyWith<$Res>
implements $ProfitSharingDetailLoaderStateCopyWith<$Res> {
factory _$$ProfitSharingDetailLoaderStateImplCopyWith(
_$ProfitSharingDetailLoaderStateImpl value,
$Res Function(_$ProfitSharingDetailLoaderStateImpl) then,
) = __$$ProfitSharingDetailLoaderStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
ProfitSharingDetail detail,
Option<AnalyticFailure> failureOption,
bool isFetching,
String parentCategoryId,
String expandedCategoryId,
DateTime dateFrom,
DateTime dateTo,
});
@override
$ProfitSharingDetailCopyWith<$Res> get detail;
}
/// @nodoc
class __$$ProfitSharingDetailLoaderStateImplCopyWithImpl<$Res>
extends
_$ProfitSharingDetailLoaderStateCopyWithImpl<
$Res,
_$ProfitSharingDetailLoaderStateImpl
>
implements _$$ProfitSharingDetailLoaderStateImplCopyWith<$Res> {
__$$ProfitSharingDetailLoaderStateImplCopyWithImpl(
_$ProfitSharingDetailLoaderStateImpl _value,
$Res Function(_$ProfitSharingDetailLoaderStateImpl) _then,
) : super(_value, _then);
/// Create a copy of ProfitSharingDetailLoaderState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? detail = null,
Object? failureOption = null,
Object? isFetching = null,
Object? parentCategoryId = null,
Object? expandedCategoryId = null,
Object? dateFrom = null,
Object? dateTo = null,
}) {
return _then(
_$ProfitSharingDetailLoaderStateImpl(
detail: null == detail
? _value.detail
: detail // ignore: cast_nullable_to_non_nullable
as ProfitSharingDetail,
failureOption: null == failureOption
? _value.failureOption
: failureOption // ignore: cast_nullable_to_non_nullable
as Option<AnalyticFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
parentCategoryId: null == parentCategoryId
? _value.parentCategoryId
: parentCategoryId // ignore: cast_nullable_to_non_nullable
as String,
expandedCategoryId: null == expandedCategoryId
? _value.expandedCategoryId
: expandedCategoryId // ignore: cast_nullable_to_non_nullable
as String,
dateFrom: null == dateFrom
? _value.dateFrom
: dateFrom // ignore: cast_nullable_to_non_nullable
as DateTime,
dateTo: null == dateTo
? _value.dateTo
: dateTo // ignore: cast_nullable_to_non_nullable
as DateTime,
),
);
}
}
/// @nodoc
class _$ProfitSharingDetailLoaderStateImpl
extends _ProfitSharingDetailLoaderState {
const _$ProfitSharingDetailLoaderStateImpl({
required this.detail,
required this.failureOption,
this.isFetching = false,
this.parentCategoryId = '',
this.expandedCategoryId = '',
required this.dateFrom,
required this.dateTo,
}) : super._();
@override
final ProfitSharingDetail detail;
@override
final Option<AnalyticFailure> failureOption;
@override
@JsonKey()
final bool isFetching;
@override
@JsonKey()
final String parentCategoryId;
@override
@JsonKey()
final String expandedCategoryId;
@override
final DateTime dateFrom;
@override
final DateTime dateTo;
@override
String toString() {
return 'ProfitSharingDetailLoaderState(detail: $detail, failureOption: $failureOption, isFetching: $isFetching, parentCategoryId: $parentCategoryId, expandedCategoryId: $expandedCategoryId, dateFrom: $dateFrom, dateTo: $dateTo)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ProfitSharingDetailLoaderStateImpl &&
(identical(other.detail, detail) || other.detail == detail) &&
(identical(other.failureOption, failureOption) ||
other.failureOption == failureOption) &&
(identical(other.isFetching, isFetching) ||
other.isFetching == isFetching) &&
(identical(other.parentCategoryId, parentCategoryId) ||
other.parentCategoryId == parentCategoryId) &&
(identical(other.expandedCategoryId, expandedCategoryId) ||
other.expandedCategoryId == expandedCategoryId) &&
(identical(other.dateFrom, dateFrom) ||
other.dateFrom == dateFrom) &&
(identical(other.dateTo, dateTo) || other.dateTo == dateTo));
}
@override
int get hashCode => Object.hash(
runtimeType,
detail,
failureOption,
isFetching,
parentCategoryId,
expandedCategoryId,
dateFrom,
dateTo,
);
/// Create a copy of ProfitSharingDetailLoaderState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ProfitSharingDetailLoaderStateImplCopyWith<
_$ProfitSharingDetailLoaderStateImpl
>
get copyWith =>
__$$ProfitSharingDetailLoaderStateImplCopyWithImpl<
_$ProfitSharingDetailLoaderStateImpl
>(this, _$identity);
}
abstract class _ProfitSharingDetailLoaderState
extends ProfitSharingDetailLoaderState {
const factory _ProfitSharingDetailLoaderState({
required final ProfitSharingDetail detail,
required final Option<AnalyticFailure> failureOption,
final bool isFetching,
final String parentCategoryId,
final String expandedCategoryId,
required final DateTime dateFrom,
required final DateTime dateTo,
}) = _$ProfitSharingDetailLoaderStateImpl;
const _ProfitSharingDetailLoaderState._() : super._();
@override
ProfitSharingDetail get detail;
@override
Option<AnalyticFailure> get failureOption;
@override
bool get isFetching;
@override
String get parentCategoryId;
@override
String get expandedCategoryId;
@override
DateTime get dateFrom;
@override
DateTime get dateTo;
/// Create a copy of ProfitSharingDetailLoaderState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ProfitSharingDetailLoaderStateImplCopyWith<
_$ProfitSharingDetailLoaderStateImpl
>
get copyWith => throw _privateConstructorUsedError;
}
@@ -0,0 +1,15 @@
part of 'profit_sharing_detail_loader_bloc.dart';
@freezed
class ProfitSharingDetailLoaderEvent with _$ProfitSharingDetailLoaderEvent {
const factory ProfitSharingDetailLoaderEvent.fetched({
required String parentCategoryId,
required DateTime dateFrom,
required DateTime dateTo,
}) = _Fetched;
/// Buka/tutup daftar produk pada satu sub kategori.
const factory ProfitSharingDetailLoaderEvent.expandedCategoryChanged(
String categoryId,
) = _ExpandedCategoryChanged;
}
@@ -0,0 +1,28 @@
part of 'profit_sharing_detail_loader_bloc.dart';
@freezed
class ProfitSharingDetailLoaderState with _$ProfitSharingDetailLoaderState {
const ProfitSharingDetailLoaderState._();
const factory ProfitSharingDetailLoaderState({
required ProfitSharingDetail detail,
required Option<AnalyticFailure> failureOption,
@Default(false) bool isFetching,
@Default('') String parentCategoryId,
@Default('') String expandedCategoryId,
required DateTime dateFrom,
required DateTime dateTo,
}) = _ProfitSharingDetailLoaderState;
factory ProfitSharingDetailLoaderState.initial() {
final now = DateTime.now();
return ProfitSharingDetailLoaderState(
detail: ProfitSharingDetail.empty(),
failureOption: none(),
dateFrom: DateTime(now.year, now.month, 1),
dateTo: DateTime(now.year, now.month + 1, 0),
);
}
bool isExpanded(String categoryId) => expandedCategoryId == categoryId;
}