ligo/tools/webide/packages/client/src/redux/evaluate-value.ts
Jev Björsell c119c44c13
Import webide into main ligo monorepo
When this is merged https://gitlab.com/ligolang/ligo-web-ide/ will be
marked as deprecated.

This MR does not hook up the webide build to the main CI. The CI
integration will come in a subsequent MR for the sake of making review
easier.
2020-02-06 19:04:18 -08:00

37 lines
965 B
TypeScript

import { ActionType as ExamplesActionType, ChangeSelectedAction as ChangeSelectedExampleAction } from './examples';
export enum ActionType {
ChangeEntrypoint = 'evaluate-value-change-entrypoint'
}
export interface EvaluateValueState {
entrypoint: string;
}
export class ChangeEntrypointAction {
public readonly type = ActionType.ChangeEntrypoint;
constructor(public payload: EvaluateValueState['entrypoint']) {}
}
type Action = ChangeEntrypointAction | ChangeSelectedExampleAction;
const DEFAULT_STATE: EvaluateValueState = {
entrypoint: ''
};
export default (state = DEFAULT_STATE, action: Action): EvaluateValueState => {
switch (action.type) {
case ExamplesActionType.ChangeSelected:
return {
...state,
...(!action.payload ? DEFAULT_STATE : action.payload.evaluateValue)
};
case ActionType.ChangeEntrypoint:
return {
...state,
entrypoint: action.payload
};
}
return state;
};