Skip to content

Commit

Permalink
Merge pull request #416 from skalenetwork/minor-changes
Browse files Browse the repository at this point in the history
Hide email section, remove Swell messages, update submodules
  • Loading branch information
dmytrotkk authored Nov 6, 2024
2 parents d68e7f0 + 32e3a85 commit 1e91cbb
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 105 deletions.
90 changes: 13 additions & 77 deletions src/components/profile/ProfileModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,68 +21,34 @@
* @copyright SKALE Labs 2024-Present
*/

import React, { useState, useCallback } from 'react'
import React from 'react'
import { Modal, Box, useTheme, useMediaQuery } from '@mui/material'
import { cls, cmn, SkPaper, useWagmiAccount } from '@skalenetwork/metaport'
import { useAuth } from '../../AuthContext'
import Tile from '../Tile'
import Message from '../Message'
import ConnectWallet from '../ConnectWallet'
import ProfileModalHeader from './ProfileModalHeader'
import EmailSection from './EmailSection'
import SwellMessage from './SwellMessage'
import ProfileModalActions from './ProfileModalActions'
import Jazzicon, { jsNumberForAddress } from 'react-jazzicon'
import EmailRoundedIcon from '@mui/icons-material/EmailRounded'

const ProfileModal: React.FC = () => {
const { address } = useWagmiAccount()
const {
isSignedIn,
email,
isEmailLoading,
isEmailUpdating,
emailError,
updateEmail,
handleSignIn,
handleSignOut,
isProfileModalOpen,
closeProfileModal
} = useAuth()

const [isEditing, setIsEditing] = useState(false)
const [newEmail, setNewEmail] = useState(email || '')
const { isSignedIn, handleSignIn, handleSignOut, isProfileModalOpen, closeProfileModal } =
useAuth()

const theme = useTheme()
const isMobile = useMediaQuery(theme.breakpoints.down('sm'))

const handleStartEditing = useCallback(() => {
setIsEditing(true)
setNewEmail(email || '')
}, [email])

const handleCancelEditing = useCallback(() => {
setIsEditing(false)
setNewEmail(email || '')
}, [email])

const handleUpdateEmail = useCallback(async () => {
if (newEmail.trim()) {
await updateEmail(newEmail.trim())
setIsEditing(false)
}
}, [newEmail, updateEmail])

const modalContent = (
<Box className="profileModal">
<SkPaper gray>
<ProfileModalHeader address={address} isSignedIn={isSignedIn} />
{!address || !isSignedIn ? (
<ConnectWallet customText="Connect your wallet and sign-in to use your profile" />
{!address ? (
<ConnectWallet customText="Connect your wallet to use your profile" />
) : (
<div></div>
)}
{address && isSignedIn ? (
{address ? (
<div>
<Tile
text="Wallet Address"
Expand All @@ -91,48 +57,18 @@ const ProfileModal: React.FC = () => {
copy={address}
className={cls(cmn.mbott10)}
/>
<EmailSection
email={email}
isEditing={isEditing}
isEmailLoading={isEmailLoading}
isEmailUpdating={isEmailUpdating}
newEmail={newEmail}
setNewEmail={setNewEmail}
handleStartEditing={handleStartEditing}
handleUpdateEmail={handleUpdateEmail}
handleCancelEditing={handleCancelEditing}
className={cls(cmn.mbott10)}
/>
{emailError && (
<Message
text={emailError}
type="error"
icon={<EmailRoundedIcon />}
closable={false}
className={cls(cmn.mbott10)}
/>
)}
<SwellMessage
email={email}
isEditing={isEditing}
handleStartEditing={handleStartEditing}
<ProfileModalActions
className={cls(cmn.mtop20)}
address={address}
isSignedIn={isSignedIn}
isMobile={isMobile}
handleSignIn={handleSignIn}
handleSignOut={handleSignOut}
/>
</div>
) : (
<div></div>
)}
{address ? (
<ProfileModalActions
className={cls(cmn.mtop20)}
address={address}
isSignedIn={isSignedIn}
isMobile={isMobile}
handleSignIn={handleSignIn}
handleSignOut={handleSignOut}
/>
) : (
<div></div>
)}
</SkPaper>
</Box>
)
Expand Down
21 changes: 9 additions & 12 deletions src/components/profile/ProfileModalActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,15 @@ const ProfileModalActions: React.FC<ProfileModalActionsProps> = ({
</Button>
)}
</RainbowConnectButton.Custom>

{isSignedIn && (
<Button
variant="text"
startIcon={isSignedIn ? <LogoutIcon /> : <LoginIcon />}
className={cls('btn', 'btnSm', 'filled')}
onClick={isSignedIn ? handleSignOut : handleSignIn}
fullWidth={isMobile}
>
Sign Out
</Button>
)}
<Button
variant="text"
startIcon={isSignedIn ? <LogoutIcon /> : <LoginIcon />}
className={cls('btn', 'btnSm', 'filled')}
onClick={isSignedIn ? handleSignOut : handleSignIn}
fullWidth={isMobile}
>
{isSignedIn ? 'Sign out' : 'Sign in'}
</Button>
</SkStack>
)

Expand Down
2 changes: 1 addition & 1 deletion src/components/profile/ProfileModalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface ProfileModalHeaderProps {
}

const ProfileModalHeader: React.FC<ProfileModalHeaderProps> = ({ address, isSignedIn }) => (
<div className={cls('profileModalHeader', cmn.flexcv, cmn.mbott10)}>
<div className={cls('profileModalHeader', cmn.flexcv)}>
<div className={cls(cmn.flexg)}>
<Headline text="Profile" icon={<AccountCircleRoundedIcon />} size="small" />
</div>
Expand Down
14 changes: 6 additions & 8 deletions src/pages/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,11 @@ export default function App(props: {
<Grid item lg={4} md={6} xs={12}>
<Tile
grow
text="Daily transactions"
text="30d transactions"
value={
counters ? formatNumber(Number(counters.transactions_today)) : undefined
counters ? formatNumber(Number(counters.transactions_last_30_days)) : undefined
}
icon={<HourglassTopRoundedIcon />}
icon={<HourglassFullRoundedIcon />}
/>
</Grid>
)}
Expand All @@ -324,11 +324,9 @@ export default function App(props: {
<Grid item lg={4} md={6} xs={12}>
<Tile
grow
text="30d transactions"
value={
counters ? formatNumber(Number(counters.transactions_last_30_days)) : undefined
}
icon={<HourglassFullRoundedIcon />}
text="Daily transactions"
value={counters ? formatNumber(Number(counters.transactions_today)) : undefined}
icon={<HourglassTopRoundedIcon />}
/>
</Grid>
)}
Expand Down
4 changes: 0 additions & 4 deletions src/pages/Ecosystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import FavoriteApps from '../components/ecosystem/tabs/FavoriteApps'
import TrendingApps from '../components/ecosystem/tabs/TrendingApps'
import SocialButtons from '../components/ecosystem/Socials'
import SkPageInfoIcon from '../components/SkPageInfoIcon'
import { SwellMessage } from '../components/Message'

export default function Ecosystem(props: {
mpc: MetaportCore
Expand Down Expand Up @@ -177,9 +176,6 @@ export default function Ecosystem(props: {
setCheckedItems={handleSetCheckedItems}
filteredAppsCount={currentFilteredApps.length}
/>
<SwellMessage
className={cls([cmn.mtop20, isFiltersApplied], [cmn.mbott20, !isFiltersApplied])}
/>
<Tabs
variant={props.isXs ? 'scrollable' : 'standard'}
value={activeTab}
Expand Down
2 changes: 0 additions & 2 deletions src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import TrendingApps from '../components/ecosystem/tabs/TrendingApps'
import { SKALE_SOCIAL_LINKS } from '../core/constants'
import { SECTION_ICONS, EXPLORE_CARDS } from '../components/HomeComponents'
import SocialButtons from '../components/ecosystem/Socials'
import { SwellMessage } from '../components/Message'
import UserRecommendations from '../components/ecosystem/UserRecommendations'

interface HomeProps {
Expand All @@ -65,7 +64,6 @@ export default function Home({
<Container maxWidth="md" className="paddBott60">
<Stack spacing={0}>
<h2 className={cls(cmn.nom)}>Welcome to SKALE</h2>
<SwellMessage className={cmn.mtop20} />
<Headline
text="Explore Portal"
icon={SECTION_ICONS.explore}
Expand Down

0 comments on commit 1e91cbb

Please sign in to comment.