state debug, functions and status in state
parent
5665eb4955
commit
dff64780f5
|
|
@ -32,3 +32,5 @@ export enum BtnColor {
|
|||
blue = "primary",
|
||||
green = "success"
|
||||
}
|
||||
|
||||
export enum Status {params, plaing, plaied, showlist}
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
import { finales, initials, tones } from "./data";
|
||||
import { IState } from "./store";
|
||||
import { SylPart, Syllable, Tone } from "./types";
|
||||
import { SylPart, Syllable, Tone, Status } from "./types";
|
||||
import { GetSyllablesByInitAndFin, getRandomArray, toggle } from "./utils";
|
||||
|
||||
export enum ActionType {
|
||||
toggleOne, toggleAll, refreshPlayList, setPause, setCount
|
||||
toggleOne, toggleAll, refreshPlayList, setPause, setCount, setStatus
|
||||
}
|
||||
|
||||
export enum ToggleType { init, fin }
|
||||
|
|
@ -38,7 +38,6 @@ const ProceedAllFinales = (state: IState):{ allfinales:boolean, finales: SylPart
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
const ProceedInitiale = (state: IState, index: SylPart):{ initiales: SylPart[], foundSyllables:Syllable[], foundTones: Tone[]} =>
|
||||
{
|
||||
let toggled = toggle(state.initiales,index)
|
||||
|
|
@ -68,6 +67,7 @@ export const reducer = (state:IState, action:Action):IState => {
|
|||
case ActionType.setPause: return { ...state, sylPause: action.payload as number }
|
||||
case ActionType.setCount: return { ...state, sylCount: action.payload as number }
|
||||
case ActionType.refreshPlayList: return { ...state, randomTones: getRandomArray( state.foundTones, state.sylCount! ) }
|
||||
case ActionType.setStatus: return { ...state, status: action.payload as Status}
|
||||
|
||||
case ActionType.toggleAll: {
|
||||
if (action.payload as ToggleType === ToggleType.init) return { ...state, ...ProceedAllInitials(state) }
|
||||
|
|
|
|||
Loading…
Reference in New Issue