Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
6e269424
Commit
6e269424
authored
Sep 19, 2024
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
my profile page re-design
parent
4eb5a26f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
32 deletions
+110
-32
MyProfileEmail.tsx
ui/myProfile/MyProfileEmail.tsx
+79
-0
MyProfileWallet.tsx
ui/myProfile/MyProfileWallet.tsx
+20
-0
Login.tsx
ui/pages/Login.tsx
+1
-0
MyProfile.tsx
ui/pages/MyProfile.tsx
+10
-32
No files found.
ui/myProfile/MyProfileEmail.tsx
0 → 100644
View file @
6e269424
import
{
Button
,
chakra
,
FormControl
,
Heading
,
Input
,
InputGroup
,
InputRightElement
,
Text
}
from
'
@chakra-ui/react
'
;
import
type
{
UseQueryResult
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
type
{
SubmitHandler
}
from
'
react-hook-form
'
;
import
{
FormProvider
,
useForm
}
from
'
react-hook-form
'
;
import
type
{
UserInfo
}
from
'
types/api/account
'
;
import
{
EMAIL_REGEXP
}
from
'
lib/validations/email
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholder
'
;
interface
FormFields
{
email
:
string
;
}
interface
Props
{
profileQuery
:
UseQueryResult
<
UserInfo
,
unknown
>
;
}
const
MyProfileEmail
=
({
profileQuery
}:
Props
)
=>
{
const
formApi
=
useForm
<
FormFields
>
({
mode
:
'
onBlur
'
,
defaultValues
:
{
email
:
profileQuery
.
data
?.
email
||
''
,
},
});
const
onFormSubmit
:
SubmitHandler
<
FormFields
>
=
React
.
useCallback
((
formData
)
=>
{
// eslint-disable-next-line no-console
console
.
log
(
formData
);
},
[
]);
const
isDisabled
=
formApi
.
formState
.
isSubmitting
;
return
(
<
section
>
<
Heading
as=
"h2"
size=
"sm"
mb=
{
3
}
>
Notifications
</
Heading
>
<
FormProvider
{
...
formApi
}
>
<
chakra
.
form
noValidate
onSubmit=
{
formApi
.
handleSubmit
(
onFormSubmit
)
}
>
<
FormControl
variant=
"floating"
isDisabled=
{
isDisabled
}
isRequired
size=
"md"
>
<
InputGroup
>
<
Input
{
...
formApi
.
register
('
email
',
{
required
:
true
,
pattern
:
EMAIL_REGEXP
})
}
required
isInvalid=
{
Boolean
(
formApi
.
formState
.
errors
.
email
)
}
isDisabled=
{
isDisabled
}
autoComplete=
"off"
/>
<
InputPlaceholder
text=
"Email"
error=
{
formApi
.
formState
.
errors
.
email
}
/>
{
!
formApi
.
formState
.
isDirty
&&
(
<
InputRightElement
h=
"100%"
>
<
IconSvg
name=
"certified"
boxSize=
{
5
}
color=
"green.500"
/>
</
InputRightElement
>
)
}
</
InputGroup
>
<
Text
variant=
"secondary"
mt=
{
1
}
fontSize=
"sm"
>
Email for watch list notifications and private tags
</
Text
>
</
FormControl
>
<
Button
mt=
{
6
}
size=
"sm"
variant=
"outline"
type=
"submit"
isDisabled=
{
formApi
.
formState
.
isSubmitting
||
!
formApi
.
formState
.
isDirty
}
isLoading=
{
formApi
.
formState
.
isSubmitting
}
loadingText=
"Save changes"
>
Save changes
</
Button
>
</
chakra
.
form
>
</
FormProvider
>
</
section
>
);
};
export
default
React
.
memo
(
MyProfileEmail
);
ui/myProfile/MyProfileWallet.tsx
0 → 100644
View file @
6e269424
import
{
Button
,
Heading
}
from
'
@chakra-ui/react
'
;
import
type
{
UseQueryResult
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
type
{
UserInfo
}
from
'
types/api/account
'
;
interface
Props
{
profileQuery
:
UseQueryResult
<
UserInfo
,
unknown
>
;
}
const
MyProfileWallet
=
({
profileQuery
}:
Props
)
=>
{
return
(
<
section
>
<
Heading
as=
"h2"
size=
"sm"
mb=
{
3
}
>
My linked wallet
</
Heading
>
{
!
profileQuery
.
data
?.
address_hash
&&
<
Button
size=
"sm"
>
Link wallet
</
Button
>
}
</
section
>
);
};
export
default
React
.
memo
(
MyProfileWallet
);
ui/pages/Login.tsx
View file @
6e269424
...
...
@@ -11,6 +11,7 @@ import useGradualIncrement from 'lib/hooks/useGradualIncrement';
import
useToast
from
'
lib/hooks/useToast
'
;
import
PageTitle
from
'
ui/shared/Page/PageTitle
'
;
// TODO @tom2drum delete this page
{
/* will be deleted when we fix login in preview CI stands */
}
const
Login
=
()
=>
{
const
toast
=
useToast
();
...
...
ui/pages/MyProfile.tsx
View file @
6e269424
import
{
VStack
,
FormControl
,
FormLabel
,
Input
}
from
'
@chakra-ui/react
'
;
import
{
Flex
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
useFetchProfileInfo
from
'
lib/hooks/useFetchProfileInfo
'
;
import
useRedirectForInvalidAuthToken
from
'
lib/hooks/useRedirectForInvalidAuthToken
'
;
import
MyProfileEmail
from
'
ui/myProfile/MyProfileEmail
'
;
import
MyProfileWallet
from
'
ui/myProfile/MyProfileWallet
'
;
import
ContentLoader
from
'
ui/shared/ContentLoader
'
;
import
DataFetchAlert
from
'
ui/shared/DataFetchAlert
'
;
import
PageTitle
from
'
ui/shared/Page/PageTitle
'
;
import
UserAvatar
from
'
ui/shared/UserAvatar
'
;
const
MyProfile
=
()
=>
{
const
{
data
,
isPending
,
isError
}
=
useFetchProfileInfo
();
const
profileQuery
=
useFetchProfileInfo
();
useRedirectForInvalidAuthToken
();
const
content
=
(()
=>
{
if
(
isPending
)
{
if
(
profileQuery
.
isPending
)
{
return
<
ContentLoader
/>;
}
if
(
isError
)
{
if
(
profileQuery
.
isError
)
{
return
<
DataFetchAlert
/>;
}
return
(
<
VStack
maxW=
"412px"
mt=
{
8
}
gap=
{
5
}
alignItems=
"stretch"
>
<
UserAvatar
size=
{
64
}
/>
<
FormControl
variant=
"floating"
id=
"name"
isRequired
size=
"lg"
>
<
Input
required
readOnly
value=
{
data
.
name
||
''
}
/>
<
FormLabel
>
Name
</
FormLabel
>
</
FormControl
>
<
FormControl
variant=
"floating"
id=
"nickname"
isRequired
size=
"lg"
>
<
Input
required
readOnly
value=
{
data
.
nickname
||
''
}
/>
<
FormLabel
>
Nickname
</
FormLabel
>
</
FormControl
>
<
FormControl
variant=
"floating"
id=
"email"
isRequired
size=
"lg"
>
<
Input
required
readOnly
value=
{
data
.
email
||
''
}
/>
<
FormLabel
>
Email
</
FormLabel
>
</
FormControl
>
</
VStack
>
<
Flex
maxW=
"480px"
mt=
{
8
}
flexDir=
"column"
rowGap=
{
12
}
>
<
MyProfileEmail
profileQuery=
{
profileQuery
}
/>
<
MyProfileWallet
profileQuery=
{
profileQuery
}
/>
</
Flex
>
);
})();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment