show trial modal on sidebar
resolves #344
Pops up message for trial users letting them know to upgrade their plans before 3 day trial ends.
Still WIP, need to create endpoint in dashboard to call on to get info.
frontend/src/components/Sidebar/index.jsx
Instead of using useState for showTrialModal, upgradeLink, and daysLeft, you can use useReducer. This will allow you to manage all these states in one place, making your code more readable and performant.
Create Issue
const initialState = {
showTrialModal: true,
upgradeLink: "https://google.com",
daysLeft: 3
};
function reducer(state, action) {
switch (action.type) {
case 'SET_TRIAL_MODAL':
return {...state, showTrialModal: action.payload};
case 'SET_UPGRADE_LINK':
return {...state, upgradeLink: action.payload};
case 'SET_DAYS_LEFT':
return {...state, daysLeft: action.payload};
default:
throw new Error();
}
}
const [state, dispatch] = useReducer(reducer, initialState);
Instead of using inline styles, consider using CSS classes or styled-components. This will make your code more readable and maintainable. Create Issue
<div
ref={sidebarRef}
className="sidebar"
>
Instead of using window.open to open a new tab, consider using the Link component from react-router-dom with the target="_blank" attribute. This will improve the performance of your application.
Create Issue
import { Link } from 'react-router-dom';
<Link to={upgradeLink} target="_blank">Upgrade</Link>