update
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
part of '../table.dart';
|
||||
|
||||
@freezed
|
||||
class ListTable with _$ListTable {
|
||||
const factory ListTable({
|
||||
required List<Table> tables,
|
||||
required int totalCount,
|
||||
required int page,
|
||||
required int limit,
|
||||
required int totalPages,
|
||||
}) = _ListTable;
|
||||
|
||||
factory ListTable.empty() =>
|
||||
ListTable(tables: [], totalCount: 0, page: 0, limit: 0, totalPages: 0);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Table with _$Table {
|
||||
const factory Table({
|
||||
required String id,
|
||||
required String organizationId,
|
||||
required String outletId,
|
||||
required String tableName,
|
||||
required TableStatusType status,
|
||||
required int paymentAmount,
|
||||
required double positionX,
|
||||
required double positionY,
|
||||
required int capacity,
|
||||
required bool isActive,
|
||||
required DateTime createdAt,
|
||||
required DateTime updatedAt,
|
||||
}) = _Table;
|
||||
|
||||
factory Table.empty() => Table(
|
||||
id: '',
|
||||
organizationId: '',
|
||||
outletId: '',
|
||||
tableName: '',
|
||||
status: TableStatusType.unknown,
|
||||
paymentAmount: 0,
|
||||
positionX: 0.0,
|
||||
positionY: 0.0,
|
||||
capacity: 0,
|
||||
isActive: false,
|
||||
createdAt: DateTime(1970),
|
||||
updatedAt: DateTime(1970),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
part of '../table.dart';
|
||||
|
||||
@freezed
|
||||
sealed class TableFailure with _$TableFailure {
|
||||
const factory TableFailure.serverError(ApiFailure failure) = _ServerError;
|
||||
const factory TableFailure.unexpectedError() = _UnexpectedError;
|
||||
const factory TableFailure.empty() = _Empty;
|
||||
const factory TableFailure.localStorageError(String erroMessage) =
|
||||
_LocalStorageError;
|
||||
const factory TableFailure.dynamicErrorMessage(String erroMessage) =
|
||||
_DynamicErrorMessage;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
part of '../table.dart';
|
||||
|
||||
abstract class ITableRepository {
|
||||
Future<Either<TableFailure, ListTable>> fetchTables({
|
||||
int page = 1,
|
||||
int limit = 50,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import '../../common/api/api_failure.dart';
|
||||
|
||||
part 'table.freezed.dart';
|
||||
|
||||
part 'entities/table_entity.dart';
|
||||
part 'failures/table_failure.dart';
|
||||
part 'repositories/i_table_repository.dart';
|
||||
|
||||
enum TableStatusType { available, occupied, unknown }
|
||||
|
||||
extension TableStatusTypeX on TableStatusType {
|
||||
String toStringType() => switch (this) {
|
||||
TableStatusType.available => 'available',
|
||||
TableStatusType.occupied => 'occupied',
|
||||
TableStatusType.unknown => 'unknown',
|
||||
};
|
||||
|
||||
bool get isAvailable => this == TableStatusType.available;
|
||||
bool get isOccupied => this == TableStatusType.occupied;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user