Updated functionality for group join requests approve, reject, leave
• Updated: - functionality for group join requests approve, reject, leave
This commit is contained in:
@@ -702,8 +702,8 @@ export function expandJoinRequestsFail(id, error) {
|
||||
export const approveJoinRequest = (accountId, groupId) => (dispatch, getState) => {
|
||||
if (!me) return
|
||||
|
||||
api(getState).post(`/api/v1/groups/${groupId}/join_requests/approve`, { accountId }).then((response) => {
|
||||
dispatch(approveJoinRequestSuccess(accountId, groupId))
|
||||
api(getState).post(`/api/v1/groups/${groupId}/join_requests/respond`, { accountId, type: 'approve' }).then((response) => {
|
||||
dispatch(approveJoinRequestSuccess(response.data.accountId, groupId))
|
||||
}).catch((error) => {
|
||||
dispatch(approveJoinRequestFail(accountId, groupId, error))
|
||||
})
|
||||
@@ -729,8 +729,9 @@ export function approveJoinRequestFail(accountId, groupId, error) {
|
||||
export const rejectJoinRequest = (accountId, groupId) => (dispatch, getState) => {
|
||||
if (!me) return
|
||||
|
||||
api(getState).delete(`/api/v1/groups/${groupId}/join_requests/reject`, { accountId }).then((response) => {
|
||||
dispatch(rejectJoinRequestSuccess(accountId, groupId))
|
||||
api(getState).post(`/api/v1/groups/${groupId}/join_requests/respond`, { accountId, type: 'reject' }).then((response) => {
|
||||
console.log("response:", response)
|
||||
dispatch(rejectJoinRequestSuccess(response.data.accountId, groupId))
|
||||
}).catch((error) => {
|
||||
dispatch(rejectJoinRequestFail(accountId, groupId, error))
|
||||
})
|
||||
|
||||
@@ -179,8 +179,7 @@ export default function userLists(state = initialState, action) {
|
||||
return appendToList(state, 'group_join_requests', action.id, action.accounts, action.next);
|
||||
case GROUP_JOIN_REQUESTS_APPROVE_SUCCESS:
|
||||
case GROUP_JOIN_REQUESTS_REJECT_SUCCESS:
|
||||
return state.updateIn(['group_join_requests', action.groupId, 'items'], list => list.filterNot(item => item === action.id));
|
||||
|
||||
return state.updateIn(['group_join_requests', action.groupId, 'items'], list => list.filterNot(item => item === action.accountId));
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user