Check prog pax load/unload

This commit is contained in:
2025-06-14 16:47:27 +02:00
parent c394cd4d7b
commit cbd7d4e0ae
11 changed files with 73 additions and 79 deletions
@@ -1,23 +1,22 @@
import { FC, useEffect, useState } from 'react';
import { unloadAircraft } from '../../configs/shared';
import {
COHERENT_COMBUS_WASM_CALL,
COHERENT_COMM_BUS_WASM_CALL,
COMM_BUS_UPDATE_TARGET_EVENT,
GSX_SERVICE_CALLED,
GSX_SERVICE_FINISHED,
} from '../../constants';
import { LoadingState } from '../../types/general';
import { WASMDataPax } from '../../types/WASMData';
import { inRangeOf, loadAircraft, unloadAircraft } from '../../utils/utils';
import ActionBar from '../actionbar/ActionBar';
interface StationEntryProps {
WASMData: WASMDataPax;
loadingState: LoadingState;
setLoadingState: (newState: LoadingState) => void;
loadAircraft: () => void;
}
const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadingState, loadAircraft }) => {
const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadingState }) => {
const [business1, setBusiness1] = useState(WASMData.targetPayload.business1);
const [business2, setBusiness2] = useState(WASMData.targetPayload.business2);
const [economy1, setEconomy1] = useState(WASMData.targetPayload.economy1);
@@ -28,7 +27,7 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
const [fuelEnabled, setFuelEnabled] = useState(true);
const ZFW = () => {
if (loadingState !== 'loaded') return Math.round(WASMData.targetPayload.total);
if (loadingState !== 'loaded' && !GSXActive()) return Math.round(WASMData.targetPayload.total);
return Math.round(WASMData.livePayload.total);
};
@@ -73,12 +72,12 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
[WASMData.userData.isER]
);
useEffect(() => {
setFuelEnabled(Math.round(WASMData.livePayload.fuel) === fuel);
setFuelEnabled(inRangeOf(Math.round(WASMData.livePayload.fuel), fuel));
}, [WASMData.livePayload.fuel]);
const updateData = () => {
Coherent.call(
COHERENT_COMBUS_WASM_CALL,
COHERENT_COMM_BUS_WASM_CALL,
COMM_BUS_UPDATE_TARGET_EVENT,
JSON.stringify({
mode: 2,
@@ -196,7 +195,8 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
<div className="block flex w-full flex-col opacity-100 transition-opacity duration-150 ease-linear mb-4">
<div className="relative flex w-full items-center justify-between rounded-t-md bg-zinc-600 p-2 px-4">
<label>
{loadingState !== 'loaded' ? 'Expected' : 'Actual'} ZFW ({WASMData.userData.isImperial ? 'lbs' : 'kg'})
{loadingState !== 'loaded' && !GSXActive() ? 'Expected' : 'Actual'} ZFW (
{WASMData.userData.isImperial ? 'lbs' : 'kg'})
</label>
<input
type="text"
@@ -208,7 +208,8 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
</div>
<div className="relative flex w-full items-center justify-between rounded-b-md bg-zinc-700 p-2 px-4">
<label>
{loadingState !== 'loaded' ? 'Expected' : 'Actual'} GW ({WASMData.userData.isImperial ? 'lbs' : 'kg'})
{loadingState !== 'loaded' && !GSXActive() ? 'Expected' : 'Actual'} GW (
{WASMData.userData.isImperial ? 'lbs' : 'kg'})
</label>
<input
type="text"