-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update reducer for set unit cell, need to fix infinite loop
- Loading branch information
Showing
4 changed files
with
28 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,6 @@ | ||
export const ADD_QUBIT = 'ADD_QUBIT'; | ||
export const REMOVE_QUBIT = 'REMOVE_QUBIT'; | ||
export const SET_UNIT_CELL = 'SET_UNIT_CELL'; | ||
|
||
export const addQubit = (qubit) => ({ | ||
type: ADD_QUBIT, | ||
payload: qubit, | ||
}); | ||
|
||
export const remoteQubit = (qubit) => ({ | ||
type: REMOVE_QUBIT, | ||
payload: qubit, | ||
export const setUnitCell = (unitCell) => ({ | ||
type: SET_UNIT_CELL, | ||
payload: unitCell, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,25 @@ | ||
/* eslint-disable default-param-last */ | ||
// reducers/workspaceReducer.js | ||
import { ADD_QUBIT, REMOVE_QUBIT } from './actions'; | ||
import { SET_UNIT_CELL } from './actions'; | ||
|
||
const initialState = { | ||
qubits: [], | ||
plaquettes: [], | ||
export const initialState = { | ||
untiCell: { | ||
qubits: [], | ||
gridSquares: [], | ||
}, | ||
}; | ||
|
||
const workspaceReducer = (state = initialState, action) => { | ||
const rootReducer = (state = initialState, action) => { | ||
switch (action.type) { | ||
case ADD_QUBIT: | ||
state.qubits.push(action.payload); | ||
return state; | ||
case REMOVE_QUBIT: | ||
state.qubits.forEach((qubit, index) => { | ||
if (qubit === action.payload) { | ||
state.qubits.splice(index, 1); | ||
case SET_UNIT_CELL: | ||
return { | ||
unitCell: { | ||
qubits: action.payload.qubits, | ||
gridSquares: action.payload.gridSquares, | ||
} | ||
}); | ||
return state; | ||
}; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
const rootReducer = workspaceReducer; | ||
|
||
export default rootReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters