Skip to content

Commit

Permalink
fix: Fix cookie lib build issue
Browse files Browse the repository at this point in the history
  • Loading branch information
borisrorsvort committed Nov 20, 2019
1 parent 0749fcd commit 2eb8a79
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 52 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"dist"
],
"dependencies": {
"@use-hook/use-cookie": "^0.1.4",
"classnames": "^2.2.6"
"classnames": "^2.2.6",
"react-cookie": "^4.0.1"
}
}
19 changes: 11 additions & 8 deletions src/components/InfoBox/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from "react";
import React, { useEffect } from "react";
import { makeStyles } from "@material-ui/styles";
import { Typography, IconButton } from "@material-ui/core";
import Icon from "@material-ui/icons/InfoTwoTone";
import CloseIcon from "@material-ui/icons/Close";
import classNames from "classnames";
import { useCookie } from "@use-hook/use-cookie";
import PropTypes from "prop-types";
import { useCookies } from "react-cookie";

const useStyles = makeStyles(theme => ({
root: {
Expand Down Expand Up @@ -35,12 +35,10 @@ const useStyles = makeStyles(theme => ({

const InfoBox = props => {
const classes = useStyles(props);
const [display, setDisplay] = useCookie(
`blsq-info-box-hesabu-${props.name}`,
"true",
);
const cookieName = `blsq-info-box-hesabu-${props.name}`;
const [cookies, setCookie] = useCookies([cookieName]);

if (display === "true") {
if (props.dismissable && !cookies[cookieName]) {
return (
<div className={classNames(classes.root, props.className)}>
<Icon className={classes.icon} />
Expand All @@ -55,7 +53,7 @@ const InfoBox = props => {
<IconButton
size="small"
className={classes.closeIcon}
onClick={() => setDisplay(false)}
onClick={() => setCookie(cookieName, true)}
>
<CloseIcon className={classes.smallIcon} />
</IconButton>
Expand All @@ -70,6 +68,11 @@ InfoBox.propTypes = {
className: PropTypes.string,
name: PropTypes.string.isRequired,
text: PropTypes.string,
dismissable: PropTypes.bool,
};

InfoBox.defaultProps = {
dismissable: true,
};

export default InfoBox;
87 changes: 45 additions & 42 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2347,6 +2347,11 @@
dependencies:
"@babel/types" "^7.3.0"

"@types/cookie@^0.3.3":
version "0.3.3"
resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.3.3.tgz#85bc74ba782fb7aa3a514d11767832b0e3bc6803"
integrity sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow==

"@types/[email protected]":
version "0.0.39"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
Expand All @@ -2371,6 +2376,14 @@
resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.3.tgz#856c99cdc1551d22c22b18b5402719affec9839a"
integrity sha512-cS5owqtwzLN5kY+l+KgKdRJ/Cee8tlmQoGQuIE9tWnSmS3JMKzmxo2HIAk2wODMifGwO20d62xZQLYz+RLfXmw==

"@types/hoist-non-react-statics@^3.0.1":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f"
integrity sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==
dependencies:
"@types/react" "*"
hoist-non-react-statics "^3.3.0"

"@types/is-function@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@types/is-function/-/is-function-1.0.0.tgz#1b0b819b1636c7baf0d6785d030d12edf70c3e83"
Expand Down Expand Up @@ -2416,6 +2429,11 @@
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
integrity sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==

"@types/object-assign@^4.0.30":
version "4.0.30"
resolved "https://registry.yarnpkg.com/@types/object-assign/-/object-assign-4.0.30.tgz#8949371d5a99f4381ee0f1df0a9b7a187e07e652"
integrity sha1-iUk3HVqZ9Dge4PHfCpt6GH4H5lI=

"@types/parse-json@^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
Expand Down Expand Up @@ -2507,15 +2525,6 @@
dependencies:
"@types/yargs-parser" "*"

"@use-hook/use-cookie@^0.1.4":
version "0.1.4"
resolved "https://registry.yarnpkg.com/@use-hook/use-cookie/-/use-cookie-0.1.4.tgz#9a506996174b634385fc2dc1f15fec3c97bb2c7d"
integrity sha512-JewDdt4m0K++qv++Ihk0vLjbkWqxEfervpaNY1n2JCxJY5QunZ59lNV0pXwQS1VAx/ipKjLarPLLHV7+RboIkw==
dependencies:
js-cookie "2.2.0"
react "^16.8.0"
react-dom "^16.8.0"

"@usulpro/color-picker@^1.1.3":
version "1.1.3"
resolved "https://registry.yarnpkg.com/@usulpro/color-picker/-/color-picker-1.1.3.tgz#02d3295ae12626da75840346b3b0abd564b53d93"
Expand Down Expand Up @@ -5633,7 +5642,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c"
integrity sha1-4wOogrNCzD7oylE6eZmXNNqzriw=

[email protected]:
[email protected], cookie@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba"
integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==
Expand Down Expand Up @@ -8685,6 +8694,13 @@ hmac-drbg@^1.0.0:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.1"

hoist-non-react-statics@^3.0.0:
version "3.3.1"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#101685d3aff3b23ea213163f6e8e12f4f111e19f"
integrity sha512-wbg3bpgA/ZqWrZuMOeJi8+SKMhr7X9TesL/rXMjTzh0p0JUBo3II8DHboYbuIXWRlttrUFxwcu/5kygrCw8fJw==
dependencies:
react-is "^16.7.0"

hoist-non-react-statics@^3.2.1, hoist-non-react-statics@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.0.tgz#b09178f0122184fb95acf525daaecb4d8f45958b"
Expand Down Expand Up @@ -10519,11 +10535,6 @@ js-beautify@^1.8.8, js-beautify@^1.8.9:
mkdirp "~0.5.1"
nopt "~4.0.1"

[email protected]:
version "2.2.0"
resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.0.tgz#1b2c279a6eece380a12168b92485265b35b1effb"
integrity sha1-Gywnmm7s44ChIWi5JIUmWzWx7/s=

js-levenshtein@^1.1.3:
version "1.1.6"
resolved "https://registry.yarnpkg.com/js-levenshtein/-/js-levenshtein-1.1.6.tgz#c6cee58eb3550372df8deb85fad5ce66ce01d59d"
Expand Down Expand Up @@ -14237,6 +14248,15 @@ react-color@^2.17.0:
reactcss "^1.2.0"
tinycolor2 "^1.4.1"

react-cookie@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/react-cookie/-/react-cookie-4.0.1.tgz#c21b2c30a5cacf320b45338fa3dcaf76d9fe9c2c"
integrity sha512-h61qAtSXvfjNa81h3XCFdFoyFaF+nb7gjK0cxQuTiCPMPAe50D950FjLCFhaIfSpAesQFAmkxf5XFpWoEVBDAA==
dependencies:
"@types/hoist-non-react-statics" "^3.0.1"
hoist-non-react-statics "^3.0.0"
universal-cookie "^4.0.0"

react-dev-utils@^5.0.2:
version "5.0.3"
resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-5.0.3.tgz#92f97668f03deb09d7fa11ea288832a8c756e35e"
Expand Down Expand Up @@ -14315,16 +14335,6 @@ react-dom@^16.4.1, react-dom@^16.8.3:
prop-types "^15.6.2"
scheduler "^0.17.0"

react-dom@^16.8.0:
version "16.12.0"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.12.0.tgz#0da4b714b8d13c2038c9396b54a92baea633fe11"
integrity sha512-LMxFfAGrcS3kETtQaCkTKjMiifahaMySFDn71fZUNpPHZQEzmk/GiAeIT8JSOrHB23fnuCOMruL2a8NYlw+8Gw==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"
scheduler "^0.18.0"

react-draggable@^4.0.3:
version "4.1.0"
resolved "https://registry.yarnpkg.com/react-draggable/-/react-draggable-4.1.0.tgz#e1c5b774001e32f0bff397254e1e9d5448ac92a4"
Expand Down Expand Up @@ -14548,15 +14558,6 @@ react@^16.4.1, react@^16.8.3:
object-assign "^4.1.1"
prop-types "^15.6.2"

react@^16.8.0:
version "16.12.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.12.0.tgz#0c0a9c6a142429e3614834d5a778e18aa78a0b83"
integrity sha512-fglqy3k5E+81pA8s+7K0/T3DBCF0ZDOher1elBFzF7O6arXJgzyu/FW+COxFvAWXJoJN9KIZbT2LXlukwphYTA==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"

reactcss@^1.2.0:
version "1.2.3"
resolved "https://registry.yarnpkg.com/reactcss/-/reactcss-1.2.3.tgz#c00013875e557b1cf0dfd9a368a1c3dab3b548dd"
Expand Down Expand Up @@ -15465,14 +15466,6 @@ scheduler@^0.17.0:
loose-envify "^1.1.0"
object-assign "^4.1.1"

scheduler@^0.18.0:
version "0.18.0"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.18.0.tgz#5901ad6659bc1d8f3fdaf36eb7a67b0d6746b1c4"
integrity sha512-agTSHR1Nbfi6ulI0kYNK0203joW2Y5W4po4l+v03tOoiJKpTBbxpNhWDvqc/4IcOw+KLmSiQLTasZ4cab2/UWQ==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"

schema-utils@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.3.0.tgz#f5877222ce3e931edae039f17eb3716e7137f8cf"
Expand Down Expand Up @@ -17243,6 +17236,16 @@ unist-util-visit@^1.0.0, unist-util-visit@^1.1.0:
dependencies:
unist-util-visit-parents "^2.0.0"

universal-cookie@^4.0.0:
version "4.0.2"
resolved "https://registry.yarnpkg.com/universal-cookie/-/universal-cookie-4.0.2.tgz#c3398a64c72ff0c31fecb1ac4966c424e8669c6d"
integrity sha512-n14lhA//lQeYRweP9j9uXsshN9Cs4LunVSnvAGmnA69SofwsjpUU03geaCaPC9LlsH2rkBy99o3zxQyVOldGvA==
dependencies:
"@types/cookie" "^0.3.3"
"@types/object-assign" "^4.0.30"
cookie "^0.4.0"
object-assign "^4.1.1"

universal-user-agent@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-4.0.0.tgz#27da2ec87e32769619f68a14996465ea1cb9df16"
Expand Down

0 comments on commit 2eb8a79

Please sign in to comment.