2025-11-07 16:29:26 +07:00
|
|
|
part of 'print_struck_bloc.dart';
|
|
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
|
class PrintStruckState with _$PrintStruckState {
|
2026-09-02 20:44:14 +07:00
|
|
|
const PrintStruckState._();
|
|
|
|
|
|
|
|
|
|
const factory PrintStruckState({
|
|
|
|
|
/// Status seluruh station di job cetak terakhir, urut sesuai urutan cetak.
|
|
|
|
|
@Default(<PrintStationResult>[]) List<PrintStationResult> stations,
|
2025-11-07 16:29:26 +07:00
|
|
|
@Default(false) bool isPrinting,
|
2026-09-02 20:44:14 +07:00
|
|
|
|
|
|
|
|
/// Order yang sedang dicetak, disimpan supaya station yang gagal bisa
|
|
|
|
|
/// diulang tanpa perlu dikirim ulang dari halaman pemanggil.
|
|
|
|
|
Order? order,
|
|
|
|
|
|
|
|
|
|
/// Naik tiap job baru dimulai. UI memakainya untuk tahu kapan harus
|
|
|
|
|
/// membuka dialog progres.
|
|
|
|
|
@Default(0) int jobId,
|
2025-11-07 16:29:26 +07:00
|
|
|
}) = _PrintStruckState;
|
|
|
|
|
|
2026-09-02 20:44:14 +07:00
|
|
|
factory PrintStruckState.initial() => const PrintStruckState();
|
|
|
|
|
|
|
|
|
|
List<PrintStationResult> get failedStations =>
|
|
|
|
|
stations.where((station) => station.isFailed).toList();
|
|
|
|
|
|
|
|
|
|
bool get hasFailure => failedStations.isNotEmpty;
|
|
|
|
|
|
|
|
|
|
/// Station yang benar-benar dicetak — yang dilewati tidak ikut dihitung.
|
|
|
|
|
int get plannedCount =>
|
|
|
|
|
stations.where((station) => !station.isSkipped).length;
|
|
|
|
|
|
|
|
|
|
int get successCount =>
|
|
|
|
|
stations.where((station) => station.isSuccess).length;
|
2025-11-07 16:29:26 +07:00
|
|
|
}
|