Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const ChannelsSelection = (props: PropsType) => {
const {fetchChannelsTree, isChannelsTreeLoaded,channelsTree }: UseChannelsType = useChannelsTreeApi();
const {fetchMandatoryChannelsByChannelIds, isDependencyDataLoaded, requiredChannelsResult}= useMandatoryChannelsApi();
const [state, dispatchChannelsSelection] : [StateChannelsSelectionType, (ActionChannelsSelectionType) => void]
= useImmerReducer(
(draft, action) => reducerChannelsSelection(draft, action, channelsTree, requiredChannelsResult),
initialStateChannelsSelection(props.initialSelectedIds),
);
const isAllApiDataLoaded = isChannelsTreeLoaded && isDependencyDataLoaded;
useEffect(() => {
fetchChannelsTree()
.then((channelsTree: ChannelsTreeType) => {
fetchMandatoryChannelsByChannelIds({channels: Object.values(channelsTree.channelsById)});
})
}, [])
useEffect(() => {
// set lead base channel as first and notify
const sortedSelectedChannelsId = state.selectedChannelsIds
const Detail = ({ initialStatistics, initialRegions, initialError }) => {
const classes = useStyles()
const [state, dispatch] = useImmerReducer(reducer, {
regions: initialRegions,
statistics: initialStatistics,
error: initialError
})
const { regions, statistics, error } = state
return (
export const Provider: React.FC = ({ children }) => {
const [state, dispatch] = useImmerReducer(reducer, initialState);
return (
{children}
);
};