This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AUTH_USER, AUTH_ERROR } from "../actions/types"; | |
export default function(state = {}, action) { | |
switch (action.type) { | |
case AUTH_USER: | |
return { ...state, error: "", authenticated: true }; | |
case AUTH_ERROR: | |
return { ...state, error: action.payload.response }; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from "axios"; | |
import { AUTH_USER, AUTH_ERROR } from "./types"; | |
const ROOT_URL = "http://localhost:"; | |
const PORT = "3030"; | |
export function signinUser({ email, password }) { | |
return ((dispatch) => { | |
return axios.post(`${ROOT_URL}${PORT}/signin`, { email, password }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
users = [ | |
{id: 1, firstname: 'steven', lastname: 'jones', | |
comments: [ | |
{id: 1, post_id: 1, comment: 'woah cool bro'} | |
]}, | |
{id: 2, firstname: 'don', lastname: 'king', | |
comments: [ | |
{id: 3, post_id: 1, comment: 'dope'} | |
] | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let search_term = 'bla' | |
let results = [ | |
{id: 1, desc: "b", topic: "bla", name: "b", match: 0.33}, | |
{id: 2, desc: "b", topic: "b", name: "bla", match: 0.33}, | |
{id: 3, desc: "bla", topic: "b", name: "b", match: 0.33} | |
] | |
let lookup_table = [ | |
{ attribute: 'name', weight: 0.3 }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sortResults = (arr) => { | |
return arr.sort((a, b) => b.match - a.match) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
calculateNewMatch = (object, weighting) => { | |
return object.match * weighting | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
returnWeightedLookupByKey = (lookup_table, attribute) => { | |
return lookup_table.find(x => x.attribute === attribute).weight | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
findKeyBySearchTerm = (object, term) => { | |
return Object.keys(object).find(key => object[key] === term); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(1 < 2 < 3); | |
console.log(3 > 2 > 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sum(arg1) { | |
if (arguments.length > 1) { | |
return arguments[0] + arguments[1]; | |
} else { | |
return function(arg2) { | |
return arg1 + arg2; | |
}; | |
} | |
} |