feat: implement recovery incident management components and form for adding incidents
This commit is contained in:
@@ -18,6 +18,7 @@ import type { RecoveryIncident } from '../RecoveryIncidentsTypes';
|
|||||||
interface AddRecoveryIncidentsProps {
|
interface AddRecoveryIncidentsProps {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
onSuccess?: (createdCount: number, flightNumber: string, passengerName: string) => void;
|
||||||
incident?: RecoveryIncident | null;
|
incident?: RecoveryIncident | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ const DEFAULT_JURISDICTION_OPTIONS = [
|
|||||||
{ label: "CAA SG (Singapore)", value: "CAA_SG" },
|
{ label: "CAA SG (Singapore)", value: "CAA_SG" },
|
||||||
];
|
];
|
||||||
|
|
||||||
export default function AddRecoveryIncidents({ isOpen, onClose, incident }: AddRecoveryIncidentsProps) {
|
export default function AddRecoveryIncidents({ isOpen, onClose, onSuccess, incident }: AddRecoveryIncidentsProps) {
|
||||||
const [, setLoyaltyTierOptions] = useState<{ label: string; value: string }[]>([]);
|
const [, setLoyaltyTierOptions] = useState<{ label: string; value: string }[]>([]);
|
||||||
const [jurisdictionOptions, setJurisdictionOptions] = useState<{ label: string; value: string }[]>(DEFAULT_JURISDICTION_OPTIONS);
|
const [jurisdictionOptions, setJurisdictionOptions] = useState<{ label: string; value: string }[]>(DEFAULT_JURISDICTION_OPTIONS);
|
||||||
const [scenarioOptions, setScenarioOptions] = useState<{ label: string; value: string }[]>(DEFAULT_SCENARIO_OPTIONS);
|
const [scenarioOptions, setScenarioOptions] = useState<{ label: string; value: string }[]>(DEFAULT_SCENARIO_OPTIONS);
|
||||||
@@ -347,6 +348,14 @@ export default function AddRecoveryIncidents({ isOpen, onClose, incident }: AddR
|
|||||||
});
|
});
|
||||||
|
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
|
|
||||||
|
if (onSuccess) {
|
||||||
|
onSuccess(
|
||||||
|
selectedPassengers.length,
|
||||||
|
formData.flightNumber || "TBD",
|
||||||
|
selectedPassengers[0]?.passengerName || "Unknown"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onClose();
|
onClose();
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import {
|
|||||||
CustomActionMenu,
|
CustomActionMenu,
|
||||||
CustomActionItem,
|
CustomActionItem,
|
||||||
CustomAlertBanner,
|
CustomAlertBanner,
|
||||||
|
CustomSuccessModal,
|
||||||
} from "../../../components/custom";
|
} from "../../../components/custom";
|
||||||
import type { Column } from "../../../components/custom/CustomTable";
|
import type { Column } from "../../../components/custom/CustomTable";
|
||||||
import type { RecoveryIncident, MetricCardData } from "../RecoveryIncidentsTypes";
|
import type { RecoveryIncident, MetricCardData } from "../RecoveryIncidentsTypes";
|
||||||
@@ -113,6 +114,14 @@ export default function RecoveryIncidentsList() {
|
|||||||
// Selection
|
// Selection
|
||||||
const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set());
|
const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set());
|
||||||
|
|
||||||
|
// Success Modal
|
||||||
|
const [successModalData, setSuccessModalData] = useState<{
|
||||||
|
isOpen: boolean;
|
||||||
|
count: number;
|
||||||
|
flightNumber: string;
|
||||||
|
passengerName: string;
|
||||||
|
}>({ isOpen: false, count: 0, flightNumber: '', passengerName: '' });
|
||||||
|
|
||||||
// ─── Fetch data ─────────────────────────────────────────────
|
// ─── Fetch data ─────────────────────────────────────────────
|
||||||
|
|
||||||
const fetchIncidents = useCallback(async () => {
|
const fetchIncidents = useCallback(async () => {
|
||||||
@@ -596,6 +605,32 @@ export default function RecoveryIncidentsList() {
|
|||||||
setEditingIncident(null);
|
setEditingIncident(null);
|
||||||
fetchIncidents(); // Refresh list
|
fetchIncidents(); // Refresh list
|
||||||
}}
|
}}
|
||||||
|
onSuccess={(createdCount, flightNumber, passengerName) => {
|
||||||
|
setSuccessModalData({
|
||||||
|
isOpen: true,
|
||||||
|
count: createdCount,
|
||||||
|
flightNumber,
|
||||||
|
passengerName,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Success Modal */}
|
||||||
|
<CustomSuccessModal
|
||||||
|
isOpen={successModalData.isOpen}
|
||||||
|
onClose={() => setSuccessModalData((prev) => ({ ...prev, isOpen: false }))}
|
||||||
|
title={
|
||||||
|
successModalData.count > 1
|
||||||
|
? "Recovery Incidents Created."
|
||||||
|
: "Recovery Incident Created."
|
||||||
|
}
|
||||||
|
label="FLIGHT & PASSENGER DETAILS"
|
||||||
|
cohortName={`Flight ${successModalData.flightNumber}`}
|
||||||
|
cohortDescription={
|
||||||
|
successModalData.count > 1
|
||||||
|
? `Successfully logged incidents for ${successModalData.count} passengers, including ${successModalData.passengerName}.`
|
||||||
|
: `Successfully logged incident for ${successModalData.passengerName}.`
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import Skeleton from "./CustomSkeleton";
|
|||||||
import CustomTimePicker from "./CustomTimePicker";
|
import CustomTimePicker from "./CustomTimePicker";
|
||||||
import CustomAccordionSection from "./CustomAccordionSection";
|
import CustomAccordionSection from "./CustomAccordionSection";
|
||||||
import CustomFullModal from "./CustomFullModal";
|
import CustomFullModal from "./CustomFullModal";
|
||||||
|
import CustomSuccessModal from "./CustomSuccessModal";
|
||||||
export {
|
export {
|
||||||
CustomInput,
|
CustomInput,
|
||||||
CustomTextArea,
|
CustomTextArea,
|
||||||
@@ -51,5 +51,6 @@ export {
|
|||||||
CustomAlertBanner,
|
CustomAlertBanner,
|
||||||
Skeleton,
|
Skeleton,
|
||||||
CustomTimePicker,
|
CustomTimePicker,
|
||||||
CustomAccordionSection
|
CustomAccordionSection,
|
||||||
|
CustomSuccessModal
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user