diff --git a/components/Announcement.js b/components/Announcement.js index ae02bea..d98f737 100644 --- a/components/Announcement.js +++ b/components/Announcement.js @@ -1,93 +1,97 @@ import React from 'react' -const key = 'CARBON_CTA_1' +import { useAuth } from './AuthContext' -class Toast extends React.Component { - state = { - open: false - } +const key = 'CARBON_CTA_1' - close = () => { - this.setState({ open: false }) - window.localStorage.setItem(key, true) - } +function Toast() { + const [open, setState] = React.useState(false) - componentDidMount() { + React.useEffect(() => { window.localStorage.removeItem('CARBON_CTA') if (!window.localStorage.getItem(key)) { - this.setState({ open: true }) + setState(true) } + }, []) + + const user = useAuth() + + if (process.env.NODE_ENV !== 'production') { + return null } - render() { - if (process.env.NODE_ENV !== 'production') { - return null - } + if (!open) { + return null + } - if (!this.state.open) { - return null - } + if (user) { + return null + } - return ( -
Never lose a Carbon again - save your work automatically!
- Click "Sign up" to try it out! - -