Customisable pax/bag weight
Better log
This commit is contained in:
@@ -2,6 +2,7 @@ import { FC, useState } from 'react';
|
||||
import { GSX_SERVICE_CALLED, GSX_SERVICE_FINISHED } from '../../constants';
|
||||
import { LoadingState } from '../../types/general';
|
||||
import { WASMDataF } from '../../types/WASMData';
|
||||
import OptionsF from '../options/OptionsF';
|
||||
import Profile from '../profile/Profile';
|
||||
import SBEntryF from '../SBEntry/SBEntryF';
|
||||
import StationEntryF from '../stationEntry/StationEntryF';
|
||||
@@ -86,7 +87,7 @@ const Freighter: FC<FreighterProps> = ({ WASMData, username }) => {
|
||||
return (
|
||||
<>
|
||||
<Profile
|
||||
type="PAX"
|
||||
type="F"
|
||||
isER={WASMData.userData.isER}
|
||||
upper1={`${upper1(GSXActive() ? 'loaded' : loadingState)}`}
|
||||
upper2={`${upper2(GSXActive() ? 'loaded' : loadingState)}`}
|
||||
@@ -121,6 +122,9 @@ const Freighter: FC<FreighterProps> = ({ WASMData, username }) => {
|
||||
{((username && selectedTab === 2) || (!username && selectedTab === 1)) && (
|
||||
<StationEntryF WASMData={WASMData} loadingState={loadingState} setLoadingState={setLoadingState} />
|
||||
)}
|
||||
{((username && selectedTab === 3) || (!username && selectedTab === 2)) && (
|
||||
<OptionsF WASMData={WASMData} loadingState={loadingState} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import { FC } from 'react';
|
||||
import { GSX_SERVICE_CALLED, GSX_SERVICE_FINISHED } from '../../constants';
|
||||
import { LoadingState } from '../../types/general';
|
||||
import { WASMDataF } from '../../types/WASMData';
|
||||
import { CoherentCallOptionsSet } from '../../utils/utils';
|
||||
import ToggleComponent from '../toggleComponent/ToggleComponent';
|
||||
|
||||
interface OptionsFProps {
|
||||
WASMData: WASMDataF;
|
||||
loadingState: LoadingState;
|
||||
}
|
||||
|
||||
const OptionsF: FC<OptionsFProps> = ({ WASMData, loadingState }) => {
|
||||
const GSXActive = () => {
|
||||
return (
|
||||
(WASMData.GSX.boardingState >= GSX_SERVICE_CALLED || WASMData.GSX.deboardingState >= GSX_SERVICE_CALLED) &&
|
||||
WASMData.GSX.deboardingState !== GSX_SERVICE_FINISHED
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<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-md bg-zinc-600 p-2 px-4">
|
||||
<ToggleComponent
|
||||
optionName="GSX Sync"
|
||||
value={WASMData.options.GSXSync}
|
||||
leftLabel={{ value: true }}
|
||||
rightLabel={{ value: false }}
|
||||
backgroundColor="bg-zinc-700"
|
||||
setValue={(value) => {
|
||||
CoherentCallOptionsSet(value);
|
||||
}}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default OptionsF;
|
||||
@@ -1,4 +1,4 @@
|
||||
import { FC } from 'react';
|
||||
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';
|
||||
@@ -11,6 +11,9 @@ interface OptionsPaxProps {
|
||||
}
|
||||
|
||||
const OptionsPax: FC<OptionsPaxProps> = ({ WASMData, loadingState }) => {
|
||||
const [paxWeight, setPaxWeight] = useState(WASMData.options.paxWeight);
|
||||
const [bagWeight, setBagWeight] = useState(WASMData.options.bagWeight);
|
||||
|
||||
const GSXActive = () => {
|
||||
return (
|
||||
(WASMData.GSX.boardingState >= GSX_SERVICE_CALLED || WASMData.GSX.deboardingState >= GSX_SERVICE_CALLED) &&
|
||||
@@ -18,6 +21,26 @@ const OptionsPax: FC<OptionsPaxProps> = ({ WASMData, loadingState }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const updateData = () => {
|
||||
CoherentCallOptionsSet(undefined, paxWeight, bagWeight);
|
||||
};
|
||||
|
||||
const handleInput = (input: string, maxValue: number, setter: (value: number) => void) => {
|
||||
if (!input) {
|
||||
setter(0);
|
||||
return;
|
||||
}
|
||||
|
||||
const converted = parseInt(input);
|
||||
if (converted) {
|
||||
if (converted < 0) setter(0);
|
||||
else if (converted > maxValue) setter(maxValue);
|
||||
else setter(converted);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => updateData(), [paxWeight, bagWeight]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="block flex w-full flex-col opacity-100 transition-opacity duration-150 ease-linear mb-4">
|
||||
@@ -35,6 +58,31 @@ const OptionsPax: FC<OptionsPaxProps> = ({ WASMData, loadingState }) => {
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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>Pax Weight ({WASMData.userData.isImperial ? 'lbs' : 'kg'})</label>
|
||||
<input
|
||||
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={paxWeight}
|
||||
onChange={(e) => handleInput(e.target.value, Number.MAX_VALUE, setPaxWeight)}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
/>
|
||||
</div>
|
||||
<div className="relative flex w-full items-center justify-between bg-zinc-700 p-2 px-4">
|
||||
<label>Bag Weight ({WASMData.userData.isImperial ? 'lbs' : 'kg'})</label>
|
||||
<input
|
||||
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={bagWeight}
|
||||
onChange={(e) => handleInput(e.target.value, Number.MAX_VALUE, setBagWeight)}
|
||||
disabled={loadingState !== 'preview' || GSXActive()}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -57,6 +57,10 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadi
|
||||
}
|
||||
};
|
||||
|
||||
const updateData = () => {
|
||||
CoherentCallStationEntryF(upper1, upper2, upper3, upper4, lowerForward, lowerRear);
|
||||
};
|
||||
|
||||
useEffect(() => updateData(), [upper1, upper2, upper3, upper4, lowerForward, lowerRear]);
|
||||
useEffect(
|
||||
() =>
|
||||
@@ -70,10 +74,6 @@ const StationEntryF: FC<StationEntryProps> = ({ WASMData, loadingState, setLoadi
|
||||
setFuelEnabled(inRangeOf(Math.round(WASMData.livePayload.fuel), fuel));
|
||||
}, [WASMData.livePayload.fuel]);
|
||||
|
||||
const updateData = () => {
|
||||
CoherentCallStationEntryF(upper1, upper2, upper3, upper4, lowerForward, lowerRear);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="block flex w-full flex-col opacity-100 transition-opacity duration-150 ease-linear mb-4">
|
||||
|
||||
@@ -57,6 +57,10 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
|
||||
}
|
||||
};
|
||||
|
||||
const updateData = () => {
|
||||
CoherentCallStationEntryPax(business1, business2, economy1, economy2, forwardCargo, rearCargo);
|
||||
};
|
||||
|
||||
useEffect(() => updateData(), [business1, business2, economy1, economy2, forwardCargo, rearCargo]);
|
||||
useEffect(
|
||||
() =>
|
||||
@@ -70,10 +74,6 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
|
||||
setFuelEnabled(inRangeOf(Math.round(WASMData.livePayload.fuel), fuel));
|
||||
}, [WASMData.livePayload.fuel]);
|
||||
|
||||
const updateData = () => {
|
||||
CoherentCallStationEntryPax(business1, business2, economy1, economy2, forwardCargo, rearCargo);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="block flex w-full flex-col opacity-100 transition-opacity duration-150 ease-linear mb-4">
|
||||
|
||||
Reference in New Issue
Block a user