Skip to content

Commit

Permalink
fix #43: add prefilled link to insa
Browse files Browse the repository at this point in the history
  • Loading branch information
joergreichert committed Nov 23, 2024
1 parent fca1623 commit 0b2c3c9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/Sidebar/SidebarMarket/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ export const SidebarMarket: FC<SidebarMarketType> = ({ marketData }) => {
)
}

const now = new Date();
const departureDate = `${now.getDate()}.${now.getMonth() + 1}.${now.getFullYear()}`;
const departureTime = `${now.getHours()}:${now.getMinutes()}`;
const journeyTarget = `${marketData.strasse}, ${marketData.plz_ort}`
const departureQueryUrl = encodeURI(`https://www.insa.de/fahrplanauskunft/insa-fahrplanauskunft?scrollTo=webapp&start=1&P=TP&journeyProducts=1023&Z=${journeyTarget}&time=${departureTime}&date=${departureDate}&timeSel=depart`);

return (
<>
<SidebarHeader text={marketData.name} fontSize="text-lg" />
Expand Down Expand Up @@ -163,6 +169,9 @@ export const SidebarMarket: FC<SidebarMarketType> = ({ marketData }) => {
{marketData.strasse}, {marketData.plz_ort}
</p>
<p className="text-sm">{marketData.train}</p>
<p className="mt-2">
<a className="text-sm underline" target="_blank" href={departureQueryUrl}>Fahrplanauskunft</a>
</p>
</MarketInfo>

{marketData.bemerkungen !== '' && (
Expand Down

0 comments on commit 0b2c3c9

Please sign in to comment.