corda-checkers/webapp/src/reducer/user.js
djmil aa2a250085 Games container sceleton
- use Route for conditional rendering
- useGamesAPI
- Checkers component
2023-11-08 18:22:05 +01:00

26 lines
605 B
JavaScript

import { useReducer } from 'react';
import { localeCompare } from '../util/Locale';
import { nextState } from '../util/StateHelper';
export const userInitialState = {
username: '',
isCurrentUser: function (otherUsername) {
return localeCompare(this.username, otherUsername)
}
};
export function userReducer(state, action) {
switch (action.type) {
case 'next':
return nextState(state, action);
default:
throw Error('UserReducer: unknown action.type', action.type);
}
}
export default function useUserReducer() {
return useReducer(userReducer, userInitialState);
}