Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
userId: undefined,
takenAtFrom: undefined,
takenAtTo: undefined,
createdAtFrom: undefined,
createdAtTo: undefined,
ratingFrom: undefined,
ratingTo: undefined,
},
editModel: null,
saveErrors: [],
showPosition: false,
language: 'en-US', // TODO this is hack so that setLanguage will change it in any case on load (eg. to 'en')
};
export const galleryReducer = createReducer(
initialState,
)
.handleAction(clearMap, state => ({
...initialState,
dirtySeq: state.dirtySeq,
}))
.handleAction(gallerySetImageIds, (state, action) => ({
...state,
imageIds: action.payload,
}))
.handleAction(galleryClear, state => ({
...state,
imageIds: null,
image: null,
activeImageId: null,
editModel: null,
Changeset,
} from 'fm3/actions/changesetsActions';
export interface ChangesetsState {
changesets: Changeset[];
days: number | null;
authorName: string | null;
}
const initialState: ChangesetsState = {
changesets: [],
days: null,
authorName: null,
};
export const changesetReducer = createReducer(
initialState,
)
.handleAction(clearMap, () => initialState)
.handleAction(changesetsSet, (state, action) => ({
...state,
changesets: action.payload,
}))
.handleAction(changesetsSetDays, (state, action) => ({
...state,
days: action.payload,
}))
.handleAction(changesetsSetAuthorName, (state, action) => ({
...state,
authorName: action.payload,
}))
.handleAction(deleteFeature, (state, action) =>
interface UiState {
highlightedItemCoordinates: {
positionLeft: number
positionTop: number
}
isFocusSearchInput: boolean
}
const INITIAL_STATE: UiState = {
highlightedItemCoordinates: {
positionLeft: 0,
positionTop: 0
},
isFocusSearchInput: false
}
export const uiReducer = createReducer>(INITIAL_STATE)
.handleAction(uiCreators.setHighlightedItemCoordinates, (state, {payload}) => {
return {
...state,
highlightedItemCoordinates: payload.highlightedItemCoordinates
}
})
.handleAction(uiCreators.setIsFocusSearchInput, (state, {payload}) => {
return {
...state,
isFocusSearchInput: payload.isFocusSearchInput
}
})
import * as menuCreators from './actions'
interface MenuState {
menuPattern: MenuPattern
positionLeft: number
positionTop: number
targetId?: string
}
const INITIAL_STATE: MenuState = {
menuPattern: [],
positionLeft: 0,
positionTop: 0,
targetId: undefined,
}
export const menuReducer = createReducer<
MenuState,
ActionType
>(INITIAL_STATE, {
[getType(menuCreators.closeMenu)]: () => INITIAL_STATE,
[getType(menuCreators.openMenu)]: (
state: MenuState,
{ payload }: ReturnType,
) => {
return {
...state,
...payload.coordinates,
targetId: payload.targetId,
}
},
[getType(menuCreators.setMenuPattern)]: (
state: MenuState,
query: string | null;
results: SearchResult[];
selectedResult: SearchResult | null;
inProgress: boolean;
searchSeq: number;
}
const initialState = {
query: null,
results: [],
searchSeq: 0,
selectedResult: null,
inProgress: false,
};
export const searchReducer = createReducer(
initialState,
)
.handleAction(clearMap, () => initialState)
.handleAction(searchSetQuery, (state, action) => ({
...state,
query: action.payload,
inProgress: true,
}))
.handleAction(searchSetResults, (state, action) => ({
...state,
results: action.payload,
searchSeq: state.searchSeq + 1,
inProgress: false,
}))
.handleAction(searchSelectResult, (state, action) => ({
...state,
const initialState: UserState = {
isAuthenticating: false,
user: null,
token: null,
};
const isAuthenticating = createReducer(initialState.isAuthenticating)
.handleAction([reloginAction, loginActions.request], () => true)
.handleAction([loginActions.success, loginActions.failure], () => false);
const user = createReducer(initialState.user)
.handleAction(loginActions.success, (_, { payload: { user } }) => user)
.handleAction(loginActions.failure, () => null);
const token = createReducer(initialState.token)
.handleAction(loginActions.success, (_, { payload: { token } }) => token)
.handleAction(loginActions.failure, () => initialState.token);
export default combineReducers({
isAuthenticating,
user,
token,
});
/**
* SELECTORS
*/
export const selectUserState = (state: RootState) => state.user;
export const selectIsAuthenticating = (state: RootState) => selectUserState(state).isAuthenticating;
export const selectUser = (state: RootState) => selectUserState(state).user;
isFetching: false,
};
const getSchemaProcessStrategy = (workspaceId: string) => (
value: ClockifyTagModel | TogglTagModel,
): CompoundTagModel => ({
id: value.id.toString(),
name: value.name,
workspaceId,
entryCount: 0,
linkedId: null,
isIncluded: true,
memberOf: EntityGroup.Tags,
});
export const tagsReducer = createReducer(initialState)
.handleAction(
[
tagsActions.clockifyTagsFetch.success,
tagsActions.clockifyTagsTransfer.success,
],
(state, { payload }) => {
const normalizedState = utils.normalizeState({
toolName: ToolName.Clockify,
entityGroup: EntityGroup.Tags,
entityState: state,
payload: payload.entityRecords,
schemaProcessStrategy: getSchemaProcessStrategy(payload.workspaceId),
});
const linkedState = utils.linkEntitiesInStateByName(
EntityGroup.Tags,
import { ActionType, createReducer } from 'typesafe-actions'
import * as editorCreators from './actions'
import { EditorState } from './types'
const INITIAL_STATE: EditorState = {
isAllowEditUrl: false,
isCreating: false,
positionLeft: 0,
positionTop: 0,
targetId: undefined,
title: '',
url: '',
}
export const editorReducer = createReducer<
EditorState,
ActionType
>(INITIAL_STATE)
.handleAction(editorCreators.closeEditor, () => INITIAL_STATE)
.handleAction(editorCreators.setEditor, (state, { payload }) => {
return {
...state,
...payload.partialState,
}
})
const actions = { startSpinnerAction, finishSpinnerAction };
export type SpinnerAction = ActionType;
type SpinnerState = Record;
export interface SpinnerKeyInState {
spinner: SpinnerState;
}
/**
* REDUCERS
*/
const initialState: SpinnerState = {};
export default createReducer(initialState)
.handleAction(startSpinnerAction, (state, { payload: id = GLOBAL }) => ({
...state,
[id]: state[id] ? state[id] + 1 : 1,
}))
.handleAction(finishSpinnerAction, (state, { payload: id = GLOBAL }) => ({
...state,
[id]: state[id] > 0 ? state[id] - 1 : 0,
}));
/**
* SELECTORS
*/
const selectSpinner = <s>(state: S) => state.spinner;
export const selectIsInProgress = <s>(state: S, id: string) =>
!!selectSpinner(state)[id];</s></s>
distanceMeasurementAddPoint,
distanceMeasurementUpdatePoint,
distanceMeasurementRemovePoint,
distanceMeasurementSetPoints,
Line,
} from 'fm3/actions/distanceMeasurementActions';
export interface DistanceMeasurementState {
lines: Line[];
}
export const initialState: DistanceMeasurementState = {
lines: [],
};
export const distanceMeasurementReducer = createReducer<
DistanceMeasurementState,
RootAction
>(initialState)
.handleAction(clearMap, () => initialState)
.handleAction(distanceMeasurementAddPoint, (state, action) =>
produce(state, draft => {
let line: Line;
if (action.payload.index == null) {
if (action.payload.type === undefined) {
throw new Error();
}
line = { type: action.payload.type, points: [] };
draft.lines.push(line);
} else {