Skip to content

Show layer details

View as Markdown

Clicking a layer is the natural way to ask for more about it. onSelect tells you which layer was clicked; what you show is up to you.

Click a layer:

Tower (Property)
Retention 70%
Property quota share
XOL Treaty - Per Event (Property)
Retention
Retention 70%
Cat XL 1, 10M xs 10M per eventCat XL 2, 30M xs 20M per eventCat XL 3, 50M xs 50M per event
XOL Treaty - Per Risk (Property)
Retention
Risk XL 1, 4M xs 1M per riskRisk XL 2, 5M xs 5M per risk
XOL Treaty - Aggregate (Property)
Retention
Retention 65%
Aggregate XL, 20M xs 40M xs 5M aggregate
XOL Treaty - Per Event (Whole account)
Retention
Whole-account clash XL, 15M xs 10M per event
kept by the cedant signed firm orderWidth is share of the risk, height is amount.

Click a layer to see its terms.

import { useState } from 'react';
import { Towers } from '@vinsa/towers';
function ProgramTowers({ response, program }) {
const [selected, setSelected] = useState(null);
return (
<div className="layout">
<Towers
data={response}
onSelect={(key, risk) => setSelected(key ? { key, riskId: risk.riskId } : null)}
/>
<LayerPanel program={program} selected={selected} />
</div>
);
}

onSelect receives:

  • key: the layer’s layerRef, or its layerName if it has no reference. null when the selection is cleared.
  • risk: the risk the layer belongs to, from the response.

The response carries what is needed to draw. Premium, reinstatements and the rest are in the request you sent, so look the layer up there with layerKey:

import { formatAmount, layerKey, layerTerms } from '@vinsa/towers';
function LayerPanel({ program, selected }) {
if (!selected) return <p>Select a layer to see its terms.</p>;
const risk = program.risks.find((r) => r.riskId === selected.riskId);
const contracts = program.contracts.filter((c) => risk?.contractRefs.includes(c.contractRef));
const layers = contracts.flatMap((c) => c.layers);
const layer = layers.find((l) => layerKey(l) === selected.key);
if (!layer) return null;
return (
<aside>
<h2>{layer.layerName}</h2>
<p>{layerTerms(layer)}</p>
<p>Premium: {layer.premium != null ? formatAmount(layer.premium) : 'not stated'}</p>
<ul>
{layer.lines?.map((r) => (
<li key={r.reinsurer}>
{r.reinsurer}: {r.writtenShare}% ({r.status})
</li>
))}
</ul>
</aside>
);
}

Give each layer a layerRef when two could share a name. The key is how they are told apart.

To highlight a layer from a row in your own table, control the selection: hold the key in state and pass it as selectedKey.

const [selected, setSelected] = useState<string | null>(null);
<Towers data={response} riskId={riskId} selectedKey={selected} onSelect={setSelected} />
<table>
{program.contracts.filter((c) => risk.contractRefs.includes(c.contractRef)).flatMap((c) => c.layers).map((l) => (
<tr key={layerKey(l)} onClick={() => setSelected(layerKey(l))}>
<td>{l.layerName}</td>
</tr>
))}
</table>