Setting of payload

This commit is contained in:
2025-06-12 14:30:00 +02:00
parent 8975ea17af
commit f7304c5c7b
13 changed files with 142 additions and 84 deletions
@@ -1,5 +1,5 @@
import { FC, useEffect, useRef, useState } from 'react';
import { emptyAircraft } from '../../configs/shared';
import { unloadAircraft } from '../../configs/shared';
import { COHERENT_COMBUS_WASM_CALL, COMM_BUS_UPDATE_TARGET_EVENT } from '../../constants';
import { WASMDataPax } from '../../types/WASMData';
import { LoadingState } from '../../types/general';
@@ -214,9 +214,7 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, username, setLoa
<ActionBar
loadingState={loadingState}
acceptDisabled={!GWValid() || SBInFlight}
accept={() => setLoadingState('loaded')}
reject={() => setLoadingState('preview')}
loadDisabled={!GWValid() || SBInFlight}
importSB={handleSB}
load={() => {
setLoadingState('loaded');
@@ -226,7 +224,7 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, username, setLoa
unload={() => {
setLoadingState('preview');
emptyAircraft();
unloadAircraft();
}}
/>
</>
@@ -3,35 +3,34 @@ import { LoadingState } from '../../types/general';
interface ActionBarProps {
loadingState: LoadingState;
acceptDisabled: boolean;
accept: () => void;
reject: () => void;
loadDisabled: boolean;
importSB?: () => void;
load: () => void;
unload: () => void;
}
const ActionBar: FC<ActionBarProps> = ({ loadingState, acceptDisabled, accept, reject, importSB, load, unload }) => {
const ActionBar: FC<ActionBarProps> = ({ loadingState, loadDisabled, importSB, load, unload }) => {
return (
<div className="relative flex w-full items-center justify-start gap-x-6">
{/*TODO: HIDE FOR GSX SYNCED */}
{loadingState === 'preview' && (
<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"
data-ripple-light="true"
onClick={accept}
disabled={acceptDisabled}
onClick={load}
disabled={loadDisabled}
>
Accept
Load
</button>
)}
{/*TODO: Make GSX optional (accepted state for NON GSX) */}
{/*TODO: HIDE FOR GSX SYNCED */}
{loadingState === 'loaded' && (
<button
className="middle none center rounded-lg bg-red-600 px-6 py-3 font-sans text-xs font-bold uppercase text-white shadow-md shadow-red-500/20 transition-all hover:shadow-lg hover:shadow-red-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"
data-ripple-light="true"
onClick={reject}
onClick={unload}
>
Reject
Unload
</button>
)}
@@ -46,27 +45,6 @@ const ActionBar: FC<ActionBarProps> = ({ loadingState, acceptDisabled, accept, r
Import from SimBrief
</button>
)}
{/*TODO: Make GSX optional */}
{/*
{loadingState === 'accepted' && (
<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"
data-ripple-light="true"
onClick={load}
>
Load
</button>
)}
{loadingState === 'loaded' && (
<button
className="middle none center rounded-lg bg-red-600 px-6 py-3 font-sans text-xs font-bold uppercase text-white shadow-md shadow-red-500/20 transition-all hover:shadow-lg hover:shadow-red-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"
data-ripple-light="true"
onClick={unload}
>
Unload
</button>
)}
*/}
</div>
);
};
@@ -1,4 +1,5 @@
import { FC, useState } from 'react';
import { loadAircraft } from '../../configs/shared';
import { LoadingState } from '../../types/general';
import { WASMDataPax } from '../../types/WASMData';
import Profile from '../profile/Profile';
@@ -109,9 +110,7 @@ const Pax: FC<PaxProps> = ({ WASMData, username }) => {
loadingState={loadingState}
username={username}
setLoadingState={setLoadingState}
loadAircraft={() => {
console.log('SET WEIGHT SB');
}}
loadAircraft={loadAircraft}
/>
)}
{((username && selectedTab === 1) || (!username && selectedTab === 0)) && (
@@ -119,9 +118,7 @@ const Pax: FC<PaxProps> = ({ WASMData, username }) => {
WASMData={WASMData}
loadingState={loadingState}
setLoadingState={setLoadingState}
loadAircraft={() => {
console.log('SET WEIGHT ZFW');
}}
loadAircraft={loadAircraft}
/>
)}
{((username && selectedTab === 2) || (!username && selectedTab === 1)) && (
@@ -129,9 +126,7 @@ const Pax: FC<PaxProps> = ({ WASMData, username }) => {
WASMData={WASMData}
loadingState={loadingState}
setLoadingState={setLoadingState}
loadAircraft={() => {
console.log('SET WEIGHT STATIONS');
}}
loadAircraft={loadAircraft}
/>
)}
</>
@@ -1,5 +1,5 @@
import { FC, useEffect, useState } from 'react';
import { emptyAircraft } from '../../configs/shared';
import { unloadAircraft } from '../../configs/shared';
import { COHERENT_COMBUS_WASM_CALL, COMM_BUS_UPDATE_TARGET_EVENT } from '../../constants';
import { LoadingState } from '../../types/general';
import { WASMDataPax } from '../../types/WASMData';
@@ -210,9 +210,7 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
<ActionBar
loadingState={loadingState}
acceptDisabled={!ZFWValid() || !GWValid()}
accept={() => setLoadingState('accepted')}
reject={() => setLoadingState('preview')}
loadDisabled={!ZFWValid() || !GWValid()}
load={() => {
setLoadingState('loaded');
@@ -221,7 +219,7 @@ const StationEntryPax: FC<StationEntryProps> = ({ WASMData, loadingState, setLoa
unload={() => {
setLoadingState('preview');
emptyAircraft();
unloadAircraft();
}}
/>
</>
@@ -1,5 +1,5 @@
import { FC, useEffect, useState } from 'react';
import { emptyAircraft } from '../../configs/shared';
import { unloadAircraft } from '../../configs/shared';
import { COHERENT_COMBUS_WASM_CALL, COMM_BUS_UPDATE_TARGET_EVENT } from '../../constants';
import { WASMDataPax } from '../../types/WASMData';
import { LoadingState } from '../../types/general';
@@ -200,9 +200,7 @@ const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, setLoadingStat
<ActionBar
loadingState={loadingState}
acceptDisabled={!GWValid()}
accept={() => setLoadingState('accepted')}
reject={() => setLoadingState('preview')}
loadDisabled={!GWValid()}
load={() => {
setLoadingState('loaded');
@@ -211,7 +209,7 @@ const ZFWEntryPax: FC<ZFWEntryProps> = ({ WASMData, loadingState, setLoadingStat
unload={() => {
setLoadingState('preview');
emptyAircraft();
unloadAircraft();
}}
/>
</>
+13 -3
View File
@@ -1,11 +1,21 @@
import { COHERENT_COMBUS_WASM_CALL, COMM_BUS_LIVE_DATA_EVENT } from '../constants';
import { COHERENT_COMBUS_WASM_CALL, COMM_BUS_UPDATE_TARGET_EVENT } from '../constants';
export const emptyAircraft = () => {
export const loadAircraft = () => {
Coherent.call(
COHERENT_COMBUS_WASM_CALL,
COMM_BUS_LIVE_DATA_EVENT,
COMM_BUS_UPDATE_TARGET_EVENT,
JSON.stringify({
mode: 3,
})
);
};
export const unloadAircraft = () => {
Coherent.call(
COHERENT_COMBUS_WASM_CALL,
COMM_BUS_UPDATE_TARGET_EVENT,
JSON.stringify({
mode: 4,
})
);
};
+1 -1
View File
@@ -1 +1 @@
export type LoadingState = 'preview' | 'accepted' | 'loaded';
export type LoadingState = 'preview' | 'loaded';