SB persist
Options page for GSX Sync
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
import { FC, useEffect, useRef, useState } from 'react';
|
||||
import {
|
||||
COHERENT_COMM_BUS_WASM_CALL,
|
||||
COMM_BUS_UPDATE_TARGET_EVENT,
|
||||
GSX_SERVICE_CALLED,
|
||||
GSX_SERVICE_FINISHED,
|
||||
} from '../../constants';
|
||||
import { GSX_SERVICE_CALLED, GSX_SERVICE_FINISHED } from '../../constants';
|
||||
import { WASMDataPax } from '../../types/WASMData';
|
||||
import { LoadingState } from '../../types/general';
|
||||
import { LoadingState, SimBrief } from '../../types/general';
|
||||
import { ImportFlightPlan } from '../../utils/TFDISBImport';
|
||||
import { inRangeOf, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
import { CoherentCallSBEntryPax, inRangeOf, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
import CGSelect from '../CGSelect/CGSelect';
|
||||
import ActionBar from '../actionbar/ActionBar';
|
||||
|
||||
@@ -23,8 +18,7 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, username, setLoa
|
||||
const [CGTarget, setCGTarget] = useState(WASMData.targetPayload.CGTarget);
|
||||
const [fuel, setFuel] = useState(Math.round(WASMData.livePayload.fuel));
|
||||
const [fuelEnabled, setFuelEnabled] = useState(true);
|
||||
//eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const [SBPlan, setSBPlan] = useState<any>();
|
||||
const [SBPlan, setSBPlan] = useState<SimBrief>();
|
||||
const [SBInFlight, setSBInFlight] = useState(false);
|
||||
|
||||
const numPax = useRef(0);
|
||||
@@ -85,7 +79,7 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, username, setLoa
|
||||
cargo.current = parseFloat(SBResponse.message.cargo) ?? 0;
|
||||
numPax.current = parseInt(SBResponse.message.pax) ?? 0;
|
||||
|
||||
updateData();
|
||||
updateData(SBResponse.message);
|
||||
|
||||
setSBPlan(SBResponse.message);
|
||||
setFuel(parseFloat(SBResponse.message.fuel) ?? 0);
|
||||
@@ -104,17 +98,8 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, username, setLoa
|
||||
setFuelEnabled(inRangeOf(Math.round(WASMData.livePayload.fuel), fuel));
|
||||
}, [WASMData.livePayload.fuel]);
|
||||
|
||||
const updateData = (_CGTarget?: number) => {
|
||||
Coherent.call(
|
||||
COHERENT_COMM_BUS_WASM_CALL,
|
||||
COMM_BUS_UPDATE_TARGET_EVENT,
|
||||
JSON.stringify({
|
||||
mode: 0,
|
||||
cargo: cargo.current ?? 0,
|
||||
numPax: numPax.current ?? 0,
|
||||
CGTarget: _CGTarget ?? CGTarget,
|
||||
})
|
||||
);
|
||||
const updateData = (_CGTarget?: number, _SBPlan?: SimBrief) => {
|
||||
CoherentCallSBEntryPax(cargo.current ?? 0, numPax.current ?? 0, _CGTarget ?? CGTarget, _SBPlan ?? SBPlan);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -156,7 +141,7 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, username, setLoa
|
||||
type="text"
|
||||
placeholder=""
|
||||
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={SBPlan?.plannedZFW ?? 0}
|
||||
value={SBPlan?.plannedZFW ?? WASMData.sbPlanned.ZFW}
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
@@ -166,7 +151,7 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, username, setLoa
|
||||
type="text"
|
||||
placeholder=""
|
||||
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={SBPlan?.plannedGW ?? 0}
|
||||
value={SBPlan?.plannedGW ?? WASMData.sbPlanned.GW}
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user