fix: Select defaults + confirm responsive pattern + convert to AlertDialog

1. Fixed Select Field Default Value 
   Problem: Select shows empty even with default/saved value
   Solution: Ensure select always has value

   const selectValue = (value || field.value || field.default) as string;
   <Select value={selectValue}>

   Priority: current > saved > default
   Result:  Select always shows correct value

2. Confirmed Responsive Pattern 
   ResponsiveDialog already working correctly:
   - Desktop (≥768px): Dialog component
   - Mobile (<768px): Drawer component
   - useMediaQuery hook detects screen size

    No changes needed - already correct!

3. Converted to AlertDialog 

   A. Orders/Detail.tsx - Retry Payment
      - Was: Dialog (can dismiss by clicking outside)
      - Now: AlertDialog (must choose action)
      - Better for critical payment retry action

   B. Orders/index.tsx - Delete Orders
      - Was: Dialog (can dismiss by clicking outside)
      - Now: AlertDialog (must choose action)
      - Better for destructive delete action

   Benefits:
   -  No close button (forces decision)
   -  Can't dismiss by clicking outside
   -  User must explicitly choose Cancel or Confirm
   -  Better UX for critical/destructive actions

Component Usage Summary:
- Dialog: Forms, settings, content display
- Drawer: Mobile bottom sheet (auto via ResponsiveDialog)
- AlertDialog: Confirmations, destructive actions

Files Modified:
- GenericGatewayForm.tsx: Select default value fix
- Orders/Detail.tsx: Dialog → AlertDialog
- Orders/index.tsx: Dialog → AlertDialog
This commit is contained in:
dwindown
2025-11-06 10:28:04 +07:00
parent 108155db50
commit f9161b49f4
3 changed files with 54 additions and 35 deletions

View File

@@ -160,6 +160,8 @@ export function GenericGatewayForm({ gateway, onSave, onCancel, hideFooter = fal
);
case 'select':
// Ensure select has a value - use current value, saved value, or default
const selectValue = (value || field.value || field.default) as string;
return (
<div key={field.id} className="space-y-2">
<Label htmlFor={field.id}>
@@ -173,7 +175,7 @@ export function GenericGatewayForm({ gateway, onSave, onCancel, hideFooter = fal
/>
)}
<Select
value={value as string}
value={selectValue}
onValueChange={(val) => handleFieldChange(field.id, val)}
>
<SelectTrigger id={field.id}>