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