Pre-fill intake wizard from order data + FRN, use quick mode for FCC lookup
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
af65fca709
commit
98a4c90e3a
2 changed files with 42 additions and 1 deletions
|
|
@ -318,6 +318,47 @@ const STEP_LABELS: Record<string, string> = {
|
|||
set steps(s: string[]) { steps = s; },
|
||||
};
|
||||
|
||||
// ── Pre-fill from order data when accessed via token (paid batch order) ──
|
||||
(async () => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const token = params.get("token");
|
||||
const frn = params.get("frn");
|
||||
if (!token) return;
|
||||
|
||||
const API = (window as any).__PW_API || "";
|
||||
try {
|
||||
// Decode the token to get order_id + email — no server call needed for basic info
|
||||
// The token is a JWT with {order_id, order_type, email}
|
||||
const payload = JSON.parse(atob(token.split(".")[1]));
|
||||
const state = loadState();
|
||||
if (payload.email && !state.email) {
|
||||
state.email = payload.email;
|
||||
}
|
||||
if (payload.order_id) {
|
||||
state.intake_data = { ...state.intake_data, order_number: payload.order_id };
|
||||
}
|
||||
|
||||
// Fetch customer info from the compliance order
|
||||
if (payload.order_id) {
|
||||
try {
|
||||
const r = await fetch(`${API}/api/v1/compliance-orders/${payload.order_id}`, {
|
||||
headers: { "Authorization": `Bearer ${token}` },
|
||||
});
|
||||
if (r.ok) {
|
||||
const order = await r.json();
|
||||
if (order.customer_name && !state.name) state.name = order.customer_name;
|
||||
if (order.customer_email && !state.email) state.email = order.customer_email;
|
||||
if (order.intake_data) {
|
||||
state.intake_data = { ...state.intake_data, ...order.intake_data };
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
saveState(state);
|
||||
} catch {}
|
||||
})();
|
||||
|
||||
function renderStep(idx: number) {
|
||||
const state = loadState();
|
||||
state.step_index = idx;
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@
|
|||
async function autoFillFromFRN(frn: string) {
|
||||
try {
|
||||
const API = (window as any).__PW_API || "";
|
||||
const r = await fetch(`${API}/api/v1/fcc/lookup?frn=${frn}`);
|
||||
const r = await fetch(`${API}/api/v1/fcc/lookup?frn=${frn}&quick=1`);
|
||||
if (!r.ok) return;
|
||||
const d = await r.json();
|
||||
const entity: any = {};
|
||||
|
|
|
|||
Loading…
Reference in a new issue