Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lab-nathan/backend
Submodule backend added at 1fc6e9
4 changes: 4 additions & 0 deletions lab-nathan/frontend/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["es2015", "react"],
"plugins": ["transform-object-rest-spread"]
}
4 changes: 4 additions & 0 deletions lab-nathan/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
coverage
build
.env
44 changes: 44 additions & 0 deletions lab-nathan/frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "frontend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack",
"watch": "webpack-dev-server --inline --hot",
"test": "jest"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"clean-webpack-plugin": "^0.1.16",
"css-loader": "^0.28.7",
"dotenv": "^4.0.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^0.11.2",
"html-webpack-plugin": "^2.30.1",
"jest": "^21.0.1",
"node-sass": "^4.5.3",
"raw-loader": "^0.5.1",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-redux": "^5.0.6",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"redux": "^3.7.2",
"redux-mock-store": "^1.2.3",
"sass-loader": "^6.0.6",
"superagent": "^3.6.0",
"uglifyjs-webpack-plugin": "^0.4.6",
"url-loader": "^0.5.9",
"uuid": "^3.1.0",
"webpack": "^3.5.6",
"webpack-dev-server": "^2.7.1"
}
}
24 changes: 24 additions & 0 deletions lab-nathan/frontend/src/__test__/token-reducer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import tokenReducer from '../reducers/token-reducer.js';

describe('Token Reducer', function() {
it('TOKEN_SET should return a token.', function() {
let testAction = {
type: 'TOKEN_SET',
payload: 'kasdf;kasdfj;asdfj;s'
};

let result = tokenReducer(null, testAction);

expect(result).toEqual(testAction.payload);
});

it('TOKEN_DELETE should delete a token.', function() {
let testAction = {
type: 'TOKEN_DELETE'
};

let result = tokenReducer(null, testAction);

expect(result).toEqual(null);
})
});
67 changes: 67 additions & 0 deletions lab-nathan/frontend/src/actions/photo-actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import superagent from 'superagent'

// sync actions
export const userPhotosSet = (photos) => ({
type: 'USER_PHOTOS_SET',
payload: photos,
})

export const userPhotoCreate = (photo) => ({
type: 'USER_PHOTO_CREATE',
payload: photo,
})

export const userPhotoUpdate = (photo) => ({
type: 'USER_PHOTO_UPDATE',
payload: photo,
})

export const userPhotoDelete = (photo) => ({
type: 'USER_PHOTO_DELETE',
payload: photo,
})

// async actions
export const userPhotosFetchRequest = () => (dispatch, getState) => {
let {token} = getState()
return superagent.get(`${__API_URL__}/photos/me`)
.set('Authorization', `Bearer ${token}`)
.then(res => {
dispatch(userPhotosSet(res.body.data))
return res
})
}

export const userPhotoCreateRequest = (photo) => (dispatch, getState) => {
let {token} = getState()
return superagent.post(`${__API_URL__}/photos`)
.set('Authorization', `Bearer ${token}`)
.field('description', photo.description)
.attach('photo', photo.photo)
.then((res) => {
dispatch(userPhotoCreate(res.body))
return res
})
}

export const userPhotoDeleteRequest = (photo) => (dispatch, getState) => {
let {token} = getState()
return superagent.delete(`${__API_URL__}/photos/${photo._id}`)
.set('Authorization', `Bearer ${token}`)
.then(res => {
dispatch(userPhotoDelete(photo))
return res
})
}

export const userPhotoUpdateRequest = (photo) => (dispatch, getState) => {
let {token} = getState()
return superagent.put(`${__API_URL__}/photos/${photo._id}`)
.set('Authorization', `Bearer ${token}`)
.field('description', photo.description)
.attach('photo', photo.photo)
.then(res => {
dispatch(userPhotoUpdate(res.body))
return res
})
}
48 changes: 48 additions & 0 deletions lab-nathan/frontend/src/actions/profile-actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import superagent from 'superagent'

// sync action creators
export const profileCreate = (profile) => ({
type: 'PROFILE_CREATE',
payload: profile,
})

export const profileUpdate = (profile) => ({
type: 'PROFILE_UPDATE',
payload: profile,
})

// async action creators
export const profileCreateRequest = (profile) => (dispatch, getState) => {
let {token} = getState()
return superagent.post(`${__API_URL__}/profiles`)
.set('Authorization', `Bearer ${token}`)
.field('bio', profile.bio)
.attach('avatar', profile.avatar)
.then(res => {
dispatch(profileCreate(res.body))
return res
})
}

export const profileUpdateRequest = (profile) => (dispatch, getState) => {
let {token} = getState()
return superagent.put(`${__API_URL__}/profiles/${profile._id}`)
.set('Authorization', `Bearer ${token}`)
.field('bio', profile.bio)
.attach('avatar', profile.avatar)
.then(res => {
dispatch(profileCreate(res.body))
return res
})
}

export const profileFetchRequest = () => (dispatch, getState) => {
let {token} = getState()
return superagent.get(`${__API_URL__}/profiles/me`)
.set('Authorization', `Bearer ${token}`)
.then(res => {
console.log(res);
dispatch(profileCreate(res.body))
return res
})
}
43 changes: 43 additions & 0 deletions lab-nathan/frontend/src/actions/token-actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import superagent from 'superagent';
import * as util from '../lib/utilities.js';

export const tokenSet = (token) => ({
type: 'TOKEN_SET',
payload: token
});

export const tokenDelete = (token) => ({
type: 'TOKEN_DELETE'
});

export const logout = () => {
util.deleteCookie('X-Sluggram-Token')
return { type: 'LOGOUT' }
}

export const signupRequest = (user) => (dispatch) => {
return superagent.post(`${__API_URL__}/signup`)
.withCredentials()
.send(user)
.then(response => {
dispatch(tokenSet(response.text));
try {
localStorage.token = response.text;
}
catch (error) {
console.log(error);
}

return response;
});
};

export const loginRequest = (user) => (dispatch) => {
return superagent.get(`${__API_URL__}/login`)
.withCredentials()
.auth(user.username, user.password)
.then(response => {
dispatch(tokenSet(response.text))
return response;
});
}
24 changes: 24 additions & 0 deletions lab-nathan/frontend/src/assets/btn_google_dark_disabled_ios.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions lab-nathan/frontend/src/assets/btn_google_dark_focus_ios.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions lab-nathan/frontend/src/assets/btn_google_dark_normal_ios.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading