1- import React , { useState } from 'react'
2- import { FaGithub } from 'react-icons/fa'
3- import { FcGoogle } from 'react-icons/fc'
4- import { IoCheckmarkOutline } from 'react-icons/io5'
1+ import React from 'react'
52import Toggle from 'react-toggle'
63import 'react-toggle/style.css'
7- import { ReactComponent as StreakIcon } from 'src/assets/icons/fire_icon.svg'
8- import { Button , ChipsSet , ConfirmModal } from 'src/components/Elements'
4+ import { ChipsSet } from 'src/components/Elements'
95import { Footer } from 'src/components/Layout'
106import { SettingsContentLayout } from 'src/components/Layout/SettingsContentLayout'
11- import { useAuth , User } from 'src/features/auth'
7+ import { useAuth } from 'src/features/auth'
128import {
139 identifyUserLinksInNewTab ,
1410 identifyUserListingMode ,
@@ -21,82 +17,10 @@ import {
2117} from 'src/lib/analytics'
2218import { useUserPreferences } from 'src/stores/preferences'
2319import { Option } from 'src/types'
24- import { pluralize } from 'src/utils/String '
20+ import { UserInfo } from '../UserSettings/UserInfo '
2521import { DNDSettings } from './DNDSettings'
2622import './generalSettings.css'
2723
28- // TODO Maybe we should create a separate folder in components for UserInfo ?
29- interface UserInfoProps {
30- user : User
31- }
32-
33- const UserInfo = ( { user } : UserInfoProps ) => {
34- const { logout, providerId } = useAuth ( )
35- const providerName = providerId ?. split ( '.' ) [ 0 ] || 'Unknown'
36- const [ showLogout , setShowLogout ] = useState ( false )
37-
38- return (
39- < div className = "userContent" >
40- < ConfirmModal
41- showModal = { showLogout }
42- title = "Confirm logout"
43- description = "Are you sure you want to logout?"
44- onClose = { ( ) => setShowLogout ( false ) }
45- onConfirm = { logout }
46- />
47- { user ?. imageURL && < img src = { user . imageURL } className = "userImage" > </ img > }
48- < div className = "userInfos" >
49- < div className = "userName" > { user . name } </ div >
50- < div className = "sub" >
51- { providerId == 'github.com' ? (
52- < FaGithub size = { 18 } />
53- ) : providerId == 'google.com' ? (
54- < FcGoogle size = { 18 } />
55- ) : null }
56- Connected with < span className = "capitalize" > { providerName } </ span >
57- </ div >
58- < div >
59- < Button className = "logoutBtn" onClick = { ( ) => setShowLogout ( true ) } size = "small" >
60- Logout
61- </ Button >
62- </ div >
63- </ div >
64-
65- < div className = "streaks" >
66- < p className = "title" >
67- You're on{ ' ' }
68- < span className = "highlight" >
69- < StreakIcon className = "icon" />
70- { pluralize ( user . streak || 1 , 'day' ) } streak
71- </ span >
72- </ p >
73- < div >
74- < ul className = "streaksWeek" >
75- { Array . from ( { length : 5 } , ( _ , i ) => {
76- const streak = user . streak || 1
77- if ( i < streak ) {
78- return (
79- < li key = { `day-${ i } ` } className = "dayWrapper checked" >
80- < span className = "day" >
81- < IoCheckmarkOutline />
82- </ span >
83- </ li >
84- )
85- } else {
86- return (
87- < li key = { `day-${ i } ` } className = "dayWrapper" >
88- < span className = "day" > </ span >
89- </ li >
90- )
91- }
92- } ) }
93- </ ul >
94- </ div >
95- </ div >
96- </ div >
97- )
98- }
99-
10024export const GeneralSettings = ( ) => {
10125 const {
10226 openLinksNewTab,
0 commit comments