Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Mar 2, 2025
1 parent f6f81f9 commit 52e4b42
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 26 deletions.
75 changes: 49 additions & 26 deletions ui/src/lib/ConnectionDetail.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,39 @@
</div>
{/snippet}

{#snippet ticketInfo(prevTransitLeg: Leg | undefined, l: Leg)}
{#if itinerary.fareTransfers != undefined && l.fareTransferIndex != undefined && l.effectiveFareLegIndex != undefined}
{@const fareTransfer = itinerary.fareTransfers[l.fareTransferIndex]}
{@const includedInTransfer =
fareTransfer.rule == 'AB' || (fareTransfer.rule == 'A_AB' && l.effectiveFareLegIndex !== 0)}
<div class="list-inside pl-1 md:pl-4 my-8 text-xs font-bold">
{#if includedInTransfer || (prevTransitLeg && prevTransitLeg.fareTransferIndex === l.fareTransferIndex && prevTransitLeg.effectiveFareLegIndex === l.effectiveFareLegIndex)}
{t.includedInTicket}
{:else}
{@const productOptions = fareTransfer.effectiveFareLegProducts[l.effectiveFareLegIndex]}
{#if productOptions.length > 1}
<div class="mb-1">{t.ticketOptions}:</div>
{/if}
<ul
class:list-disc={productOptions.length > 1}
class:list-inside={productOptions.length > 1}
>
{#each productOptions as product}
<li>
{#if productOptions.length == 1}
{t.ticket}
{/if}
{product.name}
({product.amount}
{product.currency})
</li>
{/each}
</ul>
{/if}
</div>
{/if}
{/snippet}

<div class="text-lg">
{#each itinerary.legs as l, i}
{@const isLast = i == itinerary.legs.length - 1}
Expand All @@ -91,7 +124,7 @@
<Route {onClickTrip} {l} />
{#if pred && (pred.from.track || pred.duration !== 0) && (i != 1 || pred.routeShortName)}
<div class="border-t h-0 grow shrink"></div>
<div class="text-sm text-muted-foreground leading-none px-2">
<div class="text-sm text-muted-foreground leading-none px-2 text-center">
{#if pred.from.track}
{t.arrivalOnTrack} {pred.from.track}{pred.duration ? ',' : ''}
{/if}
Expand All @@ -101,6 +134,19 @@
{#if pred.distance}
({Math.round(pred.distance)} m)
{/if}
{#if prevTransitLeg?.fareTransferIndex != undefined && itinerary.fareTransfers && itinerary.fareTransfers[prevTransitLeg.fareTransferIndex].transferProduct}
{@const transferProduct =
itinerary.fareTransfers[prevTransitLeg.fareTransferIndex].transferProduct!}
{#if prevTransitLeg.effectiveFareLegIndex === 0 && l.effectiveFareLegIndex === 1}
<br />
<span class="text-xs font-bold text-foreground">
Ticket: {pred.effectiveFareLegIndex}
{transferProduct.name}
({transferProduct.amount}
{transferProduct.currency})
</span>
{/if}
{/if}
</div>
{/if}
<div class="border-t h-0 grow shrink"></div>
Expand Down Expand Up @@ -130,32 +176,9 @@
<div class="py-8 pl-1 md:pl-4 flex items-center text-muted-foreground">
{t.tripIntermediateStops(0)}
</div>
{#if itinerary.fareTransfers != undefined && l.fareTransferIndex != undefined && l.effectiveFareLegIndex != undefined}
{@const fareTransfer = itinerary.fareTransfers[l.fareTransferIndex]}
{@const includedInTransfer =
fareTransfer.rule == 'AB' ||
(fareTransfer.rule == 'A_AB' && l.effectiveFareLegIndex !== 0)}
<div class="list-inside pl-1 md:pl-4 mb-8 text-xs font-bold">
{#if includedInTransfer || (prevTransitLeg && prevTransitLeg.fareTransferIndex === l.fareTransferIndex && prevTransitLeg.effectiveFareLegIndex === l.effectiveFareLegIndex)}
Included in ticket.
{:else}
{@const productOptions =
fareTransfer.effectiveFareLegProducts[l.effectiveFareLegIndex]}
{#if productOptions.length > 1}
<div class="mb-1">Ticket options:</div>
{/if}
<ul
class:list-disc={productOptions.length > 1}
class:list-inside={productOptions.length > 1}
>
{#each productOptions as product}
<li>{product.name}</li>
{/each}
</ul>
{/if}
</div>
{/if}
{@render ticketInfo(prevTransitLeg, l)}
{:else}
{@render ticketInfo(prevTransitLeg, l)}
<details class="[&_svg]:open:-rotate-180 my-2">
<summary class="py-8 pl-1 md:pl-4 flex items-center text-muted-foreground">
<svg
Expand Down
3 changes: 3 additions & 0 deletions ui/src/lib/i18n/de.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { Translations } from './translation';

const translations: Translations = {
ticket: 'Fahrschein',
ticketOptions: 'Fahrscheinoptionen',
includedInTicket: 'Im Fahrschein enthalten',
journeyDetails: 'Verbindungsdetails',
transfers: 'Umstiege',
walk: 'Fußweg',
Expand Down
3 changes: 3 additions & 0 deletions ui/src/lib/i18n/en.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { Translations } from './translation';

const translations: Translations = {
ticket: 'Ticket',
ticketOptions: 'Ticket Options',
includedInTicket: 'Included in ticket',
journeyDetails: 'Journey Details',
transfers: 'transfers',
walk: 'Walk',
Expand Down
3 changes: 3 additions & 0 deletions ui/src/lib/i18n/fr.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { Translations } from './translation';

const translations: Translations = {
ticket: 'Billet',
ticketOptions: 'Options de billet',
includedInTicket: 'Inclus dans le billet',
journeyDetails: 'Détails du voyage',
walk: 'à pied',
bike: 'Vélo',
Expand Down
3 changes: 3 additions & 0 deletions ui/src/lib/i18n/pl.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { Translations } from './translation';

const translations: Translations = {
ticket: 'Bilet',
ticketOptions: 'Opcje biletu',
includedInTicket: 'Zawarte w bilecie',
journeyDetails: 'Szczegóły podróży',
transfers: 'przesiadki',
walk: 'Pieszo',
Expand Down
3 changes: 3 additions & 0 deletions ui/src/lib/i18n/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import fr from './fr';
import pl from './pl';

export type Translations = {
ticket: string;
ticketOptions: string;
includedInTicket: string;
journeyDetails: string;
transfers: string;
walk: string;
Expand Down

0 comments on commit 52e4b42

Please sign in to comment.