Skip to content

Commit 9fb260b

Browse files
committed
feat: Remove Profile page + Moved userInfo to General settings.
1 parent d22b911 commit 9fb260b

11 files changed

Lines changed: 62 additions & 93 deletions

File tree

src/components/Layout/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export const Header = () => {
9999
<CircleButton
100100
onClick={() => {
101101
if (isConnected()) {
102-
navigate('/settings/profile')
102+
navigate('/settings/general')
103103
} else {
104104
openAuthModal()
105105
}

src/components/Layout/SettingsLayout/SettingsLayout.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ import './settings.css'
55

66
export const SettingsLayout = () => {
77
const navigation = [
8-
{
9-
name: 'Profile',
10-
path: '/settings/profile',
11-
},
128
{
139
name: 'Topics',
1410
path: '/settings/topics',

src/features/auth/components/AuthModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const AuthModal = ({ showAuth }: AuthModalProps) => {
2929
name: name,
3030
imageURL: imageURL,
3131
},
32+
providerId: provider.providerId,
3233
})
3334
}
3435
})

src/features/auth/hooks/useAuth.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { trackUserDisconnect } from 'src/lib/analytics'
44
export const useAuth = () => {
55
const { isAuthModalOpen, openAuthModal, closeAuthModal } = AuthModalStore()
66
const authStore = AuthStore()
7-
const { user, initState, clear } = authStore
7+
const { user, providerId, initState, clear } = authStore
88

99
const isConnected = () => user != null
1010

@@ -21,5 +21,6 @@ export const useAuth = () => {
2121
logout,
2222
isAuthModalOpen,
2323
user,
24+
providerId,
2425
}
2526
}

src/features/auth/stores/authStore.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { persist } from 'zustand/middleware'
44

55
type AuthState = {
66
user: User | null
7+
providerId: string | null
78
}
89

910
type AuthActions = {
@@ -14,11 +15,12 @@ type AuthActions = {
1415
export const AuthStore = create(
1516
persist<AuthState & AuthActions>(
1617
(set) => ({
17-
idToken: null,
1818
user: null,
19+
providerId: null,
1920
initState: (newState: AuthState) =>
2021
set({
2122
user: newState.user,
23+
providerId: newState.providerId,
2224
}),
2325
clear: () => set({ user: null }),
2426
}),

src/features/settings/components/GeneralSettings/GeneralSettings.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React from 'react'
22
import Toggle from 'react-toggle'
33
import 'react-toggle/style.css'
4-
import { ChipsSet } from 'src/components/Elements'
4+
import { Button, ChipsSet } from 'src/components/Elements'
55
import { Footer } from 'src/components/Layout'
66
import { SettingsContentLayout } from 'src/components/Layout/SettingsContentLayout'
7+
import { useAuth, User } from 'src/features/auth'
78
import {
89
identifyUserLinksInNewTab,
910
identifyUserListingMode,
@@ -19,6 +20,27 @@ import { Option } from 'src/types'
1920
import { DNDSettings } from './DNDSettings'
2021
import './generalSettings.css'
2122

23+
interface UserInfoProps {
24+
user: User
25+
}
26+
27+
const UserInfo = ({ user }: UserInfoProps) => {
28+
const { logout, providerId } = useAuth()
29+
30+
return (
31+
<div className="userContent">
32+
{user?.imageURL && <img src={user.imageURL} className="userImage"></img>}
33+
<div className="userInfos">
34+
<div className="userName">{user.name}</div>
35+
<div className="providerId">Logged using {providerId}</div>
36+
</div>
37+
<Button className="logoutBtn" onClick={logout}>
38+
Logout
39+
</Button>
40+
</div>
41+
)
42+
}
43+
2244
export const GeneralSettings = () => {
2345
const {
2446
openLinksNewTab,
@@ -62,13 +84,16 @@ export const GeneralSettings = () => {
6284
}
6385
}
6486

87+
const { user } = useAuth()
88+
6589
return (
6690
<SettingsContentLayout
6791
title="General Settings"
6892
description={
6993
'Customize your experience by selecting the number of cards you want to see, the search engine you want to use and more.'
7094
}>
7195
<div>
96+
{user != null && <UserInfo user={user} />}
7297
<div className="settingRow">
7398
<p className="settingTitle">Max number of cards to display</p>
7499
<div className="settingContent">

src/features/settings/components/GeneralSettings/generalSettings.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,31 @@ Select styles
9393
border-radius: 20px !important;
9494
color: var(--tag-secondary-color) !important;
9595
}
96+
97+
.userContent {
98+
width: auto;
99+
padding: 20px 10px;
100+
display: flex;
101+
align-items: center;
102+
border-bottom: 1px solid var(--card-content-divider);
103+
}
104+
.userContent .userImage {
105+
width: 60px;
106+
height: 60px;
107+
border-radius: 100%;
108+
}
109+
.userContent .userInfos {
110+
width: auto;
111+
margin-left: 10px;
112+
}
113+
.userContent .userName {
114+
font-size: larger;
115+
font-weight: 600;
116+
}
117+
.userContent .userEmail {
118+
font-size: medium;
119+
margin-top: 6px;
120+
}
121+
.userContent .logoutBtn {
122+
margin-left: auto;
123+
}

src/features/settings/components/Profile/ProfileSettings.tsx

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/features/settings/components/Profile/profileSettings.css

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/features/settings/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export * from './components/BookmarkSettings'
22
export * from './components/GeneralSettings'
3-
export * from './components/Profile/ProfileSettings'
3+
44
export * from './components/SearchEngineSettings'
55
export * from './components/SourceSettings'
66
export * from './components/TopicSettings'

0 commit comments

Comments
 (0)