yarn add samjs-components
In your root component:
import { CookieToaster } from 'samjs-components'
...
<CookieToaster />
...
To modify the css you can use the following structure:
.cookie-toaster { // or cookie-toaster-modal, cookie-toaster-top
// topmost div
.cookie-container {
// inner content
h1{
// title css
}
p{
// text css
}
a{
// link css
}
button {
// button css
}
}
}
- CookieToaster
- CookieToasterTop
- CookieToasterModal
- title: String, title (duh)
- text: String, content
- btnAcceptText: String, button label
- btnDeclineText: String, button label
- accept: function, callback to handle accept
- decline: function, callback to handle decline
- popped: Boolean, set this property in your localstorage to track if cookie has been shown for the user
- linkUrl: String, a url
- linkText: String, the text to display for the link
- type: 'top', 'bottom', or 'modal'
- cookieHasPopped: cookie has been shown
In your root component:
import { NetworkUtils } from 'samjs-components'
...
NetworkUtils.get(myRoute, myExtraHeaders).then(() => {
//Do awesome stuff
});
...
- route: API endpoint (e.g.: 'users/login')
- extraHeaders: an array of headers you want to include
- body: the body of your request
- get: route string, array of headers
- post: route string, body, array of headers
- put: route string, body, array of headers
- delete: route string
You should have your OAuth token available in localStorage with the key 'session'.
...
localStorage.setItem('session', '<myToken>');
...
Set your API host in your env file as 'REACT_APP_API_HOST'. This enables you to easily switch between environements without having to change any params for the NetworkUtils module.