Added promotions to redux and added selector for setting promotions if not PRO
• Added: - promotions to redux - selector for setting promotions if not PRO • Updated: - StatusList, SidebarPanelGroup to use promotions from redux
This commit is contained in:
34
app/javascript/gabsocial/actions/promotions.js
Normal file
34
app/javascript/gabsocial/actions/promotions.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import api from '../api'
|
||||
import { me } from '../initial_state'
|
||||
|
||||
export const PROMOTIONS_FETCH_REQUEST = 'PROMOTIONS_FETCH_REQUEST'
|
||||
export const PROMOTIONS_FETCH_SUCCESS = 'PROMOTIONS_FETCH_SUCCESS'
|
||||
export const PROMOTIONS_FETCH_FAIL = 'PROMOTIONS_FETCH_FAIL'
|
||||
|
||||
export const fetchPromotions = () => {
|
||||
return (dispatch, getState) => {
|
||||
if (!me) return
|
||||
|
||||
dispatch(fetchPromotionsRequest())
|
||||
|
||||
api(getState).get('/api/v1/promotions').then((response) => {
|
||||
dispatch(fetchPromotionsSuccess(response.data))
|
||||
}).catch((error) => {
|
||||
dispatch(fetchPromotionsFail(error))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const fetchPromotionsRequest = () => ({
|
||||
type: PROMOTIONS_FETCH_REQUEST,
|
||||
})
|
||||
|
||||
const fetchPromotionsSuccess = (items) => ({
|
||||
type: PROMOTIONS_FETCH_SUCCESS,
|
||||
items,
|
||||
})
|
||||
|
||||
const fetchPromotionsFail = (error, listType) => ({
|
||||
type: PROMOTIONS_FETCH_FAIL,
|
||||
error,
|
||||
})
|
||||
Reference in New Issue
Block a user