feat: update shift action buttons to conditionally display decline and book options based on shift status

This commit is contained in:
Achintha Isuru
2026-02-01 12:54:50 -05:00
parent 54f28a85ce
commit 6d70bcc5d0

View File

@@ -443,50 +443,60 @@ class ShiftDetailsPage extends StatelessWidget {
), ),
], ],
const SizedBox(height: 20), const SizedBox(height: 20),
Row( if (displayShift!.status != 'confirmed' &&
children: [ (displayShift!.hasApplied == true ||
Expanded(
child: OutlinedButton(
onPressed: () =>
_declineShift(context, displayShift!.id),
style: OutlinedButton.styleFrom(
foregroundColor: const Color(0xFFEF4444),
side: const BorderSide(
color: Color(0xFFEF4444),
),
padding: const EdgeInsets.symmetric(
vertical: 16,
),
),
child: const Text("Decline"),
),
),
const SizedBox(width: 16),
if ((displayShift!.hasApplied != true) &&
(displayShift!.requiredSlots == null || (displayShift!.requiredSlots == null ||
displayShift!.filledSlots == null || displayShift!.filledSlots == null ||
displayShift!.filledSlots! < displayShift!.filledSlots! <
displayShift!.requiredSlots!)) displayShift!.requiredSlots!)))
Row(
children: [
Expanded( Expanded(
child: ElevatedButton( child: OutlinedButton(
onPressed: () => _bookShift( onPressed: () => _declineShift(
context, context,
displayShift!.id, displayShift!.id,
displayShift!.roleId,
DateTime.tryParse(displayShift!.date),
), ),
style: ElevatedButton.styleFrom( style: OutlinedButton.styleFrom(
backgroundColor: const Color(0xFF10B981), foregroundColor: const Color(0xFFEF4444),
foregroundColor: Colors.white, side: const BorderSide(
color: Color(0xFFEF4444),
),
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
vertical: 16, vertical: 16,
), ),
), ),
child: const Text("Book Shift"), child: const Text("Decline"),
), ),
), ),
], const SizedBox(width: 16),
), if ((displayShift!.hasApplied != true) &&
(displayShift!.requiredSlots == null ||
displayShift!.filledSlots == null ||
displayShift!.filledSlots! <
displayShift!.requiredSlots!))
Expanded(
child: ElevatedButton(
onPressed: () => _bookShift(
context,
displayShift!.id,
displayShift!.roleId,
DateTime.tryParse(displayShift!.date),
),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(
0xFF10B981,
),
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(
vertical: 16,
),
),
child: const Text("Book Shift"),
),
),
],
),
SizedBox( SizedBox(
height: MediaQuery.of(context).padding.bottom + 10, height: MediaQuery.of(context).padding.bottom + 10,
), ),