2022-02-28 18:00:47 +00:00
|
|
|
import { TApplicationActions } from '../definitions';
|
|
|
|
import { CREATE_CHANNEL } from '../actions/actionsTypes';
|
|
|
|
|
|
|
|
interface ICreateChannelResult {
|
|
|
|
name: string;
|
|
|
|
users: string[];
|
2022-05-30 22:02:08 +00:00
|
|
|
teamId?: string;
|
2022-02-28 18:00:47 +00:00
|
|
|
type: boolean;
|
|
|
|
readOnly: boolean;
|
|
|
|
encrypted: boolean;
|
|
|
|
broadcast: boolean;
|
|
|
|
isTeam: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ICreateChannelResultOnlyGroup {
|
|
|
|
group: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type TCreateChannelResult = ICreateChannelResult | ICreateChannelResultOnlyGroup;
|
|
|
|
|
|
|
|
export interface ICreateChannel {
|
|
|
|
isFetching: boolean;
|
|
|
|
failure: boolean;
|
|
|
|
result: TCreateChannelResult | {};
|
|
|
|
error: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const initialState: ICreateChannel = {
|
|
|
|
isFetching: false,
|
|
|
|
failure: false,
|
|
|
|
result: {},
|
|
|
|
error: {}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function (state = initialState, action: TApplicationActions): ICreateChannel {
|
|
|
|
switch (action.type) {
|
|
|
|
case CREATE_CHANNEL.REQUEST:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isFetching: true,
|
|
|
|
failure: false,
|
|
|
|
error: {}
|
|
|
|
};
|
|
|
|
case CREATE_CHANNEL.SUCCESS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isFetching: false,
|
|
|
|
failure: false,
|
|
|
|
result: action.data
|
|
|
|
};
|
|
|
|
case CREATE_CHANNEL.FAILURE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isFetching: false,
|
|
|
|
failure: true,
|
|
|
|
error: action.err
|
|
|
|
};
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|