corda-checkers/webapp/src/reducer/leaderboard.js
djmil df431eb4f1 UUIDprops
- guide.selectedUUID is used to determina current uuid
- all the game related midifications are stored independantly per UUID
- no global indicators
2023-11-24 10:38:52 +01:00

48 lines
899 B
JavaScript

import { useReducer } from 'react';
import { nextState } from '../util/StateHelper';
/*
* State
*/
const stateTemplate = {
// name : { rank }
// Bobik: {total: 10, victory 5: draw: 1}
};
function stateReducer(state, action) {
switch (action.type) {
case 'next':
return action.table;
default:
throw Error('LeaderboardState: unknown action.type ' +action.type);
}
}
export function useLeaderboardStateReducer() {
return useReducer(stateReducer, stateTemplate);
}
/*
* Guide
*/
const guideTemplate = {
isPolling: false
}
function guideReducer(state, action) {
switch (action.type) {
case 'next':
return nextState(state, action, 'LeaderboardGuide');
default:
throw Error('LeaderboardGuide: unknown action.type ' +action.type);
}
}
export function useLeaderboardGuideReducer() {
return useReducer(guideReducer, guideTemplate);
}