feat: implement policy management listing and creation interface
This commit is contained in:
@@ -17,7 +17,6 @@ import {
|
||||
CustomLoader,
|
||||
Skeleton,
|
||||
} from '../../../components/custom';
|
||||
import CustomSuccessModal from '../../../components/custom/CustomSuccessModal';
|
||||
import {
|
||||
getJurisdictionOptions,
|
||||
getCohortOptions,
|
||||
@@ -153,7 +152,6 @@ export default function AddPolicyEngine() {
|
||||
|
||||
const [loadingPolicy, setLoadingPolicy] = useState(false);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [showSuccessModal, setShowSuccessModal] = useState(false);
|
||||
|
||||
// Dynamic Options State (loaded directly from PolicyEngineApi)
|
||||
const [jurisdictionOptions, setJurisdictionOptions] = useState<OptionItem[]>([]);
|
||||
@@ -621,7 +619,11 @@ export default function AddPolicyEngine() {
|
||||
await createPolicy(payload);
|
||||
}
|
||||
|
||||
setShowSuccessModal(true);
|
||||
const successMsg = isEditMode
|
||||
? `Policy "${payload.policyName}" updated successfully!`
|
||||
: `Policy "${payload.policyName}" created successfully!`;
|
||||
|
||||
navigate('/policy-engine', { state: { successMsg } });
|
||||
} catch (err) {
|
||||
console.error('Failed to save policy', err);
|
||||
alert('Failed to save policy. Please check input values and try again.');
|
||||
@@ -1358,20 +1360,6 @@ export default function AddPolicyEngine() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ─── Success Modal ──────────────────────────────────────────────── */}
|
||||
<CustomSuccessModal
|
||||
isOpen={showSuccessModal}
|
||||
onClose={() => {
|
||||
setShowSuccessModal(false);
|
||||
navigate('/policy-engine');
|
||||
}}
|
||||
title={isEditMode ? 'Policy Updated Successfully.' : 'Policy Created Successfully.'}
|
||||
label="POLICY NAME"
|
||||
cohortName={policyName}
|
||||
cohortStatus={status}
|
||||
cohortDescription={description}
|
||||
/>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
PencilSimpleIcon,
|
||||
ChecksIcon,
|
||||
} from "@phosphor-icons/react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useNavigate, useLocation } from "react-router-dom";
|
||||
import {
|
||||
CustomTable,
|
||||
CustomInput,
|
||||
@@ -65,6 +65,14 @@ export default function PolicyEngineList() {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [successMsg, setSuccessMsg] = useState<string | null>(null);
|
||||
const location = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
if (location.state?.successMsg) {
|
||||
setSuccessMsg(location.state.successMsg);
|
||||
window.history.replaceState({}, document.title);
|
||||
}
|
||||
}, [location]);
|
||||
|
||||
// Pagination
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
|
||||
Reference in New Issue
Block a user