Add channel and role api
This commit is contained in:
parent
8881070cac
commit
1fbd120404
22 changed files with 538 additions and 2 deletions
56
src/services/channel/channel.ts
Normal file
56
src/services/channel/channel.ts
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
import {
|
||||
fetchChannelApi,
|
||||
createChannelApi,
|
||||
updateChannelApi,
|
||||
removeChannelApi,
|
||||
} from "../../api/channel";
|
||||
import { ChannelActionTypes } from "../../store/channel";
|
||||
import { dispatch } from "../../store/state";
|
||||
|
||||
const fetchChannel = async (id: string) => {
|
||||
const data = await fetchChannelApi({
|
||||
id: id,
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: ChannelActionTypes.FETCH_CHANNEL_FINISH,
|
||||
payload: data,
|
||||
});
|
||||
};
|
||||
|
||||
const createChannel = async (name: string, communityId: string) => {
|
||||
const data = await createChannelApi({
|
||||
name: name,
|
||||
communityId: communityId,
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: ChannelActionTypes.CREATE_CHANNEL_FINISH,
|
||||
payload: data,
|
||||
});
|
||||
};
|
||||
|
||||
const updateChannel = async (id: string, name?: string) => {
|
||||
const data = await updateChannelApi({
|
||||
id: id,
|
||||
name: name,
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: ChannelActionTypes.UPDATE_CHANNEL_FINISH,
|
||||
payload: data,
|
||||
});
|
||||
};
|
||||
|
||||
const removeChannel = async (id: string) => {
|
||||
const data = await removeChannelApi({
|
||||
id: id,
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: ChannelActionTypes.REMOVE_CHANNEL_FINISH,
|
||||
payload: data,
|
||||
});
|
||||
};
|
||||
|
||||
export { fetchChannel, createChannel, updateChannel, removeChannel };
|
||||
1
src/services/channel/index.ts
Normal file
1
src/services/channel/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from "./channel";
|
||||
1
src/services/role/index.ts
Normal file
1
src/services/role/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from "./role";
|
||||
56
src/services/role/role.ts
Normal file
56
src/services/role/role.ts
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
import {
|
||||
fetchRoleApi,
|
||||
createRoleApi,
|
||||
updateRoleApi,
|
||||
removeRoleApi,
|
||||
} from "../../api/role";
|
||||
import { RoleActionTypes } from "../../store/role";
|
||||
import { dispatch } from "../../store/state";
|
||||
|
||||
const fetchRole = async (id: string) => {
|
||||
const data = await fetchRoleApi({
|
||||
id: id,
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: RoleActionTypes.FETCH_ROLE_FINISH,
|
||||
payload: data,
|
||||
});
|
||||
};
|
||||
|
||||
const createRole = async (name: string, communityId: string) => {
|
||||
const data = await createRoleApi({
|
||||
name: name,
|
||||
communityId: communityId,
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: RoleActionTypes.CREATE_ROLE_FINISH,
|
||||
payload: data,
|
||||
});
|
||||
};
|
||||
|
||||
const updateRole = async (id: string, name?: string) => {
|
||||
const data = await updateRoleApi({
|
||||
id: id,
|
||||
name: name,
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: RoleActionTypes.UPDATE_ROLE_FINISH,
|
||||
payload: data,
|
||||
});
|
||||
};
|
||||
|
||||
const removeRole = async (id: string) => {
|
||||
const data = await removeRoleApi({
|
||||
id: id,
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: RoleActionTypes.REMOVE_ROLE_FINISH,
|
||||
payload: data,
|
||||
});
|
||||
};
|
||||
|
||||
export { fetchRole, createRole, updateRole, removeRole };
|
||||
Loading…
Add table
Add a link
Reference in a new issue