← All changes
|
resources/js/components/availability/RecurringRules.tsx
+33
-12
3.0.9
→
3.0.16
View file →
| @@ -117,8 +117,9 @@ | ||
| 117 | 117 | status: true, |
| 118 | 118 | }); |
| 119 | 119 | |
| 120 | 120 | // Confirmation dialogs |
| 121 | + const [bulkDeleteConfirm, setBulkDeleteConfirm] = useState(false); | |
| 121 | 122 | const [deleteConfirm, setDeleteConfirm] = useState<{ |
| 122 | 123 | isOpen: boolean; |
| 123 | 124 | rule: RecurringRule | null; |
| 124 | 125 | }>({ |
| @@ -286,25 +287,27 @@ | ||
| 286 | 287 | }); |
| 287 | 288 | |
| 288 | 289 | // Handle bulk actions |
| 289 | 290 | const handleBulkApply = () => { |
| 290 | - if (!bulkAction || selectedIds.length === 0) { | |
| 291 | - showToast(__("Please select rules and an action", "yatra"), "warning"); | |
| 291 | + // Report the input that is actually missing. The Apply button is disabled | |
| 292 | + // whenever nothing is selected, so this can only be reached with a non-empty | |
| 293 | + // selection — the combined message blamed the selection and left operators | |
| 294 | + // re-selecting rows that were already ticked. | |
| 295 | + if (selectedIds.length === 0) { | |
| 296 | + showToast(__("Please select at least one rule.", "yatra"), "warning"); | |
| 292 | 297 | return; |
| 293 | 298 | } |
| 294 | 299 | |
| 300 | + if (!bulkAction) { | |
| 301 | + showToast(__("Please choose an action to apply.", "yatra"), "warning"); | |
| 302 | + return; | |
| 303 | + } | |
| 304 | + | |
| 295 | 305 | switch (bulkAction) { |
| 296 | 306 | case "delete": |
| 297 | - if ( | |
| 298 | - confirm( | |
| 299 | - __( | |
| 300 | - "Are you sure you want to delete {count} rule(s)?", | |
| 301 | - "yatra", | |
| 302 | - ).replace("{count}", selectedIds.length.toString()), | |
| 303 | - ) | |
| 304 | - ) { | |
| 305 | - bulkDeleteMutation.mutate(selectedIds.map((id) => id.toString())); | |
| 306 | - } | |
| 307 | + // Confirmed through the shared dialog, matching the single-rule delete | |
| 308 | + // and duplicate actions in this same component. | |
| 309 | + setBulkDeleteConfirm(true); | |
| 307 | 310 | break; |
| 308 | 311 | } |
| 309 | 312 | |
| 310 | 313 | setBulkAction(""); |
| @@ -938,8 +941,26 @@ | ||
| 938 | 941 | </div> |
| 939 | 942 | </div> |
| 940 | 943 | </CardContent> |
| 941 | 944 | </Card> |
| 945 | + | |
| 946 | + <ConfirmationDialog | |
| 947 | + isOpen={bulkDeleteConfirm} | |
| 948 | + onClose={() => setBulkDeleteConfirm(false)} | |
| 949 | + onConfirm={() => { | |
| 950 | + bulkDeleteMutation.mutate(selectedIds.map((id) => id.toString())); | |
| 951 | + setBulkDeleteConfirm(false); | |
| 952 | + }} | |
| 953 | + title={__("Delete Rules", "yatra")} | |
| 954 | + message={__( | |
| 955 | + "Are you sure you want to delete {count} rule(s)? This action cannot be undone.", | |
| 956 | + "yatra", | |
| 957 | + ).replace("{count}", selectedIds.length.toString())} | |
| 958 | + confirmText={__("Delete", "yatra")} | |
| 959 | + cancelText={__("Cancel", "yatra")} | |
| 960 | + variant="danger" | |
| 961 | + isLoading={bulkDeleteMutation.isPending} | |
| 962 | + /> | |
| 942 | 963 | </div> |
| 943 | 964 | ); |
| 944 | 965 | }; |
| 945 | 966 | |