Skip to content

Commit

Permalink
feat(front): add SimBrief button (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpedroh authored May 14, 2021
1 parent 5e23770 commit 9516d38
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/front/src/components/FlightModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { formatEet } from '../../utils/formatEet'
import Button from '../Button'
import IcaoFpl from '../IcaoFpl'
import IvaoButton from '../IvaoButton'
import SimBriefButton from '../SimBriefButton'
import SkyVectorButton from '../SkyVectorButton'
import VatsimButton from '../VatsimButton'
import styles from './index.module.css'
Expand Down Expand Up @@ -66,6 +67,7 @@ const FlightModal: FC<Props> = ({ show, onClose, flight }) => {
<div className={styles.footer}>
<IvaoButton flight={flight} />
<VatsimButton flight={flight} />
<SimBriefButton flight={flight} />
<SkyVectorButton flight={flight} />
<Button variant="danger" onClick={onClose}>
Close
Expand Down
36 changes: 36 additions & 0 deletions packages/front/src/components/SimBriefButton/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Flight from '@mach/common'
import { FC } from 'react'
import Button from '../Button'

type Props = {
flight: Flight
}

const VatsimButton: FC<Props> = ({ flight }) => {
const query = {
airline: flight.company,
fltnum: flight.flightNumber,
type: flight.aircraft.icaoCode,
orig: flight.departureIcao,
dest: flight.arrivalIcao,
deph: flight.estimatedOffBlockTime.substr(0, 2),
depm: flight.estimatedOffBlockTime.substr(2, 2),
route: flight.route,
steh: Math.floor(flight.estimatedEnrouteMinutes / 60),
stem: flight.estimatedEnrouteMinutes % 60,
fl: flight.cruisingLevel * 100,
manualrmk: flight.remarks
}

const simBriefLink = `http://www.simbrief.com/system/dispatch.php?${new URLSearchParams(
query as any
).toString()}`

return (
<Button href={simBriefLink} target="_blank">
View on SimBrief
</Button>
)
}

export default VatsimButton

0 comments on commit 9516d38

Please sign in to comment.