/* IGI โ Multi-step Quote Flow */
function QuoteFlow({ navigate }) {
const [step, setStep] = React.useState(0);
const [data, setData] = React.useState({
product: 'motor',
plan: 'standard',
addons: ['roadside'],
vehicle: { make: 'Toyota', model: 'Corolla Altis 1.6', year: '2024', value: 4500000, city: 'Karachi' },
driver: { name: '', cnic: '', mobile: '', email: '', dob: '1990-01-01', license: '5+ years' },
coverStart: '2026-05-15',
});
const setField = (path, val) => {
setData(d => {
const next = { ...d };
const keys = path.split('.');
let cur = next;
for (let i = 0; i < keys.length - 1; i++) {
cur[keys[i]] = { ...cur[keys[i]] };
cur = cur[keys[i]];
}
cur[keys[keys.length - 1]] = val;
return next;
});
};
const steps = ['What to insure', 'Vehicle details', 'Choose plan', 'Add-ons', 'Your details', 'Review & pay'];
const next = () => setStep(s => Math.min(steps.length - 1, s + 1));
const back = () => setStep(s => Math.max(0, s - 1));
// Premium calc (illustrative)
const basePrices = { thirdparty: 2500, standard: 18500, comp: 28900 };
const planPrice = basePrices[data.plan === 'thirdparty' ? 'thirdparty' : data.plan === 'comp' ? 'comp' : 'standard'];
const addonPrices = { roadside: 1800, accident: 1200, depreciation: 3400, replacement: 2100 };
const addonsTotal = data.addons.reduce((s, a) => s + (addonPrices[a] || 0), 0);
const tax = Math.round((planPrice + addonsTotal) * 0.13);
const total = planPrice + addonsTotal + tax;
return (
Quote builder
Get your motor insurance quote
navigate('home')}>
Cancel
{/* Stepper */}
{steps.map((label, i) => (
{i < step ? : i + 1}
{label}
{i < steps.length - 1 &&
}
))}
Step {step + 1} of {steps.length} โ {steps[step]}
{/* Main step content */}
{step === 0 &&
}
{step === 1 &&
}
{step === 2 &&
}
{step === 3 &&
}
{step === 4 &&
}
{step === 5 &&
}
Back
{step < steps.length - 1 ? (
Continue
) : (
alert('Demo: payment gateway would open here')}>
Pay PKR {total.toLocaleString()}
)}
{/* Sidebar โ running summary */}
Your quote so far
Total annual
PKR {total.toLocaleString()}
or 12 monthly installments of PKR {Math.round(total / 12).toLocaleString()}
Save 8% by paying annually instead of monthly.
);
}
function Row({ label, value }) {
return (
{label}
{value}
);
}
function Line({ label, value, small }) {
return (
{label}
{value}
);
}
function Step0({ data, setField }) {
const opts = [
{ id: 'motor', i: I.Car, l: 'Motor / Auto', d: 'Cars, bikes, commercial' },
{ id: 'home', i: I.Home, l: 'Home', d: 'Building & contents' },
{ id: 'travel', i: I.Plane, l: 'Travel', d: 'Trip cover, schengen' },
{ id: 'health', i: I.Heart, l: 'Health', d: 'Individual / family' },
];
return (
<>
What would you like to insure?
Pick a category to get started. You can always add more policies later from your dashboard.
{opts.map(o => {
const sel = data.product === o.id;
return (
setField('product', o.id)} style={{
padding: 24, border: sel ? '2px solid var(--blue-600)' : '1px solid var(--ink-200)',
borderRadius: 12, background: sel ? 'var(--blue-50)' : 'white',
display: 'flex', alignItems: 'center', gap: 16, textAlign: 'left',
transition: 'all 0.15s ease',
}}>
{sel && }
);
})}
>
);
}
function Step1({ data, setField }) {
return (
<>
Tell us about your vehicle
This helps us calculate your premium accurately.
>
);
}
function Step2({ data, setField }) {
const plans = [
{ id: 'thirdparty', name: 'Third Party', price: 2500, features: ['Mandatory legal cover', 'Up to PKR 20L liability'] },
{ id: 'standard', name: 'Standard', price: 18500, features: ['Accidental damage', 'Theft & fire', '120+ workshops'], popular: true },
{ id: 'comp', name: 'Comprehensive Plus', price: 28900, features: ['Everything in Standard', 'Zero depreciation', 'Roadside 24/7'] },
];
return (
<>
Choose your plan
You can switch plans any time before purchasing.
{plans.map(p => {
const sel = data.plan === p.id;
return (
setField('plan', p.id)} style={{
padding: 20, border: sel ? '2px solid var(--blue-600)' : '1px solid var(--ink-200)',
borderRadius: 12, background: sel ? 'var(--blue-50)' : 'white',
display: 'flex', alignItems: 'center', gap: 16, textAlign: 'left',
}}>
{p.name}
{p.popular && POPULAR }
{p.features.join(' ยท ')}
{p.price.toLocaleString()}
PKR / year
);
})}
>
);
}
function Step3({ data, setField }) {
const addons = [
{ id: 'roadside', i: I.Wrench, l: 'Roadside assistance', d: '24/7 towing & emergency help', p: 1800 },
{ id: 'accident', i: I.User, l: 'Personal accident cover', d: 'Up to PKR 10L for driver & passengers', p: 1200 },
{ id: 'depreciation', i: I.Sparkles, l: 'Zero depreciation', d: 'No deduction on parts during claim', p: 3400 },
{ id: 'replacement', i: I.Car, l: 'Replacement vehicle', d: 'Rental car for 14 days during repair', p: 2100 },
];
const toggle = (id) => {
const a = data.addons.includes(id) ? data.addons.filter(x => x !== id) : [...data.addons, id];
setField('addons', a);
};
return (
<>
Anything to add?
Optional extras to tailor your cover.
{addons.map(a => {
const sel = data.addons.includes(a.id);
return (
toggle(a.id)} style={{
padding: 18, border: sel ? '2px solid var(--blue-600)' : '1px solid var(--ink-200)',
borderRadius: 10, background: sel ? 'var(--blue-50)' : 'white',
display: 'flex', alignItems: 'center', gap: 14, textAlign: 'left',
}}>
{sel && }
+PKR {a.p.toLocaleString()}
);
})}
>
);
}
function Step4({ data, setField }) {
return (
<>
Your details
We use this to issue the policy and contact you about claims.
>
);
}
function Step5({ data, total, navigate }) {
const [pay, setPay] = React.useState('card');
const methods = [
{ id: 'card', l: 'Debit / Credit Card', d: 'Visa, Mastercard, UnionPay' },
{ id: 'jazz', l: 'JazzCash', d: 'Mobile wallet payment' },
{ id: 'easy', l: 'Easypaisa', d: 'Mobile wallet payment' },
{ id: 'bank', l: 'Bank transfer', d: 'IBFT to IGI account' },
{ id: 'install', l: 'Monthly installments', d: '12 monthly payments' },
];
return (
<>
Review & pay
Almost there. Review your details, choose how to pay.
Payment method
{methods.map(m => {
const sel = pay === m.id;
return (
setPay(m.id)} style={{
padding: 14, border: sel ? '2px solid var(--blue-600)' : '1px solid var(--ink-200)',
borderRadius: 10, background: sel ? 'var(--blue-50)' : 'white',
display: 'flex', alignItems: 'center', gap: 12, textAlign: 'left',
}}>
);
})}
By proceeding, you agree to IGI's policy terms and authorize debit of PKR {total.toLocaleString()}.
>
);
}
function Field({ label, children }) {
return (
{label}
{children}
);
}
window.QuoteFlow = QuoteFlow;