Refine GSX lockout
This commit is contained in:
parent
95637c9f7f
commit
d75518517a
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tfdidesign-md11-load-manager",
|
||||
"version": "0.1.98",
|
||||
"version": "0.1.116",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
@ -30,6 +30,7 @@
|
||||
"@rollup/plugin-replace": "^6.0.2",
|
||||
"@rollup/plugin-terser": "^0.4.4",
|
||||
"@rollup/plugin-typescript": "^12.1.2",
|
||||
"@types/node": "^24.3.1",
|
||||
"@types/react": "^19.1.6",
|
||||
"@types/react-dom": "^19.1.6",
|
||||
"@types/uuid": "^10.0.0",
|
||||
|
||||
21
PackageSources/js-bundle/pnpm-lock.yaml
generated
21
PackageSources/js-bundle/pnpm-lock.yaml
generated
@ -39,6 +39,9 @@ importers:
|
||||
'@rollup/plugin-typescript':
|
||||
specifier: ^12.1.2
|
||||
version: 12.1.2(rollup@4.42.0)(tslib@2.8.1)(typescript@5.8.3)
|
||||
'@types/node':
|
||||
specifier: ^24.3.1
|
||||
version: 24.3.1
|
||||
'@types/react':
|
||||
specifier: ^19.1.6
|
||||
version: 19.1.6
|
||||
@ -728,8 +731,8 @@ packages:
|
||||
'@types/minimatch@5.1.2':
|
||||
resolution: {integrity: sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==}
|
||||
|
||||
'@types/node@22.15.30':
|
||||
resolution: {integrity: sha512-6Q7lr06bEHdlfplU6YRbgG1SFBdlsfNC4/lX+SkhiTs0cpJkOElmWls8PxDFv4yY/xKb8Y6SO0OmSX4wgqTZbA==}
|
||||
'@types/node@24.3.1':
|
||||
resolution: {integrity: sha512-3vXmQDXy+woz+gnrTvuvNrPzekOi+Ds0ReMxw0LzBiK3a+1k0kQn9f2NWk+lgD4rJehFUmYy2gMhJ2ZI+7YP9g==}
|
||||
|
||||
'@types/q@1.5.8':
|
||||
resolution: {integrity: sha512-hroOstUScF6zhIi+5+x0dzqrHA1EJi+Irri6b1fxolMTqqHIV/Cg77EtnQcZqZCu8hR3mX2BzIxN4/GzI68Kfw==}
|
||||
@ -2788,8 +2791,8 @@ packages:
|
||||
resolution: {integrity: sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
undici-types@6.21.0:
|
||||
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
|
||||
undici-types@7.10.0:
|
||||
resolution: {integrity: sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag==}
|
||||
|
||||
universalify@0.1.2:
|
||||
resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==}
|
||||
@ -3389,12 +3392,12 @@ snapshots:
|
||||
|
||||
'@types/fs-extra@8.1.5':
|
||||
dependencies:
|
||||
'@types/node': 22.15.30
|
||||
'@types/node': 24.3.1
|
||||
|
||||
'@types/glob@7.2.0':
|
||||
dependencies:
|
||||
'@types/minimatch': 5.1.2
|
||||
'@types/node': 22.15.30
|
||||
'@types/node': 24.3.1
|
||||
|
||||
'@types/http-cache-semantics@4.0.4': {}
|
||||
|
||||
@ -3404,9 +3407,9 @@ snapshots:
|
||||
|
||||
'@types/minimatch@5.1.2': {}
|
||||
|
||||
'@types/node@22.15.30':
|
||||
'@types/node@24.3.1':
|
||||
dependencies:
|
||||
undici-types: 6.21.0
|
||||
undici-types: 7.10.0
|
||||
|
||||
'@types/q@1.5.8': {}
|
||||
|
||||
@ -5828,7 +5831,7 @@ snapshots:
|
||||
has-symbols: 1.1.0
|
||||
which-boxed-primitive: 1.1.1
|
||||
|
||||
undici-types@6.21.0: {}
|
||||
undici-types@7.10.0: {}
|
||||
|
||||
universalify@0.1.2: {}
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@ import commonjs from '@rollup/plugin-commonjs';
|
||||
import json from '@rollup/plugin-json';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import replace from '@rollup/plugin-replace';
|
||||
import terser from '@rollup/plugin-terser';
|
||||
import typescript from '@rollup/plugin-typescript';
|
||||
import autoprefixer from 'autoprefixer';
|
||||
import atImport from 'postcss-import';
|
||||
@ -31,9 +30,7 @@ export default {
|
||||
},
|
||||
plugins: [
|
||||
replace({
|
||||
'process.env.NODE_ENV': JSON.stringify(targetEnv),
|
||||
'import.meta.env': true,
|
||||
'import.meta.env.MODE': JSON.stringify(targetEnv),
|
||||
'process.env.NODE_ENV': `"${targetEnv}"`,
|
||||
}),
|
||||
versionInjector(),
|
||||
postcss({
|
||||
@ -50,7 +47,7 @@ export default {
|
||||
commonjs({
|
||||
requireReturnsDefault: 'auto',
|
||||
}),
|
||||
targetEnv === 'production' && terser(),
|
||||
// targetEnv === 'production' && terser(), // Disabled due to script running afterwards
|
||||
copy({
|
||||
targets: [{ src: ['src/assets/*', '!**/*.svg'], dest: `${panelDirBase}/assets` }],
|
||||
}),
|
||||
|
||||
@ -23,6 +23,8 @@ const App: FC = () => {
|
||||
setWASMData(JSON.parse(data));
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
console.log('TFDi MD-11 Load Manager version [VI]{version}[/VI]:', process.env.NODE_ENV, '[VI]{date}[/VI]');
|
||||
|
||||
console.log('Initializing CommBus');
|
||||
|
||||
const commBus = RegisterViewListener('JS_LISTENER_COMM_BUS');
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
| kessler | stuff | @rollup/plugin-replace | perpetual | material | MIT | git+https://github.com/rollup/plugins.git | 6.0.2 | 6.0.2 | ^6.0.2 | Rich Harris <richard.a.harris@gmail.com> |
|
||||
| kessler | stuff | @rollup/plugin-terser | perpetual | material | MIT | git+https://github.com/rollup/plugins.git | 0.4.4 | 0.4.4 | ^0.4.4 | Peter Placzek <peter.placzek1996@gmail.com> |
|
||||
| kessler | stuff | @rollup/plugin-typescript | perpetual | material | MIT | git+https://github.com/rollup/plugins.git | 12.1.4 | 12.1.2 | ^12.1.2 | Oskar Segersvärd |
|
||||
| kessler | stuff | @types/node | perpetual | material | MIT | https://github.com/DefinitelyTyped/DefinitelyTyped.git | 24.3.1 | 24.3.1 | ^24.3.1 | n/a |
|
||||
| kessler | stuff | @types/react | perpetual | material | MIT | https://github.com/DefinitelyTyped/DefinitelyTyped.git | 19.1.12 | 19.1.6 | ^19.1.6 | n/a |
|
||||
| kessler | stuff | @types/react-dom | perpetual | material | MIT | https://github.com/DefinitelyTyped/DefinitelyTyped.git | 19.1.9 | 19.1.6 | ^19.1.6 | n/a |
|
||||
| kessler | stuff | @types/uuid | perpetual | material | MIT | https://github.com/DefinitelyTyped/DefinitelyTyped.git | 10.0.0 | 10.0.0 | ^10.0.0 | n/a |
|
||||
@ -27,12 +28,12 @@
|
||||
| kessler | stuff | prettier | perpetual | material | MIT | git+https://github.com/prettier/prettier.git | 3.6.2 | 3.5.3 | ^3.5.3 | James Long |
|
||||
| kessler | stuff | prettier-plugin-organize-imports | perpetual | material | MIT | git+https://github.com/simonhaenisch/prettier-plugin-organize-imports.git | 4.2.0 | 4.1.0 | ^4.1.0 | Simon Haenisch (https://github.com/simonhaenisch) |
|
||||
| kessler | stuff | rimraf | perpetual | material | ISC | git://github.com/isaacs/rimraf.git | 6.0.1 | 6.0.1 | ^6.0.1 | Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/) |
|
||||
| kessler | stuff | rollup | perpetual | material | MIT | git+https://github.com/rollup/rollup.git | 4.50.0 | 4.42.0 | ^4.42.0 | Rich Harris |
|
||||
| kessler | stuff | rollup | perpetual | material | MIT | git+https://github.com/rollup/rollup.git | 4.50.1 | 4.42.0 | ^4.42.0 | Rich Harris |
|
||||
| kessler | stuff | rollup-plugin-copy | perpetual | material | MIT | git+https://github.com/vladshcherbin/rollup-plugin-copy.git | 3.5.0 | 3.5.0 | ^3.5.0 | Vlad Shcherbin <vlad.shcherbin@gmail.com> |
|
||||
| kessler | stuff | rollup-plugin-postcss | perpetual | material | MIT | git+https://github.com/egoist/rollup-plugin-postcss.git | 4.0.2 | 4.0.2 | ^4.0.2 | EGOIST <0x142857@gmail.com> |
|
||||
| kessler | stuff | rollup-plugin-react-svg | perpetual | material | MIT | git+https://github.com/boopathi/react-svg-loader.git | 3.0.3 | 3.0.3 | ^3.0.3 | boopathi |
|
||||
| kessler | stuff | rollup-plugin-version-injector | perpetual | material | ISC | git+https://github.com/djhouseknecht/rollup-plugin-version-injector.git | 1.3.3 | 1.3.3 | ^1.3.3 | David Houseknecht <david.j.houseknecht@gmail.com> |
|
||||
| kessler | stuff | sass | perpetual | material | MIT | git+https://github.com/sass/dart-sass.git | 1.92.0 | 1.89.1 | ^1.89.1 | Natalie Weizenbaum nweiz@google.com https://github.com/nex3 |
|
||||
| kessler | stuff | sass | perpetual | material | MIT | git+https://github.com/sass/dart-sass.git | 1.92.1 | 1.89.1 | ^1.89.1 | Natalie Weizenbaum nweiz@google.com https://github.com/nex3 |
|
||||
| kessler | stuff | tslib | perpetual | material | 0BSD | git+https://github.com/Microsoft/tslib.git | 2.8.1 | 2.8.1 | ^2.8.1 | Microsoft Corp. |
|
||||
| kessler | stuff | typed-scss-modules | perpetual | material | MIT | git+https://github.com/skovy/typed-scss-modules.git | 8.1.1 | 8.1.1 | ^8.1.1 | Spencer Miskoviak <smiskoviak@gmail.com> |
|
||||
| kessler | stuff | typescript | perpetual | material | Apache-2.0 | git+https://github.com/microsoft/TypeScript.git | 5.8.3 | 5.8.3 | 5.8.3 | Microsoft Corp. |
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { GSX_SERVICE_CALLED, GSX_SERVICE_FINISHED } from '../../constants';
|
||||
import { WASMDataF } 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: WASMDataF;
|
||||
loadingState: LoadingState;
|
||||
gsxActive: boolean;
|
||||
setLoadingState: (newState: LoadingState) => void;
|
||||
}
|
||||
|
||||
const SBEntryF: FC<SBEntryProps> = ({ WASMData, loadingState, setLoadingState }) => {
|
||||
const SBEntryF: 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 SBEntryF: 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 SBEntryF: 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 SBEntryF: FC<SBEntryProps> = ({ WASMData, loadingState, setLoadingState })
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!simBrief || GSXActive()) return;
|
||||
if (!simBrief || gsxActive) return;
|
||||
|
||||
setSBInFlight(true);
|
||||
|
||||
@ -80,7 +73,7 @@ const SBEntryF: 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 SBEntryF: 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 SBEntryF: 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 SBEntryF: 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 SBEntryF: FC<SBEntryProps> = ({ WASMData, loadingState, setLoadingState })
|
||||
<div className="relative 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 SBEntryF: FC<SBEntryProps> = ({ WASMData, loadingState, setLoadingState })
|
||||
<div className="relative 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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -17,6 +17,25 @@ interface FreighterProps {
|
||||
const Freighter: FC<FreighterProps> = ({ WASMData, username }) => {
|
||||
const [selectedTab, setSelectedTab] = useState(0);
|
||||
const [loadingState, setLoadingState] = useState<LoadingState>('preview');
|
||||
const [boardingState, setBoardingState] = useState(1);
|
||||
const [deboardingState, setDeboardingState] = useState(1);
|
||||
|
||||
useEffect(() => {
|
||||
console.log('GSX boarding state changed', boardingState, WASMData.GSX.boardingState);
|
||||
|
||||
if (WASMData.GSX.boardingState < GSX_SERVICE_CALLED) return;
|
||||
|
||||
setBoardingState(WASMData.GSX.boardingState);
|
||||
setDeboardingState(1);
|
||||
}, [WASMData.GSX.boardingState]);
|
||||
useEffect(() => {
|
||||
console.log('GSX deboarding state changed', deboardingState, WASMData.GSX.deboardingState);
|
||||
|
||||
if (WASMData.GSX.deboardingState < GSX_SERVICE_CALLED) return;
|
||||
|
||||
setBoardingState(1);
|
||||
setDeboardingState(WASMData.GSX.deboardingState);
|
||||
}, [WASMData.GSX.deboardingState]);
|
||||
|
||||
const upper1 = (overrideState: LoadingState = loadingState) => {
|
||||
if (overrideState !== 'loaded') return Math.round(WASMData.targetPayload.upper1);
|
||||
@ -60,9 +79,17 @@ const Freighter: FC<FreighterProps> = ({ WASMData, username }) => {
|
||||
};
|
||||
|
||||
const GSXActive = () => {
|
||||
// Cases when active:
|
||||
// BOARDING called, running or done
|
||||
// DEBOARDING called, running or done
|
||||
// Cases when not active:
|
||||
// BOARDING not called, disabled
|
||||
// DEBOARDING not called, disabled
|
||||
// BOTH done
|
||||
|
||||
return (
|
||||
(WASMData.GSX.boardingState >= GSX_SERVICE_CALLED || WASMData.GSX.deboardingState >= GSX_SERVICE_CALLED) &&
|
||||
WASMData.GSX.deboardingState !== GSX_SERVICE_FINISHED
|
||||
(boardingState >= GSX_SERVICE_CALLED || deboardingState >= GSX_SERVICE_CALLED) &&
|
||||
deboardingState !== GSX_SERVICE_FINISHED
|
||||
);
|
||||
};
|
||||
|
||||
@ -76,7 +103,7 @@ const Freighter: FC<FreighterProps> = ({ WASMData, username }) => {
|
||||
];
|
||||
}
|
||||
|
||||
if (WASMData.options.GSXSync && GSXActive() && WASMData.GSX.boardingState !== GSX_SERVICE_FINISHED) {
|
||||
if (WASMData.options.GSXSync && GSXActive() && boardingState !== GSX_SERVICE_FINISHED) {
|
||||
return [
|
||||
WASMData.targetPayload.ZFWCG.toFixed(1),
|
||||
WASMData.targetPayload.ZFWCG < WASMData.limits.minCG || WASMData.targetPayload.ZFWCG > WASMData.limits.maxCG,
|
||||
@ -115,8 +142,7 @@ const Freighter: FC<FreighterProps> = ({ WASMData, username }) => {
|
||||
CGs={CGs()}
|
||||
done={
|
||||
WASMData.options.GSXSync
|
||||
? WASMData.GSX.boardingState === GSX_SERVICE_FINISHED &&
|
||||
WASMData.GSX.deboardingState !== GSX_SERVICE_FINISHED
|
||||
? boardingState === GSX_SERVICE_FINISHED && deboardingState !== GSX_SERVICE_FINISHED
|
||||
: loadingState !== 'preview'
|
||||
}
|
||||
/>
|
||||
@ -128,13 +154,28 @@ const Freighter: FC<FreighterProps> = ({ WASMData, username }) => {
|
||||
setSelectedTab={setSelectedTab}
|
||||
/>
|
||||
{username && selectedTab === 0 && (
|
||||
<SBEntryF WASMData={WASMData} loadingState={loadingState} setLoadingState={setLoadingState} />
|
||||
<SBEntryF
|
||||
WASMData={WASMData}
|
||||
loadingState={loadingState}
|
||||
setLoadingState={setLoadingState}
|
||||
gsxActive={GSXActive()}
|
||||
/>
|
||||
)}
|
||||
{((username && selectedTab === 1) || (!username && selectedTab === 0)) && (
|
||||
<ZFWEntryF WASMData={WASMData} loadingState={loadingState} setLoadingState={setLoadingState} />
|
||||
<ZFWEntryF
|
||||
WASMData={WASMData}
|
||||
loadingState={loadingState}
|
||||
setLoadingState={setLoadingState}
|
||||
gsxActive={GSXActive()}
|
||||
/>
|
||||
)}
|
||||
{((username && selectedTab === 2) || (!username && selectedTab === 1)) && (
|
||||
<StationEntryF WASMData={WASMData} loadingState={loadingState} setLoadingState={setLoadingState} />
|
||||
<StationEntryF
|
||||
WASMData={WASMData}
|
||||
loadingState={loadingState}
|
||||
setLoadingState={setLoadingState}
|
||||
gsxActive={GSXActive()}
|
||||
/>
|
||||
)}
|
||||
{((username && selectedTab === 3) || (!username && selectedTab === 2)) && (
|
||||
<OptionsF WASMData={WASMData} loadingState={loadingState} />
|
||||
|
||||
@ -17,6 +17,25 @@ interface PaxProps {
|
||||
const Pax: FC<PaxProps> = ({ WASMData, username }) => {
|
||||
const [selectedTab, setSelectedTab] = useState(0);
|
||||
const [loadingState, setLoadingState] = useState<LoadingState>('preview');
|
||||
const [boardingState, setBoardingState] = useState(1);
|
||||
const [deboardingState, setDeboardingState] = useState(1);
|
||||
|
||||
useEffect(() => {
|
||||
console.log('GSX boarding state changed', boardingState, WASMData.GSX.boardingState);
|
||||
|
||||
if (WASMData.GSX.boardingState < GSX_SERVICE_CALLED) return;
|
||||
|
||||
setBoardingState(WASMData.GSX.boardingState);
|
||||
setDeboardingState(1);
|
||||
}, [WASMData.GSX.boardingState]);
|
||||
useEffect(() => {
|
||||
console.log('GSX deboarding state changed', deboardingState, WASMData.GSX.deboardingState);
|
||||
|
||||
if (WASMData.GSX.deboardingState < GSX_SERVICE_CALLED) return;
|
||||
|
||||
setBoardingState(1);
|
||||
setDeboardingState(WASMData.GSX.deboardingState);
|
||||
}, [WASMData.GSX.deboardingState]);
|
||||
|
||||
const upper1 = (overrideState: LoadingState = loadingState) => {
|
||||
if (overrideState !== 'loaded') return WASMData.targetPayload.business1;
|
||||
@ -60,9 +79,17 @@ const Pax: FC<PaxProps> = ({ WASMData, username }) => {
|
||||
};
|
||||
|
||||
const GSXActive = () => {
|
||||
// Cases when active:
|
||||
// BOARDING called, running or done
|
||||
// DEBOARDING called, running or done
|
||||
// Cases when not active:
|
||||
// BOARDING not called, disabled
|
||||
// DEBOARDING not called, disabled
|
||||
// BOTH done
|
||||
|
||||
return (
|
||||
(WASMData.GSX.boardingState >= GSX_SERVICE_CALLED || WASMData.GSX.deboardingState >= GSX_SERVICE_CALLED) &&
|
||||
WASMData.GSX.deboardingState !== GSX_SERVICE_FINISHED
|
||||
(boardingState >= GSX_SERVICE_CALLED || deboardingState >= GSX_SERVICE_CALLED) &&
|
||||
deboardingState !== GSX_SERVICE_FINISHED
|
||||
);
|
||||
};
|
||||
|
||||
@ -76,7 +103,7 @@ const Pax: FC<PaxProps> = ({ WASMData, username }) => {
|
||||
];
|
||||
}
|
||||
|
||||
if (WASMData.options.GSXSync && GSXActive() && WASMData.GSX.boardingState !== GSX_SERVICE_FINISHED) {
|
||||
if (WASMData.options.GSXSync && GSXActive() && boardingState !== GSX_SERVICE_FINISHED) {
|
||||
return [
|
||||
WASMData.targetPayload.ZFWCG.toFixed(1),
|
||||
WASMData.targetPayload.ZFWCG < WASMData.limits.minCG || WASMData.targetPayload.ZFWCG > WASMData.limits.maxCG,
|
||||
@ -119,8 +146,7 @@ const Pax: FC<PaxProps> = ({ WASMData, username }) => {
|
||||
CGs={CGs()}
|
||||
done={
|
||||
WASMData.options.GSXSync
|
||||
? WASMData.GSX.boardingState === GSX_SERVICE_FINISHED &&
|
||||
WASMData.GSX.deboardingState !== GSX_SERVICE_FINISHED
|
||||
? boardingState === GSX_SERVICE_FINISHED && deboardingState !== GSX_SERVICE_FINISHED
|
||||
: loadingState !== 'preview'
|
||||
}
|
||||
/>
|
||||
@ -132,13 +158,28 @@ const Pax: FC<PaxProps> = ({ WASMData, username }) => {
|
||||
setSelectedTab={setSelectedTab}
|
||||
/>
|
||||
{username && selectedTab === 0 && (
|
||||
<SBEntryPax WASMData={WASMData} loadingState={loadingState} setLoadingState={setLoadingState} />
|
||||
<SBEntryPax
|
||||
WASMData={WASMData}
|
||||
loadingState={loadingState}
|
||||
setLoadingState={setLoadingState}
|
||||
gsxActive={GSXActive()}
|
||||
/>
|
||||
)}
|
||||
{((username && selectedTab === 1) || (!username && selectedTab === 0)) && (
|
||||
<ZFWEntryPax WASMData={WASMData} loadingState={loadingState} setLoadingState={setLoadingState} />
|
||||
<ZFWEntryPax
|
||||
WASMData={WASMData}
|
||||
loadingState={loadingState}
|
||||
setLoadingState={setLoadingState}
|
||||
gsxActive={GSXActive()}
|
||||
/>
|
||||
)}
|
||||
{((username && selectedTab === 2) || (!username && selectedTab === 1)) && (
|
||||
<StationEntryPax WASMData={WASMData} loadingState={loadingState} setLoadingState={setLoadingState} />
|
||||
<StationEntryPax
|
||||
WASMData={WASMData}
|
||||
loadingState={loadingState}
|
||||
setLoadingState={setLoadingState}
|
||||
gsxActive={GSXActive()}
|
||||
/>
|
||||
)}
|
||||
{((username && selectedTab === 3) || (!username && selectedTab === 2)) && (
|
||||
<OptionsPax WASMData={WASMData} loadingState={loadingState} />
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { GSX_SERVICE_CALLED, GSX_SERVICE_FINISHED } from '../../constants';
|
||||
import { LoadingState } from '../../types/general';
|
||||
import { WASMDataF } from '../../types/WASMData';
|
||||
import { CoherentCallStationEntryF, inRangeOf, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
@ -8,10 +7,11 @@ import ActionBar from '../actionbar/ActionBar';
|
||||
interface StationEntryProps {
|
||||
WASMData: WASMDataF;
|
||||
loadingState: LoadingState;
|
||||
gsxActive: boolean;
|
||||
setLoadingState: (newState: LoadingState) => void;
|
||||
}
|
||||
|
||||
const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadingState }) => {
|
||||
const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, gsxActive, setLoadingState }) => {
|
||||
const [upper1, setUpper1] = useState(WASMData.targetPayload.upper1);
|
||||
const [upper2, setUpper2] = useState(WASMData.targetPayload.upper2);
|
||||
const [upper3, setUpper3] = useState(WASMData.targetPayload.upper3);
|
||||
@ -22,7 +22,7 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadi
|
||||
const [fuelEnabled, setFuelEnabled] = useState(true);
|
||||
|
||||
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);
|
||||
};
|
||||
@ -36,13 +36,6 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadi
|
||||
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);
|
||||
@ -86,7 +79,7 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadi
|
||||
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"
|
||||
@ -100,7 +93,7 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadi
|
||||
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>
|
||||
@ -118,7 +111,7 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadi
|
||||
className="w-1/2 rounded-lg border border-white bg-zinc-700 px-3 py-2 text-right focus:border-blue-600 focus:ring-blue-600"
|
||||
value={upper1}
|
||||
onChange={(e) => handleInput(e.target.value, WASMData.limits.upper1, setUpper1)}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -131,7 +124,7 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadi
|
||||
className="w-1/2 rounded-lg border border-white bg-zinc-700 px-3 py-2 text-right focus:border-blue-600 focus:ring-blue-600"
|
||||
value={upper2}
|
||||
onChange={(e) => handleInput(e.target.value, WASMData.limits.upper2, setUpper2)}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -144,7 +137,7 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadi
|
||||
className="w-1/2 rounded-lg border border-white bg-zinc-700 px-3 py-2 text-right focus:border-blue-600 focus:ring-blue-600"
|
||||
value={upper3}
|
||||
onChange={(e) => handleInput(e.target.value, WASMData.limits.upper3, setUpper3)}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -157,7 +150,7 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadi
|
||||
className="w-1/2 rounded-lg border border-white bg-zinc-700 px-3 py-2 text-right focus:border-blue-600 focus:ring-blue-600"
|
||||
value={upper4}
|
||||
onChange={(e) => handleInput(e.target.value, WASMData.limits.upper4, setUpper4)}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -170,7 +163,7 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadi
|
||||
className="w-1/2 rounded-lg border border-white bg-zinc-700 px-3 py-2 text-right focus:border-blue-600 focus:ring-blue-600"
|
||||
value={lowerForward}
|
||||
onChange={(e) => handleInput(e.target.value, WASMData.limits.lowerForward, setLowerForward)}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -183,7 +176,7 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadi
|
||||
className="w-1/2 rounded-lg border border-white bg-zinc-700 px-3 py-2 text-right focus:border-blue-600 focus:ring-blue-600"
|
||||
value={lowerRear}
|
||||
onChange={(e) => handleInput(e.target.value, WASMData.limits.lowerRear, setLowerRear)}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -193,7 +186,7 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadi
|
||||
<div className="relative 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
|
||||
@ -208,7 +201,7 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadi
|
||||
<div className="relative 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
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { GSX_SERVICE_CALLED, GSX_SERVICE_FINISHED } from '../../constants';
|
||||
import { LoadingState } from '../../types/general';
|
||||
import { WASMDataPax } from '../../types/WASMData';
|
||||
import { CoherentCallStationEntryPax, inRangeOf, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
@ -8,10 +7,11 @@ import ActionBar from '../actionbar/ActionBar';
|
||||
interface StationEntryProps {
|
||||
WASMData: WASMDataPax;
|
||||
loadingState: LoadingState;
|
||||
gsxActive: boolean;
|
||||
setLoadingState: (newState: LoadingState) => void;
|
||||
}
|
||||
|
||||
const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadingState }) => {
|
||||
const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, gsxActive, setLoadingState }) => {
|
||||
const [business1, setBusiness1] = useState(WASMData.targetPayload.business1);
|
||||
const [business2, setBusiness2] = useState(WASMData.targetPayload.business2);
|
||||
const [economy1, setEconomy1] = useState(WASMData.targetPayload.economy1);
|
||||
@ -22,7 +22,7 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
|
||||
const [fuelEnabled, setFuelEnabled] = useState(true);
|
||||
|
||||
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);
|
||||
};
|
||||
@ -36,13 +36,6 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
|
||||
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);
|
||||
@ -86,7 +79,7 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
|
||||
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"
|
||||
@ -100,7 +93,7 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
|
||||
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>
|
||||
@ -118,7 +111,7 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
|
||||
className="w-1/2 rounded-lg border border-white bg-zinc-700 px-3 py-2 text-right focus:border-blue-600 focus:ring-blue-600"
|
||||
value={business1}
|
||||
onChange={(e) => handleInput(e.target.value, WASMData.limits.business1, setBusiness1)}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -131,7 +124,7 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
|
||||
className="w-1/2 rounded-lg border border-white bg-zinc-700 px-3 py-2 text-right focus:border-blue-600 focus:ring-blue-600"
|
||||
value={business2}
|
||||
onChange={(e) => handleInput(e.target.value, WASMData.limits.business2, setBusiness2)}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -144,7 +137,7 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
|
||||
className="w-1/2 rounded-lg border border-white bg-zinc-700 px-3 py-2 text-right focus:border-blue-600 focus:ring-blue-600"
|
||||
value={economy1}
|
||||
onChange={(e) => handleInput(e.target.value, WASMData.limits.economy1, setEconomy1)}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -157,7 +150,7 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
|
||||
className="w-1/2 rounded-lg border border-white bg-zinc-700 px-3 py-2 text-right focus:border-blue-600 focus:ring-blue-600"
|
||||
value={economy2}
|
||||
onChange={(e) => handleInput(e.target.value, WASMData.limits.economy2, setEconomy2)}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -170,7 +163,7 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
|
||||
className="w-1/2 rounded-lg border border-white bg-zinc-700 px-3 py-2 text-right focus:border-blue-600 focus:ring-blue-600"
|
||||
value={forwardCargo}
|
||||
onChange={(e) => handleInput(e.target.value, WASMData.limits.forwardCargo, setForwardCargo)}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -183,7 +176,7 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
|
||||
className="w-1/2 rounded-lg border border-white bg-zinc-700 px-3 py-2 text-right focus:border-blue-600 focus:ring-blue-600"
|
||||
value={rearCargo}
|
||||
onChange={(e) => handleInput(e.target.value, WASMData.limits.rearCargo, setRearCargo)}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -193,7 +186,7 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
|
||||
<div className="relative 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
|
||||
@ -208,7 +201,7 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
|
||||
<div className="relative 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
|
||||
|
||||
@ -9,17 +9,18 @@ import ActionBar from '../actionbar/ActionBar';
|
||||
interface ZFWEntryProps {
|
||||
WASMData: WASMDataF;
|
||||
loadingState: LoadingState;
|
||||
gsxActive: boolean;
|
||||
setLoadingState: (newState: LoadingState) => void;
|
||||
}
|
||||
|
||||
const ZFWEntryF: FC<ZFWEntryProps> = ({ WASMData, loadingState, setLoadingState }) => {
|
||||
const ZFWEntryF: FC<ZFWEntryProps> = ({ WASMData, loadingState, gsxActive, setLoadingState }) => {
|
||||
const [CGTarget, setCGTarget] = useState(WASMData.targetPayload.CGTarget);
|
||||
const [fuel, setFuel] = useState(Math.round(WASMData.livePayload.fuel));
|
||||
const [ZFWTarget, setZFWTarget] = useState(Math.round(WASMData.targetPayload.total));
|
||||
const [fuelEnabled, setFuelEnabled] = useState(true);
|
||||
|
||||
const ZFW = () => {
|
||||
if (loadingState !== 'loaded' && !GSXActive()) return ZFWTarget;
|
||||
if (loadingState !== 'loaded' && !gsxActive) return ZFWTarget;
|
||||
|
||||
return Math.round(WASMData.livePayload.total);
|
||||
};
|
||||
@ -33,13 +34,6 @@ const ZFWEntryF: FC<ZFWEntryProps> = ({ 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);
|
||||
@ -109,7 +103,7 @@ const ZFWEntryF: FC<ZFWEntryProps> = ({ 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"
|
||||
@ -123,7 +117,7 @@ const ZFWEntryF: FC<ZFWEntryProps> = ({ 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>
|
||||
@ -142,7 +136,7 @@ const ZFWEntryF: FC<ZFWEntryProps> = ({ WASMData, loadingState, setLoadingState
|
||||
value={ZFWTarget}
|
||||
onChange={(e) => handleInputZFW(e.target.value)}
|
||||
onBlur={(e) => handleBlur(e.target.value)}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -155,7 +149,7 @@ const ZFWEntryF: FC<ZFWEntryProps> = ({ 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;
|
||||
@ -179,7 +173,7 @@ const ZFWEntryF: FC<ZFWEntryProps> = ({ WASMData, loadingState, setLoadingState
|
||||
<div className="relative 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
|
||||
@ -194,7 +188,7 @@ const ZFWEntryF: FC<ZFWEntryProps> = ({ WASMData, loadingState, setLoadingState
|
||||
<div className="relative 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
|
||||
|
||||
@ -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 } from '../../types/general';
|
||||
import { CoherentCallZFWEntry, inRangeOf, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
@ -9,17 +8,18 @@ import ActionBar from '../actionbar/ActionBar';
|
||||
interface ZFWEntryProps {
|
||||
WASMData: WASMDataPax;
|
||||
loadingState: LoadingState;
|
||||
gsxActive: boolean;
|
||||
setLoadingState: (newState: LoadingState) => void;
|
||||
}
|
||||
|
||||
const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, setLoadingState }) => {
|
||||
const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, gsxActive, setLoadingState }) => {
|
||||
const [CGTarget, setCGTarget] = useState(WASMData.targetPayload.CGTarget);
|
||||
const [fuel, setFuel] = useState(Math.round(WASMData.livePayload.fuel));
|
||||
const [ZFWTarget, setZFWTarget] = useState(Math.round(WASMData.targetPayload.total));
|
||||
const [fuelEnabled, setFuelEnabled] = useState(true);
|
||||
|
||||
const ZFW = () => {
|
||||
if (loadingState !== 'loaded' && !GSXActive()) return ZFWTarget;
|
||||
if (loadingState !== 'loaded' && !gsxActive) return ZFWTarget;
|
||||
|
||||
return Math.round(WASMData.livePayload.total);
|
||||
};
|
||||
@ -33,13 +33,6 @@ const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, setLoadingStat
|
||||
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);
|
||||
@ -109,7 +102,7 @@ const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, setLoadingStat
|
||||
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"
|
||||
@ -123,7 +116,7 @@ const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, setLoadingStat
|
||||
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>
|
||||
@ -142,7 +135,7 @@ const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, setLoadingStat
|
||||
value={ZFWTarget}
|
||||
onChange={(e) => handleInputZFW(e.target.value)}
|
||||
onBlur={(e) => handleBlur(e.target.value)}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
disabled={loadingState !== 'preview' || gsxActive}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -155,7 +148,7 @@ const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, setLoadingStat
|
||||
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;
|
||||
@ -179,7 +172,7 @@ const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, setLoadingStat
|
||||
<div className="relative 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
|
||||
@ -194,7 +187,7 @@ const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, setLoadingStat
|
||||
<div className="relative 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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user