Add if statement conditional to React epic function

Viewed 39

I am fairly new to React and Redux, and am attempting to add a conditional statement inside an epic function. Based on the results of the conditional, it will either filter on a single privilege or on multiple.

Is this possible?

Here is what I have so far:

export const handleSetPrivileges: Epic<RootAction, RootAction, RootState> = (action$, store$) =>
    action$.pipe(
        filter(isActionOf(UserActions.SetPrivileges)),
        
        if (specific component) {
            filter((action) => ![304, 1112].some(priv => action.payload.includes(priv))),
        }
        else {
            filter((action) => !action.payload?.includes(304)),

        map(() => routerActions.push('/unauthorized'))
    );
0 Answers
Related