Enhance trigger handling in Trigger component: update addTrigger logic to include backend update and refresh triggers; improve default option handling in LabledDropdown for triggered points.
This commit is contained in:
parent
71fdb26e16
commit
ed9d149072
|
@ -221,7 +221,21 @@ const Trigger = ({ selectedPointData, type }: TriggerProps) => {
|
|||
triggeredAsset: null
|
||||
};
|
||||
|
||||
addTrigger(selectedProduct.productId, currentAction, newTrigger);
|
||||
const event = addTrigger(selectedProduct.productId, currentAction, newTrigger);
|
||||
|
||||
if (event) {
|
||||
updateBackend(
|
||||
selectedProduct.productName,
|
||||
selectedProduct.productId,
|
||||
organization,
|
||||
event
|
||||
);
|
||||
}
|
||||
|
||||
const updatedAction = getActionByUuid(selectedProduct.productId, currentAction);
|
||||
const updatedTriggers = updatedAction?.triggers || [];
|
||||
|
||||
setTriggers(updatedTriggers);
|
||||
setSelectedTrigger(newTrigger);
|
||||
};
|
||||
|
||||
|
@ -358,7 +372,7 @@ const Trigger = ({ selectedPointData, type }: TriggerProps) => {
|
|||
/>
|
||||
<LabledDropdown
|
||||
label="Triggered Point"
|
||||
defaultOption={`Point ${triggeredPoint?.uuid.slice(0, 4)}`}
|
||||
defaultOption={triggeredPoint?.uuid ? `Point ${triggeredPoint?.uuid.slice(0, 4)}` : ''}
|
||||
options={[...pointOptions.map((option) => (`Point ${option.uuid.slice(0, 4)}`))]}
|
||||
onSelect={(option) => { handlePointSelect(option, selectedTrigger.triggerUuid) }}
|
||||
/>
|
||||
|
|
Loading…
Reference in New Issue