Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { createActionDescription } from 'src/redux/utils';
import { v1 as uuid } from 'uuid';
import { delay } from 'redux-saga';
import { ToastMessage } from 'src/redux/models';
import { Toast } from 'models';
// ACTIONS
const actionDescription = createActionDescription('toast');
export const actions = {
showMessage: createAction(actionDescription('SHOW_MESSAGE')),
// INTERNAL
addToast: createAction(actionDescription('SHOW_TOAST')),
hideToast: createAction(actionDescription('HIDE_TOAST')),
removeToast: createAction(actionDescription('REMOVE_TOAST')),
showToast: createAction(actionDescription('SHOW_TOAST')),
};
// STATE
const initialState = {
toast: null as Toast,
};
export type ToastState = typeof initialState;
// REDUCER
const toast = createReducer({}, initialState.toast)
.on(actions.addToast, (_, toast) => toast)
import { createReducer, createAction } from 'redux-act'
import { loop, Effects } from 'redux-loop'
import client from '../../../helpers/apiClient'
export const fetch = createAction('mg/holidays/getHolidays')
export const fetchSuccess = createAction('mg/holidays/getHolidaysSuccess')
export const fetchFailure = createAction('mg/holidays/getHolidaysFailure')
const initialState = {
isLoaded: false,
isLoading: false,
data: {}
}
const request = (country, year) => () =>
client.get(`https://holidayapi.com/v1/holidays?key=f988097d-8481-420d-8f86-6b29abec97c4&country=${country}&year=${year}`)
.then(fetchSuccess)
.catch(fetchFailure)
const handleFetch = (state, payload) => {
const { country, year } = payload
return loop({
import { createReducer, createAction } from 'redux-act'
import { loop, Effects } from 'redux-loop'
import client from '../../../helpers/apiClient'
export const fetch = createAction('mg/holidays/getHolidays')
export const fetchSuccess = createAction('mg/holidays/getHolidaysSuccess')
export const fetchFailure = createAction('mg/holidays/getHolidaysFailure')
const initialState = {
isLoaded: false,
isLoading: false,
data: {}
}
const request = (country, year) => () =>
client.get(`https://holidayapi.com/v1/holidays?key=f988097d-8481-420d-8f86-6b29abec97c4&country=${country}&year=${year}`)
.then(fetchSuccess)
.catch(fetchFailure)
const handleFetch = (state, payload) => {
const { country, year } = payload
reducer.on(setGroupClaimsBy, (state: ContactsState, payload?: any) => {
return {
...state,
groupClaimsBy: payload,
}
})
export const setRoomForSharing = createAction('Set Room For Sharing clam')
reducer.on(setRoomForSharing, (state: ContactsState, payload?: string) => {
return {
...state,
roomForSharing: payload,
}
})
export const addContact = createAction('Add contact')
reducer.on(addContact, (state: ContactsState, payload?: User) => {
let list = [...state.list]
remove(list, (item: User) => {
return item.address === payload.address
})
return {
...state,
list: [ ...list, payload ],
}
})
export const setForEditing = createAction('Set contact for editing')
reducer.on(setForEditing, (state: ContactsState, payload?: User) => {
return {
...state,
editing: payload,
import {createAction} from 'redux-act';
import {User} from 'models';
export const actions = {
subscribeUser: createAction('user/SUBSCRIBE_USER'),
unsubscribeUser: createAction('user/UNSUBSCRIBE_USER'),
import: createAction('user/IMPORT'),
cancelImport: createAction('user/CANCEL_IMPORT'),
setUser: createAction('user/SET_USER'),
setToken: createAction('user/SET_TOKEN'),
};
type ActionsType = typeof actions;
export type Actions = {[P in keyof ActionsType]: ReturnType};
import { createAction } from 'redux-act';
import { endpoint } from 'src/app/api';
export const loginWithToken = createAction('LOGIN');
export const logout = createAction('LOGOUT');
export const loginWithPassword = (email, password) => async (dispatch) => {
const response = await endpoint.post('/sessions/login', { email, password });
dispatch(loginWithToken(response.data.token));
};
import { createAction } from 'redux-act'
export const startApp = createAction()
export const enterPage = createAction()
export const exitPage = createAction()
export const moveMouse = createAction()
export const changePageSize = createAction()
export const tick = createAction()
export const toggleSnackbar = createAction()
import { createAction } from 'redux-act'
export const resetAll = createAction('RESET_ALL')
export const setMock = createAction('SET_MOCK')
export const toggleOrderModal = createAction('TOGGLE_ORDER_MODAL')
export const showOrderModal = createAction('SHOW_ORDER_MODAL')
export const hideOrderModal = createAction('HIDE_ORDER_MODAL')
export const setSettings = createAction('SET_SETTINGS')