|
@@ -7,37 +7,25 @@ import { setFormatCode } from '../../store/currentWork/currentWorkSlice';
|
|
import { BsFillCloudFill } from 'react-icons/bs';
|
|
import { BsFillCloudFill } from 'react-icons/bs';
|
|
import { FaPen } from 'react-icons/fa/index';
|
|
import { FaPen } from 'react-icons/fa/index';
|
|
import { GoMessage } from '../GoMessage/GoMessage';
|
|
import { GoMessage } from '../GoMessage/GoMessage';
|
|
|
|
+import { LoginPopup } from '../LoginPopup/LoginPopup';
|
|
|
|
+import { usePopup } from '../../hooks/usePopup.js';
|
|
|
|
|
|
export const HeaderPen = () => {
|
|
export const HeaderPen = () => {
|
|
const dispatch = useDispatch();
|
|
const dispatch = useDispatch();
|
|
const { isAuth } = useSelector((state) => state.auth);
|
|
const { isAuth } = useSelector((state) => state.auth);
|
|
const { id, title, owner, files } = useSelector((state) => state.currentWork);
|
|
const { id, title, owner, files } = useSelector((state) => state.currentWork);
|
|
|
|
+ const loginPopup = usePopup();
|
|
|
|
|
|
const logout = () => {
|
|
const logout = () => {
|
|
localStorage.removeItem('authToken');
|
|
localStorage.removeItem('authToken');
|
|
dispatch(logout());
|
|
dispatch(logout());
|
|
};
|
|
};
|
|
|
|
|
|
- // const loginPrompt = (
|
|
|
|
- // <div className={style.loginPopup}>
|
|
|
|
- // <span>
|
|
|
|
- // You’ll have to Log In or Sign Up to save your Pen. Don’t worry! All your
|
|
|
|
- // work will be saved to your account.
|
|
|
|
- // </span>
|
|
|
|
- // <div>
|
|
|
|
- // <button>close</button>
|
|
|
|
- // <NavLink to={'/login'}>OK</NavLink>
|
|
|
|
- // </div>
|
|
|
|
- // </div>
|
|
|
|
- // );
|
|
|
|
-
|
|
|
|
- // TODO: HoldUp component
|
|
|
|
-
|
|
|
|
const handleSaveFiles = () => {
|
|
const handleSaveFiles = () => {
|
|
dispatch(setFormatCode());
|
|
dispatch(setFormatCode());
|
|
|
|
|
|
if (!isAuth) {
|
|
if (!isAuth) {
|
|
- console.log('HoldUp component!!!!');
|
|
|
|
|
|
+ loginPopup.open();
|
|
} else {
|
|
} else {
|
|
dispatch(
|
|
dispatch(
|
|
saveFiles({
|
|
saveFiles({
|
|
@@ -64,6 +52,8 @@ export const HeaderPen = () => {
|
|
|
|
|
|
<GoMessage />
|
|
<GoMessage />
|
|
|
|
|
|
|
|
+ <LoginPopup isOpen={loginPopup.isPopupVisible} close={loginPopup.close} />
|
|
|
|
+
|
|
<nav>
|
|
<nav>
|
|
<button onClick={handleSaveFiles}>
|
|
<button onClick={handleSaveFiles}>
|
|
<BsFillCloudFill />
|
|
<BsFillCloudFill />
|