Updated GroupsController, groups reducer to work with browsing by category, tag
• Updated: - GroupsController, groups reducer to work with browsing by category, tag
This commit is contained in:
parent
ada8b123d6
commit
65c5ee56f9
@ -39,7 +39,15 @@ class Api::V1::GroupsController < Api::BaseController
|
||||
render json: { error: 'This method requires an authenticated user' }, status: 422
|
||||
end
|
||||
|
||||
@groupCategory = nil
|
||||
if !params[:category].empty?
|
||||
@groupCategory = GroupCategories.where("text ILIKE ?", "%#{params[:category]}%")
|
||||
end
|
||||
|
||||
@groups = []
|
||||
if !@groupCategory.nil?
|
||||
@groups = Group.where(is_archived: false, group_categories: @groupCategory).all
|
||||
end
|
||||
|
||||
render json: @groups, each_serializer: REST::GroupSerializer
|
||||
end
|
||||
@ -50,6 +58,9 @@ class Api::V1::GroupsController < Api::BaseController
|
||||
end
|
||||
|
||||
@groups = []
|
||||
if !params[:tag].empty?
|
||||
@groups = Group.where(is_archived: false).where("array_to_string(tags, '||') ILIKE :tag", tag: "%#{params[:tag]}%").all
|
||||
end
|
||||
|
||||
render json: @groups, each_serializer: REST::GroupSerializer
|
||||
end
|
||||
|
@ -2,6 +2,8 @@ import {
|
||||
GROUP_FETCH_SUCCESS,
|
||||
GROUP_FETCH_FAIL,
|
||||
GROUPS_FETCH_SUCCESS,
|
||||
GROUPS_BY_CATEGORY_FETCH_SUCCESS,
|
||||
GROUPS_BY_TAG_FETCH_SUCCESS,
|
||||
} from '../actions/groups'
|
||||
import { GROUP_UPDATE_SUCCESS } from '../actions/group_editor'
|
||||
import { Map as ImmutableMap, fromJS } from 'immutable'
|
||||
@ -23,6 +25,8 @@ export default function groups(state = initialState, action) {
|
||||
case GROUP_FETCH_SUCCESS:
|
||||
case GROUP_UPDATE_SUCCESS:
|
||||
return normalizeGroup(state, action.group)
|
||||
case GROUPS_BY_CATEGORY_FETCH_SUCCESS:
|
||||
case GROUPS_BY_TAG_FETCH_SUCCESS:
|
||||
case GROUPS_FETCH_SUCCESS:
|
||||
return normalizeGroups(state, action.groups)
|
||||
case GROUP_FETCH_FAIL:
|
||||
|
Loading…
x
Reference in New Issue
Block a user