feat: add OrderType enum and integrate orderType in OrderItem and ViewOrdersCubit

This commit is contained in:
Achintha Isuru
2026-02-21 20:53:27 -05:00
parent 6e50369e17
commit 6de6661394
5 changed files with 40 additions and 0 deletions

View File

@@ -1,5 +1,7 @@
import 'package:equatable/equatable.dart';
import 'order_type.dart';
/// Represents a customer's view of an order or shift.
///
/// This entity captures the details necessary for the dashboard/view orders screen,
@@ -9,6 +11,7 @@ class OrderItem extends Equatable {
const OrderItem({
required this.id,
required this.orderId,
required this.orderType,
required this.title,
required this.clientName,
required this.status,
@@ -31,6 +34,9 @@ class OrderItem extends Equatable {
/// Parent order identifier.
final String orderId;
/// The type of order (e.g., ONE_TIME, PERMANENT).
final OrderType orderType;
/// Title or name of the role.
final String title;
@@ -77,6 +83,7 @@ class OrderItem extends Equatable {
List<Object?> get props => <Object?>[
id,
orderId,
orderType,
title,
clientName,
status,

View File

@@ -0,0 +1,30 @@
/// Defines the type of an order.
enum OrderType {
/// A single occurrence shift.
oneTime,
/// A long-term or permanent staffing position.
permanent,
/// Shifts that repeat on a defined schedule.
recurring,
/// A quickly created shift.
rapid;
/// Creates an [OrderType] from a string value (typically from the backend).
static OrderType fromString(String value) {
switch (value.toUpperCase()) {
case 'ONE_TIME':
return OrderType.oneTime;
case 'PERMANENT':
return OrderType.permanent;
case 'RECURRING':
return OrderType.recurring;
case 'RAPID':
return OrderType.rapid;
default:
return OrderType.oneTime;
}
}
}