Skip to content

Commit c864cdd

Browse files
authored
Merge pull request #146 from cephie-studios/canary
Canary
2 parents 1314524 + f748c39 commit c864cdd

3 files changed

Lines changed: 67 additions & 11 deletions

File tree

package-lock.json

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

src/pages/ACARS.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from 'lucide-react';
1313
import { useData } from '../hooks/data/useData';
1414
import { useSettings } from '../hooks/settings/useSettings';
15+
import { useAuth } from '../hooks/auth/useAuth';
1516
import { createFlightsSocket } from '../sockets/flightsSocket';
1617
import {
1718
createOverviewSocket,
@@ -22,11 +23,13 @@ import { getChartsForAirport, playNotificationSound } from '../utils/acars';
2223
import { createChartHandlers } from '../utils/charts';
2324
import type { AcarsMessage } from '../types/acars';
2425
import type { Flight } from '../types/flight';
26+
import type { SessionInfo } from '../types/session';
2527

2628
import AcarsSidebar from '../components/acars/AcarsSidebar';
2729
import AcarsTerminal from '../components/acars/AcarsTerminal';
2830
import AcarsNotePanel from '../components/acars/AcarsNotePanel';
2931
import ChartDrawer from '../components/tools/ChartDrawer';
32+
import ControllerRatingPopup from '../components/tools/ControllerRatingPopup';
3033

3134
export default function ACARS() {
3235
const { sessionId, flightId } = useParams<{
@@ -36,10 +39,13 @@ export default function ACARS() {
3639
const [searchParams] = useSearchParams();
3740
const accessId = searchParams.get('acars_token');
3841
const navigate = useNavigate();
42+
const { user } = useAuth();
3943
const { airports, airlines, loading: dataLoading } = useData();
4044
const { settings, loading: settingsLoading } = useSettings();
4145
const [loading, setLoading] = useState(true);
4246
const [flight, setFlight] = useState<Flight | null>(null);
47+
const [session, setSession] = useState<SessionInfo | null>(null);
48+
const [showRating, setShowRating] = useState(false);
4349
const [messages, setMessages] = useState<AcarsMessage[]>([]);
4450
const [activeSessions, setActiveSessions] = useState<OverviewSession[]>([]);
4551
const [error, setError] = useState<string | null>(null);
@@ -231,6 +237,16 @@ NOTES:
231237
await validateResponse.json();
232238
if (!valid) throw new Error('Invalid access token');
233239
setSessionAccessId(sessionAccess);
240+
241+
const sessionResponse = await fetch(
242+
`${import.meta.env.VITE_SERVER_URL}/api/sessions/${sessionId}/submit`,
243+
{ credentials: 'include' }
244+
);
245+
if (sessionResponse.ok) {
246+
const sessionData = await sessionResponse.json();
247+
setSession(sessionData);
248+
}
249+
234250
const flightResponse = await fetch(
235251
`${import.meta.env.VITE_SERVER_URL}/api/flights/${sessionId}`,
236252
{ credentials: 'include' }
@@ -403,6 +419,18 @@ NOTES:
403419
};
404420
}, []);
405421

422+
useEffect(() => {
423+
if (
424+
session &&
425+
flight &&
426+
user &&
427+
session.createdBy !== user.userId &&
428+
(settings?.acars?.autoRedirectToAcars ?? true)
429+
) {
430+
setShowRating(true);
431+
}
432+
}, [session, flight, user, settings?.acars?.autoRedirectToAcars]);
433+
406434
const addPDCMessage = (text: string) => {
407435
const message: AcarsMessage = {
408436
id: `${Date.now()}-${Math.random()}`,
@@ -637,6 +665,18 @@ NOTES:
637665
</div>
638666
</div>
639667

668+
{/* Controller Rating Popup */}
669+
{showRating && session?.createdBy && (
670+
<div className="max-w-3xl mx-auto px-4 pt-6">
671+
<ControllerRatingPopup
672+
controllerId={session.createdBy}
673+
flightId={flightId}
674+
onClose={() => setShowRating(false)}
675+
isInline={true}
676+
/>
677+
</div>
678+
)}
679+
640680
{/* Desktop Layout */}
641681
<div
642682
className="hidden md:flex gap-4 pt-4 px-6 pb-6"

src/pages/Submit.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ export default function Submit() {
9393
session?.isPFATC &&
9494
(settings?.acars?.autoRedirectToAcars ?? true)
9595
) {
96-
if (session?.createdBy && session.createdBy !== user?.userId) return;
9796
navigate(
9897
`/acars/${sessionId}/${submittedFlight.id}?acars_token=${submittedFlight.acars_token}`
9998
);

0 commit comments

Comments
 (0)