sdding modal close

This commit is contained in:
Khalim Conn-Kowlessar 2026-05-06 18:16:55 +00:00
parent fccf4130c8
commit e6e94176cd
2 changed files with 6 additions and 3 deletions

View file

@ -1517,6 +1517,8 @@ interface InstructMeasureEditorProps {
canEdit: boolean;
/** Soft-warning string from `outOfOrderInstructionWarning`, or null. */
outOfOrderWarning: string | null;
/** Called after a successful instruction (e.g. to close an outer modal). */
onSuccess?: () => void;
}
export function InstructMeasureEditor({
@ -1525,6 +1527,7 @@ export function InstructMeasureEditor({
proposedMeasures,
canEdit,
outOfOrderWarning,
onSuccess,
}: InstructMeasureEditorProps) {
const queryClient = useQueryClient();
const { toast } = useToast();
@ -1582,6 +1585,7 @@ export function InstructMeasureEditor({
async function handleConfirm() {
const measureNames = Array.from(checked);
if (measureNames.length === 0) return;
setConfirmOpen(false);
setSubmitting(true);
setError(null);
try {
@ -1600,7 +1604,6 @@ export function InstructMeasureEditor({
? json.error
: "Failed to instruct measures",
);
setConfirmOpen(false);
return;
}
const json = (await res.json()) as {
@ -1608,9 +1611,9 @@ export function InstructMeasureEditor({
hubspotSync: "ok" | "failed";
hubspotError?: string;
};
setConfirmOpen(false);
setChecked(new Set());
void queryClient.invalidateQueries({ queryKey: ["pibiMeasures", portfolioId, dealId] });
onSuccess?.();
if (json.hubspotSync === "failed") {
toast({
title: "Measures instructed",
@ -1629,7 +1632,6 @@ export function InstructMeasureEditor({
setError(
err instanceof Error ? err.message : "Failed to instruct measures",
);
setConfirmOpen(false);
} finally {
setSubmitting(false);
}

View file

@ -554,6 +554,7 @@ export default function DealPage({
proposedMeasures={parseMeasures(deal.proposedMeasures ?? null)}
canEdit={isApprover}
outOfOrderWarning={outOfOrderInstructionWarning(deal)}
onSuccess={() => setInstructModalOpen(false)}
/>
</DialogContent>
</Dialog>