Skip to content

Commit

Permalink
feat: #7/공고 수정 화면 상세 조회 추가
Browse files Browse the repository at this point in the history
1. JobPostingFormIdSet 이벤트 추가
2. JobPostingFormDetailFetched 이벤트 추가
3. 수정 화면 진입시 id 주입
  • Loading branch information
Younggun-Kim committed Oct 24, 2024
1 parent 0bb250b commit ce3c0e3
Show file tree
Hide file tree
Showing 9 changed files with 187 additions and 16 deletions.
36 changes: 32 additions & 4 deletions lib/core/router/router.gr.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:withu_app/core/core.dart';
import 'package:withu_app/feature/job_posting/domain/domain.dart';
import 'package:withu_app/feature/job_posting/domain/entities/job_posting_detail_entity.dart';

part 'job_posting_form_state.dart';

Expand Down Expand Up @@ -55,6 +56,8 @@ class JobPostingFormBloc
on<OnSelectBreakTimePaid>(_onSelectBreakTimePaid);
on<OnToggleHasMealPaid>(_onToggleHasMealPaid);
on<OnPressedSubmit>(_onPressedSubmit);
on<JobPostingFormIdSet>(_onIdSet);
on<JobPostingFormDetailFetched>(_onDetailFetched);
}

/// 공고 제목 변경 이벤트.
Expand Down Expand Up @@ -247,4 +250,40 @@ class JobPostingFormBloc
emit(state.copyWith(status: JobPostingFormStatus.initial));
}
}

/// 공고 ID 설정
void _onIdSet(
JobPostingFormIdSet event,
Emitter<JobPostingFormState> emit,
) {
emit(state.copyWith(jobPostingId: event.id));
}

/// 공고 상세 조회
void _onDetailFetched(
JobPostingFormDetailFetched event,
Emitter<JobPostingFormState> emit,
) async {
final id = state.jobPostingId;
if (id == null) {
return;
}
emit(state.copyWith(status: JobPostingFormStatus.loading));

final Either<JobPostingDetailEntity> result = await useCase.getJobPosting(
jobPostingId: id,
);

result.when(success: (JobPostingDetailEntity data) {
emit(state.copyWithEntity(
status: JobPostingFormStatus.loaded,
entity: data,
));
}, fail: (String message) {
emit(state.copyWith(
status: JobPostingFormStatus.fail,
message: message,
));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ mixin _$JobPostingFormState {
bool get hasTravelTime => throw _privateConstructorUsedError;
bool get hasBreakTime => throw _privateConstructorUsedError;
bool get isMealProvided => throw _privateConstructorUsedError;
String? get jobPostingId => throw _privateConstructorUsedError;
JobCategoryType? get category => throw _privateConstructorUsedError;
ContractType? get contractType => throw _privateConstructorUsedError;
DateTime? get contractStartDate => throw _privateConstructorUsedError;
Expand All @@ -38,6 +39,7 @@ mixin _$JobPostingFormState {
PayType? get payType => throw _privateConstructorUsedError;
bool? get isTravelTimePaid => throw _privateConstructorUsedError;
bool? get isBreakTimePaid => throw _privateConstructorUsedError;
String? get message => throw _privateConstructorUsedError;

/// Create a copy of JobPostingFormState
/// with the given fields replaced by the non-null parameter values.
Expand Down Expand Up @@ -66,6 +68,7 @@ abstract class $JobPostingFormStateCopyWith<$Res> {
bool hasTravelTime,
bool hasBreakTime,
bool isMealProvided,
String? jobPostingId,
JobCategoryType? category,
ContractType? contractType,
DateTime? contractStartDate,
Expand All @@ -74,7 +77,8 @@ abstract class $JobPostingFormStateCopyWith<$Res> {
DateTime? workEndTime,
PayType? payType,
bool? isTravelTimePaid,
bool? isBreakTimePaid});
bool? isBreakTimePaid,
String? message});
}

/// @nodoc
Expand Down Expand Up @@ -105,6 +109,7 @@ class _$JobPostingFormStateCopyWithImpl<$Res, $Val extends JobPostingFormState>
Object? hasTravelTime = null,
Object? hasBreakTime = null,
Object? isMealProvided = null,
Object? jobPostingId = freezed,
Object? category = freezed,
Object? contractType = freezed,
Object? contractStartDate = freezed,
Expand All @@ -114,6 +119,7 @@ class _$JobPostingFormStateCopyWithImpl<$Res, $Val extends JobPostingFormState>
Object? payType = freezed,
Object? isTravelTimePaid = freezed,
Object? isBreakTimePaid = freezed,
Object? message = freezed,
}) {
return _then(_value.copyWith(
status: null == status
Expand Down Expand Up @@ -168,6 +174,10 @@ class _$JobPostingFormStateCopyWithImpl<$Res, $Val extends JobPostingFormState>
? _value.isMealProvided
: isMealProvided // ignore: cast_nullable_to_non_nullable
as bool,
jobPostingId: freezed == jobPostingId
? _value.jobPostingId
: jobPostingId // ignore: cast_nullable_to_non_nullable
as String?,
category: freezed == category
? _value.category
: category // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -204,6 +214,10 @@ class _$JobPostingFormStateCopyWithImpl<$Res, $Val extends JobPostingFormState>
? _value.isBreakTimePaid
: isBreakTimePaid // ignore: cast_nullable_to_non_nullable
as bool?,
message: freezed == message
? _value.message
: message // ignore: cast_nullable_to_non_nullable
as String?,
) as $Val);
}
}
Expand All @@ -230,6 +244,7 @@ abstract class _$$JobPostingFormStateImplCopyWith<$Res>
bool hasTravelTime,
bool hasBreakTime,
bool isMealProvided,
String? jobPostingId,
JobCategoryType? category,
ContractType? contractType,
DateTime? contractStartDate,
Expand All @@ -238,7 +253,8 @@ abstract class _$$JobPostingFormStateImplCopyWith<$Res>
DateTime? workEndTime,
PayType? payType,
bool? isTravelTimePaid,
bool? isBreakTimePaid});
bool? isBreakTimePaid,
String? message});
}

/// @nodoc
Expand Down Expand Up @@ -267,6 +283,7 @@ class __$$JobPostingFormStateImplCopyWithImpl<$Res>
Object? hasTravelTime = null,
Object? hasBreakTime = null,
Object? isMealProvided = null,
Object? jobPostingId = freezed,
Object? category = freezed,
Object? contractType = freezed,
Object? contractStartDate = freezed,
Expand All @@ -276,6 +293,7 @@ class __$$JobPostingFormStateImplCopyWithImpl<$Res>
Object? payType = freezed,
Object? isTravelTimePaid = freezed,
Object? isBreakTimePaid = freezed,
Object? message = freezed,
}) {
return _then(_$JobPostingFormStateImpl(
status: null == status
Expand Down Expand Up @@ -330,6 +348,10 @@ class __$$JobPostingFormStateImplCopyWithImpl<$Res>
? _value.isMealProvided
: isMealProvided // ignore: cast_nullable_to_non_nullable
as bool,
jobPostingId: freezed == jobPostingId
? _value.jobPostingId
: jobPostingId // ignore: cast_nullable_to_non_nullable
as String?,
category: freezed == category
? _value.category
: category // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -366,6 +388,10 @@ class __$$JobPostingFormStateImplCopyWithImpl<$Res>
? _value.isBreakTimePaid
: isBreakTimePaid // ignore: cast_nullable_to_non_nullable
as bool?,
message: freezed == message
? _value.message
: message // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
Expand All @@ -387,6 +413,7 @@ class _$JobPostingFormStateImpl implements _JobPostingFormState {
required this.hasTravelTime,
required this.hasBreakTime,
required this.isMealProvided,
this.jobPostingId,
this.category,
this.contractType,
this.contractStartDate,
Expand All @@ -395,7 +422,8 @@ class _$JobPostingFormStateImpl implements _JobPostingFormState {
this.workEndTime,
this.payType,
this.isTravelTimePaid,
this.isBreakTimePaid});
this.isBreakTimePaid,
this.message});

@override
final JobPostingFormStatus status;
Expand Down Expand Up @@ -424,6 +452,8 @@ class _$JobPostingFormStateImpl implements _JobPostingFormState {
@override
final bool isMealProvided;
@override
final String? jobPostingId;
@override
final JobCategoryType? category;
@override
final ContractType? contractType;
Expand All @@ -441,10 +471,12 @@ class _$JobPostingFormStateImpl implements _JobPostingFormState {
final bool? isTravelTimePaid;
@override
final bool? isBreakTimePaid;
@override
final String? message;

@override
String toString() {
return 'JobPostingFormState(status: $status, title: $title, content: $content, isVisibleStartCalendar: $isVisibleStartCalendar, isVisibleEndCalendar: $isVisibleEndCalendar, isTBC: $isTBC, participants: $participants, pay: $pay, address: $address, preferredQualifications: $preferredQualifications, hasTravelTime: $hasTravelTime, hasBreakTime: $hasBreakTime, isMealProvided: $isMealProvided, category: $category, contractType: $contractType, contractStartDate: $contractStartDate, contractEndDate: $contractEndDate, workStartTime: $workStartTime, workEndTime: $workEndTime, payType: $payType, isTravelTimePaid: $isTravelTimePaid, isBreakTimePaid: $isBreakTimePaid)';
return 'JobPostingFormState(status: $status, title: $title, content: $content, isVisibleStartCalendar: $isVisibleStartCalendar, isVisibleEndCalendar: $isVisibleEndCalendar, isTBC: $isTBC, participants: $participants, pay: $pay, address: $address, preferredQualifications: $preferredQualifications, hasTravelTime: $hasTravelTime, hasBreakTime: $hasBreakTime, isMealProvided: $isMealProvided, jobPostingId: $jobPostingId, category: $category, contractType: $contractType, contractStartDate: $contractStartDate, contractEndDate: $contractEndDate, workStartTime: $workStartTime, workEndTime: $workEndTime, payType: $payType, isTravelTimePaid: $isTravelTimePaid, isBreakTimePaid: $isBreakTimePaid, message: $message)';
}

@override
Expand Down Expand Up @@ -473,6 +505,8 @@ class _$JobPostingFormStateImpl implements _JobPostingFormState {
other.hasBreakTime == hasBreakTime) &&
(identical(other.isMealProvided, isMealProvided) ||
other.isMealProvided == isMealProvided) &&
(identical(other.jobPostingId, jobPostingId) ||
other.jobPostingId == jobPostingId) &&
(identical(other.category, category) ||
other.category == category) &&
(identical(other.contractType, contractType) ||
Expand All @@ -489,7 +523,8 @@ class _$JobPostingFormStateImpl implements _JobPostingFormState {
(identical(other.isTravelTimePaid, isTravelTimePaid) ||
other.isTravelTimePaid == isTravelTimePaid) &&
(identical(other.isBreakTimePaid, isBreakTimePaid) ||
other.isBreakTimePaid == isBreakTimePaid));
other.isBreakTimePaid == isBreakTimePaid) &&
(identical(other.message, message) || other.message == message));
}

@override
Expand All @@ -508,6 +543,7 @@ class _$JobPostingFormStateImpl implements _JobPostingFormState {
hasTravelTime,
hasBreakTime,
isMealProvided,
jobPostingId,
category,
contractType,
contractStartDate,
Expand All @@ -516,7 +552,8 @@ class _$JobPostingFormStateImpl implements _JobPostingFormState {
workEndTime,
payType,
isTravelTimePaid,
isBreakTimePaid
isBreakTimePaid,
message
]);

/// Create a copy of JobPostingFormState
Expand Down Expand Up @@ -544,6 +581,7 @@ abstract class _JobPostingFormState implements JobPostingFormState {
required final bool hasTravelTime,
required final bool hasBreakTime,
required final bool isMealProvided,
final String? jobPostingId,
final JobCategoryType? category,
final ContractType? contractType,
final DateTime? contractStartDate,
Expand All @@ -552,7 +590,8 @@ abstract class _JobPostingFormState implements JobPostingFormState {
final DateTime? workEndTime,
final PayType? payType,
final bool? isTravelTimePaid,
final bool? isBreakTimePaid}) = _$JobPostingFormStateImpl;
final bool? isBreakTimePaid,
final String? message}) = _$JobPostingFormStateImpl;

@override
JobPostingFormStatus get status;
Expand Down Expand Up @@ -581,6 +620,8 @@ abstract class _JobPostingFormState implements JobPostingFormState {
@override
bool get isMealProvided;
@override
String? get jobPostingId;
@override
JobCategoryType? get category;
@override
ContractType? get contractType;
Expand All @@ -598,6 +639,8 @@ abstract class _JobPostingFormState implements JobPostingFormState {
bool? get isTravelTimePaid;
@override
bool? get isBreakTimePaid;
@override
String? get message;

/// Create a copy of JobPostingFormState
/// with the given fields replaced by the non-null parameter values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,19 @@ class OnPressedSubmit extends JobPostingFormEvent {
@override
List<Object?> get props => [];
}

/// 공고 Id 저장
class JobPostingFormIdSet extends JobPostingFormEvent {
final String? id;

JobPostingFormIdSet({required this.id});

@override
List<Object?> get props => [id];
}

/// 상세 조회 이벤트
class JobPostingFormDetailFetched extends JobPostingFormEvent {
@override
List<Object?> get props => [];
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
part of 'job_posting_form_bloc.dart';

enum JobPostingFormStatus { initial, loading, success }
enum JobPostingFormStatus { initial, loading, loaded, success, fail }

extension JobPostingFormStatusExt on JobPostingFormStatus {
bool get isSuccess => this == JobPostingFormStatus.success;
Expand All @@ -24,6 +24,7 @@ class JobPostingFormState with _$JobPostingFormState {
required bool hasTravelTime,
required bool hasBreakTime,
required bool isMealProvided,
String? jobPostingId,
JobCategoryType? category,
ContractType? contractType,
DateTime? contractStartDate,
Expand All @@ -33,6 +34,7 @@ class JobPostingFormState with _$JobPostingFormState {
PayType? payType,
bool? isTravelTimePaid,
bool? isBreakTimePaid,
String? message,
}) = _JobPostingFormState;

}
Loading

0 comments on commit ce3c0e3

Please sign in to comment.