(projectId, chartId, otherId)
| 168 | } |
| 169 | |
| 170 | export function changeOrder(projectId, chartId, otherId) { |
| 171 | return (dispatch) => { |
| 172 | const token = cookie.load("brewToken"); |
| 173 | const url = `${API_HOST}/project/${projectId}/chart/${chartId}/order`; |
| 174 | const method = "PUT"; |
| 175 | const body = JSON.stringify({ otherId }); |
| 176 | const headers = new Headers({ |
| 177 | "Accept": "application/json", |
| 178 | "Content-Type": "application/json", |
| 179 | "authorization": `Bearer ${token}`, |
| 180 | }); |
| 181 | |
| 182 | dispatch({ type: FETCH_CHART }); |
| 183 | return fetch(url, { method, body, headers }) |
| 184 | .then((response) => { |
| 185 | if (!response.ok) { |
| 186 | dispatch(addError(response.status)); |
| 187 | return new Promise((resolve, reject) => reject(response.statusText)); |
| 188 | } |
| 189 | |
| 190 | return response.json(); |
| 191 | }) |
| 192 | .then((chart) => { |
| 193 | dispatch(getProjectCharts(projectId)); |
| 194 | return new Promise(resolve => resolve(chart)); |
| 195 | }) |
| 196 | .catch((error) => { |
| 197 | dispatch({ type: FETCH_CHART_FAIL }); |
| 198 | return new Promise((resolve, reject) => reject(error)); |
| 199 | }); |
| 200 | }; |
| 201 | } |
| 202 | |
| 203 | export function removeChart(projectId, chartId) { |
| 204 | return (dispatch) => { |
no test coverage detected