You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
612 B
26 lines
612 B
const initialState = { |
|
loading: false, |
|
error: null, |
|
uploads: {}, |
|
lastUpload: null, |
|
}; |
|
|
|
export default function file(state = initialState, action) { |
|
let { type, data, params } = action; |
|
switch (type) { |
|
case "file/upload": |
|
return { |
|
...state, |
|
loading: false, |
|
error: null, |
|
uploads: { ...state.uploads, [params?.target || "last"]: data.id }, |
|
lastUpload: data.id, |
|
}; |
|
case "loading": |
|
return { ...state, loading: true }; |
|
case "error": |
|
return { ...state, loading: false, error: data.message }; |
|
default: |
|
return state; |
|
} |
|
}
|
|
|