{#snippet pinIcon()}
{/snippet}
{#each pinnedUnits as unit (unit._id)}
(selectedUnitId = unit._id)} aria-label="Select {unit.code}" >
{unit.code}{unit.code2 ? ` / ${unit.code2}` : ""}
{unit.name}
{#if authed}
togglePin(unit)} disabled={busy || (!isPinned(unit._id) && !canPinMore)} title={isPinned(unit._id) ? "Unpin unit" : canPinMore ? "Pin unit" : "You can pin up to 10 units"} aria-label={isPinned(unit._id) ? "Unpin unit" : "Pin unit"} > {@render pinIcon()}
{/if}
{/each} {#each unpinnedUnits as unit (unit._id)}
(selectedUnitId = unit._id)} aria-label="Select {unit.code}" >
{unit.code}{unit.code2 ? ` / ${unit.code2}` : ""}
{unit.name}
{#if authed}
togglePin(unit)} disabled={busy || (!isPinned(unit._id) && !canPinMore)} title={isPinned(unit._id) ? "Unpin unit" : canPinMore ? "Pin unit" : "You can pin up to 10 units"} aria-label={isPinned(unit._id) ? "Unpin unit" : "Pin unit"} > {@render pinIcon()}
{/if}
{/each}
{#if error}
{error}
{/if}