Skip to content

Commit 801d579

Browse files
committed
Displays existing collection
- List all collections for a given user - View an individual collection - Link to a sketch from a collection
1 parent 63c0228 commit 801d579

File tree

12 files changed

+922
-15
lines changed

12 files changed

+922
-15
lines changed

client/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ export const HIDE_EDIT_PROJECT_NAME = 'HIDE_EDIT_PROJECT_NAME';
3232
export const SET_PROJECT = 'SET_PROJECT';
3333
export const SET_PROJECTS = 'SET_PROJECTS';
3434

35+
export const SET_COLLECTIONS = 'SET_COLLECTIONS';
36+
3537
export const DELETE_PROJECT = 'DELETE_PROJECT';
3638

3739
export const SET_SELECTED_FILE = 'SET_SELECTED_FILE';
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import axios from 'axios';
2+
import * as ActionTypes from '../../../constants';
3+
import { startLoader, stopLoader } from './loader';
4+
5+
const __process = (typeof global !== 'undefined' ? global : window).process;
6+
const ROOT_URL = __process.env.API_URL;
7+
8+
// eslint-disable-next-line
9+
export function getCollections(username) {
10+
return (dispatch) => {
11+
dispatch(startLoader());
12+
let url;
13+
if (username) {
14+
url = `${ROOT_URL}/${username}/collections`;
15+
} else {
16+
url = `${ROOT_URL}/collections`;
17+
}
18+
axios.get(url, { withCredentials: true })
19+
.then((response) => {
20+
dispatch({
21+
type: ActionTypes.SET_COLLECTIONS,
22+
collections: response.data
23+
});
24+
dispatch(stopLoader());
25+
})
26+
.catch((response) => {
27+
dispatch({
28+
type: ActionTypes.ERROR,
29+
error: response.data
30+
});
31+
dispatch(stopLoader());
32+
});
33+
};
34+
}

0 commit comments

Comments
 (0)