import {RootState} from '../rootReducer'; import {loadSocialPosts} from '../../services'; import {Action, ThunkAction} from '@reduxjs/toolkit'; import {userSocialsFetched, individualSocialfetched} from '../reducers'; import {loadAllSocialsForUser} from '../../utils'; export const loadIndividualSocial = ( userId: string, socialType: string, ): ThunkAction, RootState, unknown, Action> => async (dispatch) => { try { const social = await loadSocialPosts(userId, socialType); dispatch({ type: individualSocialfetched.type, payload: {socialType, social}, }); } catch (error) { console.log(error); } }; export const loadAllSocials = ( userId: string, ): ThunkAction, RootState, unknown, Action> => async (dispatch) => { try { const socials = await loadAllSocialsForUser(userId); dispatch({ type: userSocialsFetched.type, payload: socials, }); } catch (error) { console.log(error); } };