Refine GSX lockout
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { GSX_SERVICE_CALLED, GSX_SERVICE_FINISHED } from '../../constants';
|
||||
import { WASMDataPax } from '../../types/WASMData';
|
||||
import { LoadingState, SimBrief } from '../../types/general';
|
||||
import { ImportFlightPlanKH } from '../../utils/TFDISBImport';
|
||||
@@ -10,10 +9,11 @@ import ActionBar from '../actionbar/ActionBar';
|
||||
interface SBEntryProps {
|
||||
WASMData: WASMDataPax;
|
||||
loadingState: LoadingState;
|
||||
gsxActive: boolean;
|
||||
setLoadingState: (newState: LoadingState) => void;
|
||||
}
|
||||
|
||||
const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, setLoadingState }) => {
|
||||
const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, gsxActive, setLoadingState }) => {
|
||||
const [CGTarget, setCGTarget] = useState(WASMData.targetPayload.CGTarget);
|
||||
const [fuel, setFuel] = useState(Math.round(WASMData.livePayload.fuel));
|
||||
const [fuelEnabled, setFuelEnabled] = useState(true);
|
||||
@@ -23,7 +23,7 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, setLoadingState
|
||||
const simBrief = useSelector((state) => state.simbrief.plan);
|
||||
|
||||
const ZFW = () => {
|
||||
if (loadingState !== 'loaded' && !GSXActive()) return Math.round(WASMData.targetPayload.total);
|
||||
if (loadingState !== 'loaded' && !gsxActive) return Math.round(WASMData.targetPayload.total);
|
||||
|
||||
return Math.round(WASMData.livePayload.total);
|
||||
};
|
||||
@@ -37,13 +37,6 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, setLoadingState
|
||||
return GW() <= WASMData.limits.maxTOW;
|
||||
};
|
||||
|
||||
const GSXActive = () => {
|
||||
return (
|
||||
(WASMData.GSX.boardingState >= GSX_SERVICE_CALLED || WASMData.GSX.deboardingState >= GSX_SERVICE_CALLED) &&
|
||||
WASMData.GSX.deboardingState !== GSX_SERVICE_FINISHED
|
||||
);
|
||||
};
|
||||
|
||||
const handleInput = (input: string, maxValue: number, setter: (value: number) => void) => {
|
||||
if (!input) {
|
||||
setter(0);
|
||||
@@ -59,7 +52,7 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, setLoadingState
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!simBrief || GSXActive()) return;
|
||||
if (!simBrief || gsxActive) return;
|
||||
|
||||
setSBInFlight(true);
|
||||
|
||||
@@ -80,7 +73,7 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, setLoadingState
|
||||
|
||||
setFuel(parseFloat((SBResponse.message as SimBrief).fuel as unknown as string) ?? 0);
|
||||
setSBInFlight(false);
|
||||
}, [simBrief, GSXActive()]);
|
||||
}, [simBrief, gsxActive]);
|
||||
|
||||
useEffect(
|
||||
() =>
|
||||
@@ -110,7 +103,7 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, setLoadingState
|
||||
className={`w-1/2 rounded-lg border border-white bg-zinc-700 px-3 py-2 text-right`}
|
||||
value={fuel}
|
||||
onChange={(e) => handleInput(e.target.value, WASMData.limits.maxFuel, setFuel)}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
<button
|
||||
className="middle none center rounded-lg bg-green-600 px-6 py-3 font-sans text-xs font-bold uppercase text-white shadow-md shadow-green-500/20 transition-all hover:shadow-lg hover:shadow-green-500/40 focus:opacity-[0.85] focus:shadow-none active:opacity-[0.85] active:shadow-none disabled:pointer-events-none disabled:opacity-50 disabled:shadow-none"
|
||||
@@ -124,7 +117,7 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, setLoadingState
|
||||
SimVar.SetSimVarValue('L:MD11_EFB_READ_READY', 'bool', true);
|
||||
setFuelEnabled(WASMData.livePayload.fuel === fuel);
|
||||
}}
|
||||
disabled={loadingState !== 'preview' || !fuelEnabled || GSXActive()}
|
||||
disabled={loadingState !== 'preview' || !fuelEnabled || gsxActive}
|
||||
>
|
||||
Load Fuel
|
||||
</button>
|
||||
@@ -166,7 +159,7 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, setLoadingState
|
||||
minCG={WASMData.limits.minCG}
|
||||
maxCG={WASMData.limits.maxCG}
|
||||
value={CGTarget}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
increase={() =>
|
||||
setCGTarget((prev) => {
|
||||
const _new = prev + 0.1;
|
||||
@@ -190,7 +183,7 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, setLoadingState
|
||||
<div className="flex w-full items-center justify-between rounded-t-md bg-zinc-600 p-2 px-4">
|
||||
<div className="flex w-full items-center justify-between text-xs">
|
||||
<label>
|
||||
{loadingState !== 'loaded' && !GSXActive() ? 'Expected' : 'Actual'} ZFW (
|
||||
{loadingState !== 'loaded' && !gsxActive ? 'Expected' : 'Actual'} ZFW (
|
||||
{WASMData.userData.isImperial ? 'lbs' : 'kg'})
|
||||
</label>
|
||||
<input
|
||||
@@ -205,7 +198,7 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, setLoadingState
|
||||
<div className="flex w-full items-center justify-between rounded-b-md bg-zinc-700 p-2 px-4">
|
||||
<div className="flex w-full items-center justify-between text-xs">
|
||||
<label>
|
||||
{loadingState !== 'loaded' && !GSXActive() ? 'Expected' : 'Actual'} GW (
|
||||
{loadingState !== 'loaded' && !gsxActive ? 'Expected' : 'Actual'} GW (
|
||||
{WASMData.userData.isImperial ? 'lbs' : 'kg'})
|
||||
</label>
|
||||
<input
|
||||
|
||||
Reference in New Issue
Block a user