Skip to content

Commit 9f5c1c8

Browse files
committed
client: modify auto login message, replace user image with svg
1 parent c498a06 commit 9f5c1c8

File tree

5 files changed

+31
-11
lines changed

5 files changed

+31
-11
lines changed

client/src/components/button/toggle-theme.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@
6969
opacity: 0;
7070
}
7171

72-
.theme__button label:active .circle {
72+
/* .theme__button label:active .circle {
7373
width: 50px;
74-
}
74+
} */

client/src/components/modal/brief-info.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ const BriefInfo: React.FC<RegisterDataProps> = ({ registerData, setRegisterData
3838
}, []);
3939

4040
const handleAvatarChange = useFileHandler(5);
41-
4241
const handleFileInputChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
4342
const base64String = await handleAvatarChange(e);
4443
setRegisterData(prevState => ({
@@ -124,7 +123,8 @@ const BriefInfo: React.FC<RegisterDataProps> = ({ registerData, setRegisterData
124123
<div className='avatar-username__container'>
125124
<div
126125
className='avatar__container'
127-
onClick={() => document.getElementById('user-avatar')?.click()}
126+
// onClick={() => document.getElementById('user-avatar')?.click()}
127+
onClick={() => toast.warning('Feature coming soon.')}
128128
>
129129
<input
130130
type="file"

client/src/components/sidebar/profile.css

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
.modal-profile__image {
3535
width: 40px;
3636
height: 40px;
37+
display: grid;
38+
place-items: center;
3739
border-radius: 50%;
3840
overflow: hidden;
3941
cursor: pointer;

client/src/components/sidebar/profile.tsx

+23-5
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ import { useNavStore } from "../../store/useNavStore";
55
import { AuthStatus, AuthTab, useAuthStore } from "../../store/useAuthStore";
66
import ToggleTheme from "../button/toggle-theme";
77
import useLogout from "../../hooks/useLogout";
8+
import LoadingSkeleton from "../loading/skeleton";
89
import { IoMdPerson } from "react-icons/io";
910
import { PiSignOutBold } from "react-icons/pi";
10-
import LoadingSkeleton from "../loading/skeleton";
1111
import { GoPerson } from "react-icons/go";
12+
import { FaRegUser } from "react-icons/fa";
1213

1314
const Profile = () => {
1415
const navigate = useNavigate();
1516
const { expand, setExpand } = useNavStore();
16-
const { isAuthenticated, setIsAuthenticated, user, setUser, setAuthTab } = useAuthStore();
17+
const { isAuthenticated, setIsAuthenticated, user, setUser, authTab, setAuthTab } = useAuthStore();
1718

1819
useEffect(() => {
1920
const handleClickOutside = (event: MouseEvent) => {
@@ -40,12 +41,25 @@ const Profile = () => {
4041
) : isAuthenticated === AuthStatus.Authenticated ? (
4142
<div
4243
className='profile__image'
44+
style={{
45+
borderWidth: '2px',
46+
borderStyle: 'solid',
47+
borderColor: `${expand ? 'var(--body_color)' : 'var(--nav_border)'}`
48+
}}
4349
onClick={() => setExpand(!expand)}
4450
>
45-
<img src={user.avatar || "/user.jpg"} alt="" />
51+
{user.avatar ? (
52+
<img src={user.avatar} alt="" />
53+
) : (
54+
<FaRegUser style={{ width: '50%', height: '50%' }} />
55+
)}
4656
</div>
4757
) : (
48-
<button className='login-btn' onClick={() => setAuthTab(AuthTab.Login)}>
58+
<button
59+
className='login-btn'
60+
style={{ border: `${authTab !== AuthTab.Closed ? '2px solid var(--body_color)' : ''}` }}
61+
onClick={() => setAuthTab(AuthTab.Login)}
62+
>
4963
<GoPerson size={20} />
5064
<p>Login</p>
5165
</button>
@@ -56,7 +70,11 @@ const Profile = () => {
5670
<div className='modal-profile__wrapper'>
5771
<div className="profile-wrapper">
5872
<div className='modal-profile__image'>
59-
<img src={user.avatar || "/user.jpg"} alt="" />
73+
{user.avatar ? (
74+
<img src={user.avatar} alt="" />
75+
) : (
76+
<FaRegUser style={{ width: '50%', height: '50%' }} />
77+
)}
6078
</div>
6179
<div className='modal-profile__info'>
6280
<p>{user.first_name} {user.last_name}</p>

client/src/hooks/useAutoLogin.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ const useAutoLogin = (setRoute: SetRoute, setUser: SetUser, setIsAuthenticated:
3030
setAuthTab(AuthTab.Closed);
3131
}
3232
else {
33-
toast.success(response.message);
33+
toast.success('Session logged out.');
3434
setIsAuthenticated(AuthStatus.Failed);
3535
localStorage.removeItem('token');
3636
}
3737
})
3838
.catch(() => {
39-
toast.success('Something went wrong.');
39+
toast.success('Session logged out.');
4040
setIsAuthenticated(AuthStatus.Failed);
4141
localStorage.removeItem('token');
4242
});

0 commit comments

Comments
 (0)