Skip to content

Commit 6da6378

Browse files
committed
Errors & ESLint
1 parent ec0138d commit 6da6378

8 files changed

Lines changed: 358 additions & 167 deletions

File tree

.github/workflows/lint.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- 'README.md'
9+
pull_request:
10+
branches:
11+
- main
12+
paths-ignore:
13+
- 'README.md'
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: 20
27+
cache: 'npm'
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Run lint
33+
run: npm run lint
34+
35+
- name: Run type check
36+
run: npm run type-check
37+
38+
- name: Build project
39+
run: npm run build-only

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,11 @@
88
"prod": "cross-env NODE_ENV=production node server/server.js",
99
"build": "vite build --mode production",
1010
"build:dev": "vite build --mode development",
11-
"docker:build": "docker build -t pfcontrol-v2 .",
12-
"docker:run": "docker run -p 9900:9900 --env-file .env.production pfcontrol-v2",
13-
"docker:dev": "docker-compose -f docker-compose.dev.yml up --build",
14-
"docker:prod": "docker-compose up --build -d",
15-
"docker:stop": "docker-compose down",
16-
"docker:restart": "docker-compose down && docker-compose up --build -d",
17-
"docker:clean": "docker-compose down -v && docker system prune -f",
18-
"docker:update": "git pull && docker-compose down && docker-compose up --build -d",
19-
"docker:logs": "docker-compose logs -f",
20-
"docker:status": "docker-compose ps"
11+
"build-only": "vite build",
12+
"lint": "eslint .",
13+
"format:check": "prettier --check .",
14+
"format": "prettier --write .",
15+
"type-check": "tsc --noEmit"
2116
},
2217
"dependencies": {
2318
"@dnd-kit/core": "^6.3.1",
@@ -64,6 +59,7 @@
6459
"eslint-plugin-react-refresh": "^0.4.20",
6560
"globals": "^16.4.0",
6661
"nodemon": "^3.1.10",
62+
"prettier": "^3.6.2",
6763
"typescript": "~5.8.3",
6864
"typescript-eslint": "^8.44.0",
6965
"vite": "^7.1.7"

src/components/modals/ContactAcarsModal.tsx

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { useState, useEffect } from 'react';
22
import { X, Radio, Plane, MapPin } from 'lucide-react';
3+
import { fetchFrequencies } from '../../utils/fetch/data';
4+
import type { AirportFrequency } from '../../types/airports';
5+
import type { Flight } from '../../types/flight';
36
import Button from '../common/Button';
47
import Dropdown from '../common/Dropdown';
5-
import type { Flight } from '../../types/flight';
6-
import { fetchFrequencies } from '../../utils/fetch/data';
78

89
interface ContactAcarsModalProps {
910
isOpen: boolean;
@@ -26,24 +27,31 @@ export default function ContactAcarsModal({
2627
const [customMessage, setCustomMessage] = useState('');
2728
const [sending, setSending] = useState(false);
2829
const [selectedPosition, setSelectedPosition] = useState<string>('TWR');
29-
const [frequencies, setFrequencies] = useState<{ type: string; freq: string }[]>([]);
30+
const [frequencies, setFrequencies] = useState<
31+
{ type: string; freq: string }[]
32+
>([]);
3033

31-
const flightsWithAcars = flights.filter(f => activeAcarsFlights.has(f.id));
34+
const flightsWithAcars = flights.filter((f) =>
35+
activeAcarsFlights.has(f.id)
36+
);
3237

3338
useEffect(() => {
3439
const loadFrequencies = async () => {
3540
try {
36-
const freqData = await fetchFrequencies();
37-
const airportFreq = freqData.find((f: any) => f.icao === airportIcao);
38-
const freqs = Array.isArray(airportFreq?.frequencies) ? airportFreq.frequencies : [];
41+
const freqData: AirportFrequency[] = await fetchFrequencies();
42+
const airportFreq = freqData.find(
43+
(f: AirportFrequency) => f.icao === airportIcao
44+
);
45+
const freqs = Array.isArray(airportFreq?.frequencies)
46+
? airportFreq.frequencies
47+
: [];
3948
setFrequencies(freqs);
4049

41-
// Set default position to first available frequency, preferring TWR
4250
if (freqs.length > 0) {
43-
const twr = freqs.find(f => f.type === 'TWR');
51+
const twr = freqs.find((f) => f.type === 'TWR');
4452
setSelectedPosition(twr ? 'TWR' : freqs[0].type);
4553
}
46-
} catch (error) {
54+
} catch {
4755
setFrequencies([]);
4856
}
4957
};
@@ -54,7 +62,7 @@ export default function ContactAcarsModal({
5462
}, [airportIcao]);
5563

5664
const getDefaultMessage = () => {
57-
const freq = frequencies.find(f => f.type === selectedPosition);
65+
const freq = frequencies.find((f) => f.type === selectedPosition);
5866
if (freq) {
5967
return `CONTACT ME ON ${airportIcao}_${selectedPosition} ${freq.freq}`;
6068
}
@@ -91,7 +99,9 @@ export default function ContactAcarsModal({
9199
<Radio className="h-6 w-6 text-blue-400" />
92100
</div>
93101
<div>
94-
<h3 className="text-xl font-semibold">Contact ACARS Terminal</h3>
102+
<h3 className="text-xl font-semibold">
103+
Contact ACARS Terminal
104+
</h3>
95105
<p className="text-sm text-gray-400 mt-1">
96106
Send a message to a flight's ACARS terminal
97107
</p>
@@ -112,7 +122,9 @@ export default function ContactAcarsModal({
112122
<div className="text-center py-8 text-gray-400">
113123
<Radio className="h-12 w-12 mx-auto mb-3 opacity-50" />
114124
<p>No flights with active ACARS terminals</p>
115-
<p className="text-sm mt-2">Flights must open their ACARS terminal first</p>
125+
<p className="text-sm mt-2">
126+
Flights must open their ACARS terminal first
127+
</p>
116128
</div>
117129
) : (
118130
<>
@@ -125,7 +137,9 @@ export default function ContactAcarsModal({
125137
{flightsWithAcars.map((flight) => (
126138
<button
127139
key={flight.id}
128-
onClick={() => setSelectedFlight(flight)}
140+
onClick={() =>
141+
setSelectedFlight(flight)
142+
}
129143
className={`w-full text-left p-4 rounded-lg border-2 transition-all ${
130144
selectedFlight?.id === flight.id
131145
? 'border-blue-500 bg-blue-500/10'
@@ -141,11 +155,13 @@ export default function ContactAcarsModal({
141155
</div>
142156
<div className="text-sm text-gray-400 flex items-center gap-2 mt-1">
143157
<MapPin className="h-3 w-3" />
144-
{flight.departure}{flight.arrival}
158+
{flight.departure}{' '}
159+
{flight.arrival}
145160
</div>
146161
</div>
147162
</div>
148-
{selectedFlight?.id === flight.id && (
163+
{selectedFlight?.id ===
164+
flight.id && (
149165
<div className="h-5 w-5 rounded-full bg-blue-500 flex items-center justify-center">
150166
<div className="h-2 w-2 rounded-full bg-white"></div>
151167
</div>
@@ -168,9 +184,9 @@ export default function ContactAcarsModal({
168184
Contact as
169185
</label>
170186
<Dropdown
171-
options={frequencies.map(freq => ({
187+
options={frequencies.map((freq) => ({
172188
value: freq.type,
173-
label: `${freq.type} - ${freq.freq}`
189+
label: `${freq.type} - ${freq.freq}`,
174190
}))}
175191
value={selectedPosition}
176192
onChange={setSelectedPosition}
@@ -191,7 +207,9 @@ export default function ContactAcarsModal({
191207
<input
192208
type="text"
193209
value={customMessage}
194-
onChange={(e) => setCustomMessage(e.target.value)}
210+
onChange={(e) =>
211+
setCustomMessage(e.target.value)
212+
}
195213
placeholder={getDefaultMessage()}
196214
className="w-full px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500"
197215
maxLength={100}

0 commit comments

Comments
 (0)