feat: guest mode

This commit is contained in:
Tristan Yang
2022-08-30 23:20:00 +08:00
parent ac3289b255
commit 5ffd9748fd
11 changed files with 179 additions and 44 deletions
+33 -20
View File
@@ -1,36 +1,49 @@
import React from "react";
import { NavLink } from "react-router-dom";
// import { useEffect } from "react";
import { useDispatch } from "react-redux";
import { useNavigate } from "react-router-dom";
import styled from "styled-components";
import { resetAuthData } from "../../../app/slices/auth.data";
import Button from "../../../common/component/styled/Button";
import useLogout from "../../../common/hook/useLogout";
const Styled = styled.div`
display: flex;
align-items: center;
justify-content: space-between;
background: #e5e7eb;
border-radius: var(--br);
width: 100%;
width: -webkit-fill-available;
padding: 14px 18px;
color: #aaa;
.hand {
font-size: 22px;
margin-right: 10px;
}
.link {
font-weight: bold;
color: #333;
padding: 0 8px;
padding: 16px 18px;
.txt {
font-weight: 500;
font-size: 14px;
line-height: 20px;
color: #98a2b3;
.hand {
font-size: 20px;
margin-right: 10px;
}
}
`;
type Props = {};
// type Props = {};
const LoginTip = () => {
const dispatch = useDispatch();
const { clearLocalData } = useLogout();
const navigateTo = useNavigate();
const handleSignIn = () => {
dispatch(resetAuthData());
clearLocalData();
navigateTo("/login");
};
const LoginTip = (props: Props) => {
return (
<Styled>
<i className="hand">👋</i>
Please{" "}
<NavLink className={"link"} to={`/login`}>
Login/Register
</NavLink>{" "}
before you can send message
<span className="txt">
<i className="hand">👋</i>
Please sign in to send message
</span>
<Button onClick={handleSignIn} className="small">{`Sign In`}</Button>
</Styled>
);
};