|
|
@ -1,39 +1,44 @@
|
|
|
|
import React from 'react'
|
|
|
|
import React from 'react'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { useAuth } from './AuthContext'
|
|
|
|
|
|
|
|
|
|
|
|
const key = 'CARBON_CTA_1'
|
|
|
|
const key = 'CARBON_CTA_1'
|
|
|
|
|
|
|
|
|
|
|
|
class Toast extends React.Component {
|
|
|
|
function Toast() {
|
|
|
|
state = {
|
|
|
|
const [open, setState] = React.useState(false)
|
|
|
|
open: false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
close = () => {
|
|
|
|
React.useEffect(() => {
|
|
|
|
this.setState({ open: false })
|
|
|
|
|
|
|
|
window.localStorage.setItem(key, true)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
|
|
|
window.localStorage.removeItem('CARBON_CTA')
|
|
|
|
window.localStorage.removeItem('CARBON_CTA')
|
|
|
|
if (!window.localStorage.getItem(key)) {
|
|
|
|
if (!window.localStorage.getItem(key)) {
|
|
|
|
this.setState({ open: true })
|
|
|
|
setState(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const user = useAuth()
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
return null
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.state.open) {
|
|
|
|
if (!open) {
|
|
|
|
return null
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (user) {
|
|
|
|
|
|
|
|
return null
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function close() {
|
|
|
|
|
|
|
|
setState(false)
|
|
|
|
|
|
|
|
window.localStorage.setItem(key, true)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className="toast mb4">
|
|
|
|
<div className="toast mb4">
|
|
|
|
<div className="toast-content">
|
|
|
|
<div className="toast-content">
|
|
|
|
<p>Never lose a Carbon again - save your work automatically!</p>
|
|
|
|
<p>Never lose a Carbon again - save your work automatically!</p>
|
|
|
|
Click "Sign up" to try it out!
|
|
|
|
Click "Sign up" to try it out!
|
|
|
|
<button className="close-toast" onClick={this.close}>
|
|
|
|
<button className="close-toast" onClick={close}>
|
|
|
|
×
|
|
|
|
×
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
@ -88,6 +93,5 @@ class Toast extends React.Component {
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default Toast
|
|
|
|
export default Toast
|
|
|
|