This file contains 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'; | |
export default axios.create({ | |
baseURL: 'https://api.expertlead.de/v.1.0/', | |
timeout: 1000, | |
headers: { | |
'token': '<YOUR_TOKEN>' | |
} | |
}); |
This file contains 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
export default (authenticate, deny) => { | |
// from https://developers.facebook.com/docs/reference/javascript/FB.login/v6.0 | |
FB.login(function(response) { | |
if (response.authResponse) { | |
console.log('Welcome! Fetching your information.... '); | |
FB.api('/me', function(response) { | |
console.log('Good to see you, ' + response.name + '.'); | |
// actual integration |
This file contains 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 React, { useState } from 'react'; | |
import { saveUser } from 'services/user'; | |
const Users = () => { | |
const [loading, setLoading] = useState(false); | |
const [user, setUser] = useState(null); | |
const [error, setError] = useState(null); | |
const save = useCallback(() => { | |
setError(null); |
This file contains 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
const getBaseURL = () => { | |
switch(process.env.NODE_ENV) { | |
case 'staging': | |
return '//staging-api.nelsoncorp.com/ | |
case 'production': | |
return '//api.nelsoncorp.com/ | |
default: | |
return '//localhost:9000/ | |
} | |
} |
This file contains 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
const getTotal = (stack, [score, max]) => ({ | |
score: stack.score + score, | |
max: stack.max + max | |
}); | |
const getPercentage = ({ score, max }) => score * 100 / max; | |
const study = ({ score, max }, hours = 1) => ({ | |
until: expected => { | |
const goal = { score: score + 1, max: max + 1 }; |
This file contains 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 { func, node, oneOf, oneOfType, shape, string } from 'prop-types'; | |
import items from './items'; | |
export const item = { | |
id: string.isRequired, | |
children: node.isRequired, | |
url: oneOfType([string, func]), | |
target: oneOf(['_blank']), | |
}; |
This file contains 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
const sample = [ | |
[ | |
[ | |
[ | |
[ | |
[ | |
{ | |
foo: [{ rate: 2.18 }], | |
}, | |
], |
This file contains 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
const convert = seconds => | |
[ | |
{ label: "year(s)", amount: 31104000 }, | |
{ label: "month(s)", amount: 2592000 }, | |
{ label: "week(s)", amount: 604800 }, | |
{ label: "day(s)", amount: 86400 }, | |
{ label: "hour(s)", amount: 3600 }, | |
{ label: "minute(s)", amount: 60 }, | |
{ label: "second(s)", amount: 1 } | |
] |
This file contains 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 last from "lodash/last"; | |
import React, { Fragment } from "react"; | |
import { usePersisted, useVolatile, useLog } from "nodh"; | |
// your service (async operation) | |
const fetchGithubRepos = () => | |
window | |
.fetch("https://api.github.com/search/repositories?q=react") | |
.then(response => response.json()); |
This file contains 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 React from "react"; | |
import { Provider as Curse } from "nodh"; | |
import YourApp from "./app"; | |
// it works 👍 | |
export default ( | |
<Curse> | |
<YourApp /> | |
</Curse> |