Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return name === 'AddToContestModal' ? { ...state, error: null } : state
}
case ACCEPT_TERMS: {
return {
...state,
data: {
...state.data,
hasAcceptedTerms: true
}
}
}
case SUBMIT_PROJECT_REQUEST: {
return {
...state,
error: null,
loading: loadingReducer(state.loading, action)
}
}
case SUBMIT_PROJECT_SUCCESS: {
const { projectId, contest } = action.payload
return {
...state,
loading: loadingReducer(state.loading, action),
error: null,
data: {
...state.data,
...contest,
projects: { ...state.data.projects, [projectId]: Date.now() }
}
}
}
case SUBMIT_PROJECT_FAILURE: {
export function authReducer(state: AuthState = INITIAL_STATE, action: AuthReducerAction) {
switch (action.type) {
case AUTH_REQUEST: {
return {
...state,
loading: loadingReducer(state.loading, action)
}
}
case AUTH_SUCCESS: {
return {
...state,
data: action.payload.data,
loading: loadingReducer(state.loading, action),
error: null
}
}
case AUTH_FAILURE: {
return {
...state,
data: null,
loading: loadingReducer(state.loading, action),
error: action.payload.error
...projects
},
loading: loadingReducer(state.loading, action)
}
}
case LOAD_PROJECTS_FAILURE: {
return {
...state,
loading: loadingReducer(state.loading, action)
}
}
case LOAD_PUBLIC_PROJECT_REQUEST:
case LOAD_PUBLIC_PROJECT_FAILURE: {
return {
...state,
loading: loadingReducer(state.loading, action)
}
}
case LOAD_PUBLIC_PROJECT_SUCCESS: {
const { project, type } = action.payload
if (type !== 'public') {
return {
...state,
loading: loadingReducer(state.loading, action)
}
}
return {
...state,
data: {
...state.data,
[project.id]: project
},
progress: {
stage: ProgressStage.NONE,
value: 0
}
}
delete newState.data[projectId]
return newState
}
case CLEAR_DEPLOYMENT_FAILURE: {
return {
...state,
data: {
...state.data
},
loading: loadingReducer(state.loading, action),
error: action.payload.error
}
}
case DELETE_PROJECT: {
const { project } = action.payload
const newState = {
...state,
data: {
...state.data
},
progress: {
stage: ProgressStage.NONE,
value: 0
}
}
delete newState.data[project.id]
(accum, assetPack) => ({
...accum,
[assetPack.id]: {
...assetPack,
assets: assetPack.assets.map(asset => asset.id)
}
}),
{}
)
}
}
}
case LOAD_ASSET_PACKS_FAILURE: {
return {
...state,
loading: loadingReducer(state.loading, action),
error: action.payload.error
}
}
case SAVE_ASSET_PACK_REQUEST: {
return {
...state,
loading: loadingReducer(state.loading, action)
}
}
case SAVE_ASSET_PACK_SUCCESS: {
return {
...state,
loading: loadingReducer(state.loading, action)
}
}
case SAVE_ASSET_PACK_FAILURE: {
...state.data,
...assets
}
}
}
case LOAD_ASSET_PACKS_FAILURE: {
return { ...state, loading: loadingReducer(state.loading, action), error: action.payload.error }
}
case LOAD_COLLECTIBLES_SUCCESS: {
const assets: AssetState['data'] = {}
for (const asset of action.payload.assets) {
assets[asset.id] = { ...asset }
}
return { ...state, loading: loadingReducer(state.loading, action), error: null, data: { ...state.data, ...assets } }
}
case SAVE_ASSET_PACK_SUCCESS: {
const { assetPack } = action.payload
const newState = {
...state,
data: {
...state.data
}
}
for (let assetId of Object.keys(state.data)) {
const asset = newState.data[assetId]
if (asset.assetPackId === assetPack.id) {
delete newState.data[asset.id]
}
export const poolReducer = (state = INITIAL_STATE, action: PoolReducerAction): PoolState => {
switch (action.type) {
case LIKE_POOL_FAILURE:
case LIKE_POOL_SUCCESS:
case LOAD_POOLS_REQUEST:
case LOAD_POOLS_FAILURE: {
return {
...state,
loading: loadingReducer(state.loading, action)
}
}
case LOAD_POOLS_SUCCESS: {
const { projects } = action.payload
return {
...state,
data: {
...state.data,
...projects
},
loading: loadingReducer(state.loading, action)
}
}
case LOAD_PUBLIC_PROJECT_SUCCESS: {
const { project, type } = action.payload
if (type !== 'pool') {
}
categories[categoryName].assets = [...categories[categoryName].assets, asset.id]
}
}
return {
loading: loadingReducer(state.loading, action),
error: null,
data: {
...state.data,
...categories
}
}
}
case LOAD_ASSET_PACKS_FAILURE: {
return { ...state, loading: loadingReducer(state.loading, action), error: action.payload.error }
}
default:
return state
}
}