Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | import React, { useMemo } from "react"; import { useAppSelector } from "store/hooks"; import { customEventSelectors } from "store/features/entities/entitiesSelectors"; import { ScriptEventNormalized, ScriptEventParentType, } from "shared/lib/entities/entitiesTypes"; import ScriptEventFields from "./ScriptEventFields"; import { selectScriptEventDefs } from "store/features/scriptEventDefs/scriptEventDefsState"; import { getScriptEventFields } from "./scriptEventFormFields"; interface ScriptEventFormProps { scriptEvent: ScriptEventNormalized; entityId: string; parentType: ScriptEventParentType; parentId: string; parentKey: string; nestLevel: number; altBg: boolean; renderEvents: (key: string, label: string) => React.ReactNode; } const ScriptEventForm = ({ scriptEvent, entityId, parentId, parentKey, parentType, nestLevel, altBg, renderEvents, }: ScriptEventFormProps) => { const scriptEventDefs = useAppSelector((state) => selectScriptEventDefs(state), ); const customEvents = useAppSelector((state) => customEventSelectors.selectEntities(state), ); const command = scriptEvent?.command; const value = scriptEvent?.args; const fields = useMemo(() => { if (command) { return getScriptEventFields( command, value || {}, customEvents, scriptEventDefs, ); } return []; }, [command, value, customEvents, scriptEventDefs]); if (!scriptEvent) { return null; } return ( <ScriptEventFields scriptEvent={scriptEvent} entityId={entityId} parentId={parentId} parentKey={parentKey} parentType={parentType} nestLevel={nestLevel} altBg={altBg} renderEvents={renderEvents} fields={fields} value={value} /> ); }; export default ScriptEventForm; |