misc_pterodactyl-panel/resources/scripts/state/progress.ts

34 lines
709 B
TypeScript
Raw Normal View History

import { action, Action } from 'easy-peasy';
export interface ProgressStore {
continuous: boolean;
progress?: number;
startContinuous: Action<ProgressStore>;
setProgress: Action<ProgressStore, number | undefined>;
setComplete: Action<ProgressStore>;
}
const progress: ProgressStore = {
continuous: false,
progress: undefined,
2022-11-25 20:25:03 +00:00
startContinuous: action(state => {
state.continuous = true;
}),
setProgress: action((state, payload) => {
state.progress = payload;
}),
2022-11-25 20:25:03 +00:00
setComplete: action(state => {
if (state.progress) {
state.progress = 100;
}
state.continuous = false;
}),
};
export default progress;