Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | 364x 64x 24x 9x 40x 39x 2x 76x 28x 1x | import { createPortal } from "react-dom";
import { Button } from "../ui/button";
import { LOSS_REASON_OPTIONS } from "../../lib/crm-constants";
// ─── Types ───────────────────────────────────────────────────────────────────
export type PendingDrop = {
leadId: number;
stageId: number;
stageName: string;
stageType: string;
};
type StageChangeDialogsProps = {
pendingDrop: PendingDrop | null;
orderValue: string;
onOrderValueChange: (value: string) => void;
lossReasonCategory: string;
onLossReasonCategoryChange: (value: string) => void;
lossReason: string;
onLossReasonChange: (value: string) => void;
onConfirm: () => void;
onCancel: () => void;
isPending: boolean;
};
// ─── Component ───────────────────────────────────────────────────────────────
export function StageChangeDialogs({
pendingDrop,
orderValue,
onOrderValueChange,
lossReasonCategory,
onLossReasonCategoryChange,
lossReason,
onLossReasonChange,
onConfirm,
onCancel,
isPending,
}: StageChangeDialogsProps) {
if (!pendingDrop) return null;
// #428: render through a portal so the dialog's `position: fixed` is
// anchored to the viewport, not to whichever ancestor happens to create a
// containing block. The Lead detail page wraps the desktop LeadHeader in
// `<StickyPageHeader>`, which uses `backdrop-filter: blur(...)` — and per
// CSS spec any non-`none` `backdrop-filter`/`transform`/`filter` ancestor
// becomes the containing block for `position: fixed` descendants. That
// trapped this dialog's full-viewport backdrop inside the ~64px header,
// leaving the rest of the page un-dimmed (the user-reported symptom).
if (pendingDrop.stageType === "system_terminal_won") {
return createPortal(
<div
role="dialog"
className="fixed inset-0 z-[60] flex items-center justify-center"
>
<button
type="button"
aria-label="Close"
className="fixed inset-0 bg-black/50 cursor-default"
onClick={onCancel}
tabIndex={-1}
/>
<div className="relative z-10 bg-background-elevated rounded-lg shadow-xl w-full max-w-sm mx-4 p-6">
<h2 className="text-lg font-semibold text-foreground-default">
Mark as Won
</h2>
<p className="mt-2 text-sm text-foreground-muted">
Move this lead to "{pendingDrop.stageName}"?
</p>
<div className="mt-4">
<label
htmlFor="won-order-value"
className="block text-sm font-medium text-foreground-default mb-1"
>
Order Value (optional)
</label>
<input
id="won-order-value"
type="text"
value={orderValue}
onChange={(e) => onOrderValueChange(e.target.value)}
placeholder="e.g., 4.2L or 420000"
className="w-full h-10 px-3 rounded-md border border-border-default bg-background-elevated text-foreground-default focus:ring-2 focus:ring-primary-500"
/>
<p className="mt-1 text-xs text-foreground-subtle">
Supports: 4.2L, 42K, 1.2Cr, or plain numbers
</p>
</div>
<div className="mt-6 flex justify-end gap-3">
<Button type="button" variant="outline" onClick={onCancel}>
Cancel
</Button>
<Button
type="button"
onClick={onConfirm}
isLoading={isPending}
>
Mark Won
</Button>
</div>
</div>
</div>,
document.body,
);
}
if (pendingDrop.stageType === "system_terminal_lost") {
return createPortal(
<div
role="dialog"
className="fixed inset-0 z-[60] flex items-center justify-center"
>
<button
type="button"
aria-label="Close"
className="fixed inset-0 bg-black/50 cursor-default"
onClick={onCancel}
tabIndex={-1}
/>
<div className="relative z-10 bg-background-elevated rounded-lg shadow-xl w-full max-w-sm mx-4 p-6">
<h2 className="text-lg font-semibold text-foreground-default">
Mark as Lost
</h2>
<p className="mt-2 text-sm text-foreground-muted">
Move this lead to "{pendingDrop.stageName}"?
</p>
<div className="mt-4 space-y-3">
<div>
<label
htmlFor="lost-reason-category"
className="block text-sm font-medium text-foreground-default mb-1"
>
Reason
</label>
<select
id="lost-reason-category"
value={lossReasonCategory}
onChange={(e) => onLossReasonCategoryChange(e.target.value)}
className="w-full h-10 px-3 rounded-md border border-border-default bg-background-elevated text-foreground-default focus:ring-2 focus:ring-primary-500"
>
<option value="">Select a reason (optional)</option>
{LOSS_REASON_OPTIONS.map((opt) => (
<option key={opt.value} value={opt.value}>
{opt.label}
</option>
))}
</select>
</div>
<div>
<label
htmlFor="lost-reason-detail"
className="block text-sm font-medium text-foreground-default mb-1"
>
Details (optional)
</label>
<textarea
id="lost-reason-detail"
value={lossReason}
onChange={(e) => onLossReasonChange(e.target.value)}
rows={2}
placeholder="Any additional details..."
className="w-full px-3 py-2 rounded-md border border-border-default bg-background-elevated text-foreground-default focus:ring-2 focus:ring-primary-500 resize-none"
/>
</div>
</div>
<div className="mt-6 flex justify-end gap-3">
<Button type="button" variant="outline" onClick={onCancel}>
Cancel
</Button>
<Button
type="button"
variant="destructive"
onClick={onConfirm}
isLoading={isPending}
>
Mark Lost
</Button>
</div>
</div>
</div>,
document.body,
);
}
return null;
}
|