Add channel and role api

This commit is contained in:
Aslan 2026-01-02 16:23:21 +01:00
parent 8881070cac
commit 1fbd120404
22 changed files with 538 additions and 2 deletions

View 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 };

View file

@ -0,0 +1 @@
export * from "./channel";

View file

@ -0,0 +1 @@
export * from "./role";

56
src/services/role/role.ts Normal file
View 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 };