new field and enums values for break in shiftrole
This commit is contained in:
@@ -140,6 +140,7 @@ class ClientCreateOrderRepositoryImpl
|
||||
.endTime(_toTimestamp(normalizedEnd))
|
||||
.hours(hours)
|
||||
.breakType(_breakDurationFromValue(position.lunchBreak))
|
||||
.isBreakPaid(_isBreakPaid(position.lunchBreak))
|
||||
.totalValue(totalValue)
|
||||
.execute());
|
||||
}
|
||||
@@ -172,15 +173,25 @@ class ClientCreateOrderRepositoryImpl
|
||||
|
||||
dc.BreakDuration _breakDurationFromValue(String value) {
|
||||
switch (value) {
|
||||
case 'MIN_10':
|
||||
return dc.BreakDuration.MIN_10;
|
||||
case 'MIN_15':
|
||||
return dc.BreakDuration.MIN_15;
|
||||
case 'MIN_30':
|
||||
return dc.BreakDuration.MIN_30;
|
||||
case 'MIN_45':
|
||||
return dc.BreakDuration.MIN_45;
|
||||
case 'MIN_60':
|
||||
return dc.BreakDuration.MIN_60;
|
||||
default:
|
||||
return dc.BreakDuration.NO_BREAK;
|
||||
}
|
||||
}
|
||||
|
||||
bool _isBreakPaid(String value) {
|
||||
return value == 'MIN_10' || value == 'MIN_15';
|
||||
}
|
||||
|
||||
DateTime _parseTime(DateTime date, String time) {
|
||||
if (time.trim().isEmpty) {
|
||||
throw Exception('Shift time is missing.');
|
||||
|
||||
@@ -243,13 +243,24 @@ class OneTimeOrderPositionCard extends StatelessWidget {
|
||||
onUpdated(position.copyWith(lunchBreak: val));
|
||||
}
|
||||
},
|
||||
items: <String>['NO_BREAK', 'MIN_15', 'MIN_30'].map((
|
||||
items: <String>[
|
||||
'NO_BREAK',
|
||||
'MIN_10',
|
||||
'MIN_15',
|
||||
'MIN_30',
|
||||
'MIN_45',
|
||||
'MIN_60',
|
||||
].map((
|
||||
String value,
|
||||
) {
|
||||
final String label = switch (value) {
|
||||
'NO_BREAK' => 'No Break',
|
||||
'MIN_15' => '15 min',
|
||||
_ => '30 min',
|
||||
'MIN_10' => '10 min (Paid)',
|
||||
'MIN_15' => '15 min (Paid)',
|
||||
'MIN_30' => '30 min (Unpaid)',
|
||||
'MIN_45' => '45 min (Unpaid)',
|
||||
'MIN_60' => '60 min (Unpaid)',
|
||||
_ => value,
|
||||
};
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
|
||||
@@ -279,6 +279,7 @@ class _ShiftOrderFormSheetState extends State<ShiftOrderFormSheet> {
|
||||
.endTime(_toTimestamp(normalizedEnd))
|
||||
.hours(hours)
|
||||
.breakType(_breakDurationFromValue(lunchBreak))
|
||||
.isBreakPaid(_isBreakPaid(lunchBreak))
|
||||
.totalValue(totalValue)
|
||||
.execute();
|
||||
}
|
||||
@@ -527,10 +528,16 @@ class _ShiftOrderFormSheetState extends State<ShiftOrderFormSheet> {
|
||||
final dc.BreakDuration? value =
|
||||
breakType is dc.Known<dc.BreakDuration> ? breakType.value : null;
|
||||
switch (value) {
|
||||
case dc.BreakDuration.MIN_10:
|
||||
return 'MIN_10';
|
||||
case dc.BreakDuration.MIN_15:
|
||||
return 'MIN_15';
|
||||
case dc.BreakDuration.MIN_30:
|
||||
return 'MIN_30';
|
||||
case dc.BreakDuration.MIN_45:
|
||||
return 'MIN_45';
|
||||
case dc.BreakDuration.MIN_60:
|
||||
return 'MIN_60';
|
||||
case dc.BreakDuration.NO_BREAK:
|
||||
case null:
|
||||
return 'NO_BREAK';
|
||||
@@ -539,15 +546,25 @@ class _ShiftOrderFormSheetState extends State<ShiftOrderFormSheet> {
|
||||
|
||||
dc.BreakDuration _breakDurationFromValue(String value) {
|
||||
switch (value) {
|
||||
case 'MIN_10':
|
||||
return dc.BreakDuration.MIN_10;
|
||||
case 'MIN_15':
|
||||
return dc.BreakDuration.MIN_15;
|
||||
case 'MIN_30':
|
||||
return dc.BreakDuration.MIN_30;
|
||||
case 'MIN_45':
|
||||
return dc.BreakDuration.MIN_45;
|
||||
case 'MIN_60':
|
||||
return dc.BreakDuration.MIN_60;
|
||||
default:
|
||||
return dc.BreakDuration.NO_BREAK;
|
||||
}
|
||||
}
|
||||
|
||||
bool _isBreakPaid(String value) {
|
||||
return value == 'MIN_10' || value == 'MIN_15';
|
||||
}
|
||||
|
||||
dc.OrderType _orderTypeFromValue(String? value) {
|
||||
switch (value) {
|
||||
case 'PERMANENT':
|
||||
@@ -1053,15 +1070,28 @@ class _ShiftOrderFormSheetState extends State<ShiftOrderFormSheet> {
|
||||
),
|
||||
const SizedBox(height: UiConstants.space1),
|
||||
_buildDropdownField(
|
||||
hint: 'None',
|
||||
hint: 'No Break',
|
||||
value: pos['lunch_break'],
|
||||
items: <String>['NO_BREAK', 'MIN_15', 'MIN_30'],
|
||||
items: <String>[
|
||||
'NO_BREAK',
|
||||
'MIN_10',
|
||||
'MIN_15',
|
||||
'MIN_30',
|
||||
'MIN_45',
|
||||
'MIN_60',
|
||||
],
|
||||
itemBuilder: (dynamic value) {
|
||||
switch (value.toString()) {
|
||||
case 'MIN_10':
|
||||
return '10 min (Paid)';
|
||||
case 'MIN_15':
|
||||
return '15 min';
|
||||
return '15 min (Paid)';
|
||||
case 'MIN_30':
|
||||
return '30 min';
|
||||
return '30 min (Unpaid)';
|
||||
case 'MIN_45':
|
||||
return '45 min (Unpaid)';
|
||||
case 'MIN_60':
|
||||
return '60 min (Unpaid)';
|
||||
default:
|
||||
return 'No Break';
|
||||
}
|
||||
|
||||
@@ -1053,10 +1053,16 @@ class _OrderEditSheetState extends State<_OrderEditSheet> {
|
||||
final dc.BreakDuration? value =
|
||||
breakType is dc.Known<dc.BreakDuration> ? breakType.value : null;
|
||||
switch (value) {
|
||||
case dc.BreakDuration.MIN_10:
|
||||
return 'MIN_10';
|
||||
case dc.BreakDuration.MIN_15:
|
||||
return 'MIN_15';
|
||||
case dc.BreakDuration.MIN_30:
|
||||
return 'MIN_30';
|
||||
case dc.BreakDuration.MIN_45:
|
||||
return 'MIN_45';
|
||||
case dc.BreakDuration.MIN_60:
|
||||
return 'MIN_60';
|
||||
case dc.BreakDuration.NO_BREAK:
|
||||
case null:
|
||||
return 'NO_BREAK';
|
||||
@@ -1065,15 +1071,25 @@ class _OrderEditSheetState extends State<_OrderEditSheet> {
|
||||
|
||||
dc.BreakDuration _breakDurationFromValue(String value) {
|
||||
switch (value) {
|
||||
case 'MIN_10':
|
||||
return dc.BreakDuration.MIN_10;
|
||||
case 'MIN_15':
|
||||
return dc.BreakDuration.MIN_15;
|
||||
case 'MIN_30':
|
||||
return dc.BreakDuration.MIN_30;
|
||||
case 'MIN_45':
|
||||
return dc.BreakDuration.MIN_45;
|
||||
case 'MIN_60':
|
||||
return dc.BreakDuration.MIN_60;
|
||||
default:
|
||||
return dc.BreakDuration.NO_BREAK;
|
||||
}
|
||||
}
|
||||
|
||||
bool _isBreakPaid(String value) {
|
||||
return value == 'MIN_10' || value == 'MIN_15';
|
||||
}
|
||||
|
||||
_RoleOption? _roleById(String roleId) {
|
||||
for (final _RoleOption role in _roles) {
|
||||
if (role.id == roleId) {
|
||||
@@ -1209,6 +1225,7 @@ class _OrderEditSheetState extends State<_OrderEditSheet> {
|
||||
.endTime(_toTimestamp(normalizedEnd))
|
||||
.hours(hours)
|
||||
.breakType(_breakDurationFromValue(lunchBreak))
|
||||
.isBreakPaid(_isBreakPaid(lunchBreak))
|
||||
.totalValue(totalValue)
|
||||
.execute();
|
||||
} else {
|
||||
@@ -1219,6 +1236,7 @@ class _OrderEditSheetState extends State<_OrderEditSheet> {
|
||||
.endTime(_toTimestamp(normalizedEnd))
|
||||
.hours(hours)
|
||||
.breakType(_breakDurationFromValue(lunchBreak))
|
||||
.isBreakPaid(_isBreakPaid(lunchBreak))
|
||||
.totalValue(totalValue)
|
||||
.execute();
|
||||
}
|
||||
@@ -1233,6 +1251,7 @@ class _OrderEditSheetState extends State<_OrderEditSheet> {
|
||||
.endTime(_toTimestamp(normalizedEnd))
|
||||
.hours(hours)
|
||||
.breakType(_breakDurationFromValue(lunchBreak))
|
||||
.isBreakPaid(_isBreakPaid(lunchBreak))
|
||||
.totalValue(totalValue)
|
||||
.execute();
|
||||
}
|
||||
@@ -1747,17 +1766,30 @@ class _OrderEditSheetState extends State<_OrderEditSheet> {
|
||||
|
||||
_buildSectionHeader('LUNCH BREAK'),
|
||||
_buildDropdownField(
|
||||
hint: 'No break',
|
||||
hint: 'No Break',
|
||||
value: pos['lunch_break'],
|
||||
items: <String>['NO_BREAK', 'MIN_15', 'MIN_30'],
|
||||
items: <String>[
|
||||
'NO_BREAK',
|
||||
'MIN_10',
|
||||
'MIN_15',
|
||||
'MIN_30',
|
||||
'MIN_45',
|
||||
'MIN_60',
|
||||
],
|
||||
itemBuilder: (dynamic val) {
|
||||
switch (val.toString()) {
|
||||
case 'MIN_10':
|
||||
return '10 min (Paid)';
|
||||
case 'MIN_15':
|
||||
return '15 min';
|
||||
return '15 min (Paid)';
|
||||
case 'MIN_30':
|
||||
return '30 min';
|
||||
return '30 min (Unpaid)';
|
||||
case 'MIN_45':
|
||||
return '45 min (Unpaid)';
|
||||
case 'MIN_60':
|
||||
return '60 min (Unpaid)';
|
||||
default:
|
||||
return 'No break';
|
||||
return 'No Break';
|
||||
}
|
||||
},
|
||||
onChanged: (dynamic val) =>
|
||||
|
||||
@@ -9,6 +9,7 @@ mutation createShiftRole(
|
||||
$department: String
|
||||
$uniform: String
|
||||
$breakType: BreakDuration
|
||||
$isBreakPaid: Boolean
|
||||
$totalValue: Float
|
||||
) @auth(level: USER) {
|
||||
shiftRole_insert(
|
||||
@@ -23,6 +24,7 @@ mutation createShiftRole(
|
||||
department: $department
|
||||
uniform: $uniform
|
||||
breakType: $breakType
|
||||
isBreakPaid: $isBreakPaid
|
||||
totalValue: $totalValue
|
||||
}
|
||||
)
|
||||
@@ -39,6 +41,7 @@ mutation updateShiftRole(
|
||||
$department: String
|
||||
$uniform: String
|
||||
$breakType: BreakDuration
|
||||
$isBreakPaid: Boolean
|
||||
$totalValue: Float
|
||||
) @auth(level: USER) {
|
||||
shiftRole_update(
|
||||
@@ -52,6 +55,7 @@ mutation updateShiftRole(
|
||||
department: $department
|
||||
uniform: $uniform
|
||||
breakType: $breakType
|
||||
isBreakPaid: $isBreakPaid
|
||||
totalValue: $totalValue
|
||||
}
|
||||
)
|
||||
|
||||
@@ -15,6 +15,7 @@ query getShiftRoleById(
|
||||
department
|
||||
uniform
|
||||
breakType
|
||||
isBreakPaid
|
||||
totalValue
|
||||
createdAt
|
||||
|
||||
@@ -76,6 +77,7 @@ query listShiftRolesByShiftId(
|
||||
department
|
||||
uniform
|
||||
breakType
|
||||
isBreakPaid
|
||||
totalValue
|
||||
createdAt
|
||||
|
||||
@@ -132,6 +134,7 @@ query listShiftRolesByRoleId(
|
||||
department
|
||||
uniform
|
||||
breakType
|
||||
isBreakPaid
|
||||
totalValue
|
||||
createdAt
|
||||
|
||||
@@ -195,6 +198,7 @@ query listShiftRolesByShiftIdAndTimeRange(
|
||||
department
|
||||
uniform
|
||||
breakType
|
||||
isBreakPaid
|
||||
totalValue
|
||||
createdAt
|
||||
|
||||
@@ -263,6 +267,7 @@ query listShiftRolesByVendorId(
|
||||
department
|
||||
uniform
|
||||
breakType
|
||||
isBreakPaid
|
||||
totalValue
|
||||
createdAt
|
||||
|
||||
@@ -371,6 +376,7 @@ query listShiftRolesByBusinessAndOrder(
|
||||
endTime
|
||||
hours
|
||||
breakType
|
||||
isBreakPaid
|
||||
totalValue
|
||||
createdAt
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
enum BreakDuration {
|
||||
MIN_10
|
||||
MIN_15
|
||||
MIN_30
|
||||
MIN_45
|
||||
MIN_60
|
||||
NO_BREAK
|
||||
}
|
||||
|
||||
@@ -25,6 +28,7 @@ type ShiftRole @table(name: "shift_roles", key: ["shiftId", "roleId"]) {
|
||||
department: String
|
||||
uniform: String
|
||||
breakType: BreakDuration
|
||||
isBreakPaid: Boolean @default(expr: "false")
|
||||
totalValue: Float
|
||||
|
||||
createdAt: Timestamp @default(expr: "request.time")
|
||||
|
||||
Reference in New Issue
Block a user