2022-02-28 18:00:47 +00:00
|
|
|
import { TActionInviteLinks } from '../actions/inviteLinks';
|
2020-01-29 20:20:36 +00:00
|
|
|
import { INVITE_LINKS } from '../actions/actionsTypes';
|
|
|
|
|
2022-02-28 18:00:47 +00:00
|
|
|
export type TInvite = { url: string; expires: string; maxUses: number; uses: number; [x: string]: any };
|
|
|
|
|
|
|
|
export interface IInviteLinks {
|
|
|
|
token: string;
|
|
|
|
days: number;
|
|
|
|
maxUses: number;
|
|
|
|
invite: TInvite;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const initialState: IInviteLinks = {
|
2020-01-29 20:20:36 +00:00
|
|
|
token: '',
|
|
|
|
days: 1,
|
|
|
|
maxUses: 0,
|
2022-02-28 18:00:47 +00:00
|
|
|
invite: { url: '', expires: '', maxUses: 0, uses: 0 }
|
2020-01-29 20:20:36 +00:00
|
|
|
};
|
|
|
|
|
2022-02-28 18:00:47 +00:00
|
|
|
export default (state = initialState, action: TActionInviteLinks): IInviteLinks => {
|
2020-01-29 20:20:36 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case INVITE_LINKS.SET_TOKEN:
|
2022-02-28 18:00:47 +00:00
|
|
|
return { ...state, token: action.token };
|
2020-01-29 20:20:36 +00:00
|
|
|
case INVITE_LINKS.SET_PARAMS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
...action.params
|
|
|
|
};
|
|
|
|
case INVITE_LINKS.SET_INVITE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
invite: action.invite
|
|
|
|
};
|
|
|
|
case INVITE_LINKS.REQUEST:
|
|
|
|
return state;
|
|
|
|
case INVITE_LINKS.SUCCESS:
|
|
|
|
return initialState;
|
|
|
|
case INVITE_LINKS.FAILURE:
|
|
|
|
return initialState;
|
|
|
|
case INVITE_LINKS.CLEAR:
|
|
|
|
return initialState;
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|