1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00
vault-frontend/src/redux/boris/reducer.ts
2021-09-22 15:55:45 +07:00

72 lines
1.2 KiB
TypeScript

import { createReducer } from '~/utils/reducer';
import { BORIS_HANDLERS } from './handlers';
import { IGithubIssue } from '~/redux/boris/types';
export type IStatGitRow = {
commit: string;
subject: string;
timestamp: string;
};
export type IStatBackend = {
users: {
total: number;
alive: number;
};
nodes: {
images: number;
audios: number;
videos: number;
texts: number;
total: number;
};
comments: {
total: number;
};
files: {
count: number;
size: number;
};
};
export interface BorisUsageStats {
git: Partial<IStatGitRow>[];
issues: IGithubIssue[];
backend: IStatBackend;
is_loading: boolean;
}
export type IBorisState = Readonly<{
stats: BorisUsageStats;
}>;
const initialBackendStats: IStatBackend = {
users: {
total: 0,
alive: 0,
},
nodes: {
images: 0,
audios: 0,
videos: 0,
texts: 0,
total: 0,
},
comments: {
total: 0,
},
files: {
count: 0,
size: 0,
},
};
const BORIS_INITIAL_STATE: IBorisState = {
stats: {
git: [],
issues: [],
backend: initialBackendStats,
is_loading: false,
},
};
export default createReducer(BORIS_INITIAL_STATE, BORIS_HANDLERS);