Invite and Session API/Services; Home view; Sidebar Items; Modals
This commit is contained in:
parent
280158470a
commit
e36587b99d
80 changed files with 1343 additions and 71 deletions
|
|
@ -1,8 +1,12 @@
|
|||
import {
|
||||
fetchCommunity,
|
||||
createCommunity,
|
||||
updateCommunity,
|
||||
removeCommunity,
|
||||
fetchCommunityChannels,
|
||||
fetchCommunityRoles,
|
||||
fetchCommunityMembers,
|
||||
fetchCommunityInvites,
|
||||
} from "../../services/community";
|
||||
import { setState } from "../state";
|
||||
import { CommunityActionTypes, CommunityAction } from "./actions";
|
||||
|
|
@ -32,6 +36,42 @@ function communityReducer(state: ICommunityState, action: CommunityAction) {
|
|||
action.payload,
|
||||
);
|
||||
break;
|
||||
case CommunityActionTypes.CREATE_COMMUNITY_START:
|
||||
createCommunity(action.payload.name);
|
||||
break;
|
||||
case CommunityActionTypes.CREATE_COMMUNITY_FINISH:
|
||||
setState(
|
||||
"community",
|
||||
"communities",
|
||||
action.payload.id,
|
||||
action.payload,
|
||||
);
|
||||
break;
|
||||
case CommunityActionTypes.UPDATE_COMMUNITY_START:
|
||||
updateCommunity(
|
||||
action.payload.id,
|
||||
action.payload.name,
|
||||
action.payload.description,
|
||||
);
|
||||
break;
|
||||
case CommunityActionTypes.UPDATE_COMMUNITY_FINISH:
|
||||
setState(
|
||||
"community",
|
||||
"communities",
|
||||
action.payload.id,
|
||||
action.payload,
|
||||
);
|
||||
break;
|
||||
case CommunityActionTypes.REMOVE_COMMUNITY_START:
|
||||
removeCommunity(action.payload);
|
||||
break;
|
||||
case CommunityActionTypes.REMOVE_COMMUNITY_FINISH:
|
||||
setState("community", "communities", (communities) => {
|
||||
const copy = { ...communities };
|
||||
delete copy[action.payload.id];
|
||||
return copy;
|
||||
});
|
||||
break;
|
||||
case CommunityActionTypes.FETCH_COMMUNITY_CHANNELS_START:
|
||||
fetchCommunityChannels(action.payload);
|
||||
break;
|
||||
|
|
@ -56,6 +96,14 @@ function communityReducer(state: ICommunityState, action: CommunityAction) {
|
|||
members: action.payload.members.map((member) => member.id),
|
||||
});
|
||||
break;
|
||||
case CommunityActionTypes.FETCH_COMMUNITY_INVITES_START:
|
||||
fetchCommunityInvites(action.payload);
|
||||
break;
|
||||
case CommunityActionTypes.FETCH_COMMUNITY_INVITES_FINISH:
|
||||
setState("community", "communities", action.payload.id, {
|
||||
invites: action.payload.invites.map((invite) => invite.id),
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue