bigbuffet-rw/app/soapbox/reducers/rules.ts
marcin mikołajczak 81de0014d3 Change ESLint rules, lint
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2023-02-16 00:12:02 +01:00

31 lines
706 B
TypeScript

import { RULES_FETCH_REQUEST, RULES_FETCH_SUCCESS } from '../actions/rules';
import type { RulesActions } from '../actions/rules';
export type Rule = {
id: string
text: string
subtext: string
rule_type: 'content' | 'account'
}
type RulesState = {
items: Rule[]
isLoading: boolean
}
const initialState: RulesState = {
items: [],
isLoading: false,
};
export default function rules(state: RulesState = initialState, action: RulesActions): RulesState {
switch (action.type) {
case RULES_FETCH_REQUEST:
return { ...state, isLoading: true };
case RULES_FETCH_SUCCESS:
return { ...state, isLoading: false, items: action.payload };
default:
return state;
}
}