Skip to content

Commit

Permalink
Update handle discount rule channel change
Browse files Browse the repository at this point in the history
  • Loading branch information
poulch committed Jan 18, 2025
1 parent 0023fb9 commit d81bc75
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ export const RuleForm = <ErrorCode,>({ errors, openPlayground }: RuleFormProps<E
}
}, [currencySymbol]);

useEffect(() => {
const handleChannelChange = (e: ChangeEvent) => {
const channelId = e.target.value;
const channel = channels.find(channel => channel.id === channelId);

if (channel) {
channelfield.onChange({ value: channel.id, label: channel.name });
}

setValue("rewardGifts", []);

// Restart conditions when catalog promotion
Expand All @@ -70,15 +77,6 @@ export const RuleForm = <ErrorCode,>({ errors, openPlayground }: RuleFormProps<E
setValue("conditions", [createEmptyCodition()]);
}
}
}, [selectedChannel]);

const handleChannelChange = (e: ChangeEvent) => {
const channelId = e.target.value;
const channel = channels.find(channel => channel.id === channelId);

if (channel) {
channelfield.onChange({ value: channel.id, label: channel.name });
}
};

return (
Expand Down

0 comments on commit d81bc75

Please sign in to comment.