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
f8d8e686
Commit
f8d8e686
authored
May 09, 2024
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
result screen: company and requester info
parent
ff311e56
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
140 additions
and
11 deletions
+140
-11
PublicTagsSubmit.tsx
ui/pages/PublicTagsSubmit.tsx
+15
-4
PublicTagsSubmitForm.tsx
ui/publicTags/submit/PublicTagsSubmitForm.tsx
+8
-4
PublicTagsSubmitResult.tsx
ui/publicTags/submit/PublicTagsSubmitResult.tsx
+51
-3
mocks.ts
ui/publicTags/submit/mocks.ts
+31
-0
PublicTagsSubmitResultSuccess.tsx
...ublicTags/submit/result/PublicTagsSubmitResultSuccess.tsx
+14
-0
PublicTagsSubmitResultWithErrors.tsx
...icTags/submit/result/PublicTagsSubmitResultWithErrors.tsx
+14
-0
types.ts
ui/publicTags/submit/types.ts
+7
-0
No files found.
ui/pages/PublicTagsSubmit.tsx
View file @
f8d8e686
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
FormSubmitResult
}
from
'
ui/publicTags/submit/types
'
;
import
useApiQuery
from
'
lib/api/useApiQuery
'
;
import
useApiQuery
from
'
lib/api/useApiQuery
'
;
import
*
as
mocks
from
'
ui/publicTags/submit/mocks
'
;
import
PublicTagsSubmitForm
from
'
ui/publicTags/submit/PublicTagsSubmitForm
'
;
import
PublicTagsSubmitForm
from
'
ui/publicTags/submit/PublicTagsSubmitForm
'
;
import
PublicTagsSubmitResult
from
'
ui/publicTags/submit/PublicTagsSubmitResult
'
;
import
PublicTagsSubmitResult
from
'
ui/publicTags/submit/PublicTagsSubmitResult
'
;
import
ContentLoader
from
'
ui/shared/ContentLoader
'
;
import
ContentLoader
from
'
ui/shared/ContentLoader
'
;
...
@@ -11,16 +14,24 @@ type Screen = 'form' | 'result' | 'initializing' | 'error';
...
@@ -11,16 +14,24 @@ type Screen = 'form' | 'result' | 'initializing' | 'error';
const
PublicTagsSubmit
=
()
=>
{
const
PublicTagsSubmit
=
()
=>
{
const
[
screen
,
setScreen
]
=
React
.
useState
<
Screen
>
(
'
initializing
'
);
const
[
screen
,
setScreen
]
=
React
.
useState
<
Screen
>
(
'
result
'
);
const
[
submitResult
,
setSubmitResult
]
=
React
.
useState
<
FormSubmitResult
>
([
mocks
.
item1
,
]);
const
configQuery
=
useApiQuery
(
'
address_metadata_tag_types
'
);
const
configQuery
=
useApiQuery
(
'
address_metadata_tag_types
'
);
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
if
(
!
configQuery
.
isPending
)
{
if
(
!
configQuery
.
isPending
)
{
setScreen
(
configQuery
.
isError
?
'
error
'
:
'
form
'
);
setScreen
(
configQuery
.
isError
?
'
error
'
:
'
result
'
);
}
}
},
[
configQuery
.
isError
,
configQuery
.
isPending
]);
},
[
configQuery
.
isError
,
configQuery
.
isPending
]);
const
handleFormSubmitResult
=
React
.
useCallback
((
result
:
FormSubmitResult
)
=>
{
setSubmitResult
(
result
);
setScreen
(
'
result
'
);
},
[]);
const
content
=
(()
=>
{
const
content
=
(()
=>
{
switch
(
screen
)
{
switch
(
screen
)
{
case
'
initializing
'
:
case
'
initializing
'
:
...
@@ -28,9 +39,9 @@ const PublicTagsSubmit = () => {
...
@@ -28,9 +39,9 @@ const PublicTagsSubmit = () => {
case
'
error
'
:
case
'
error
'
:
return
<
DataFetchAlert
/>;
return
<
DataFetchAlert
/>;
case
'
form
'
:
case
'
form
'
:
return
<
PublicTagsSubmitForm
config=
{
configQuery
.
data
}
/>;
return
<
PublicTagsSubmitForm
config=
{
configQuery
.
data
}
onSubmitResult=
{
handleFormSubmitResult
}
/>;
case
'
result
'
:
case
'
result
'
:
return
<
PublicTagsSubmitResult
/>;
return
<
PublicTagsSubmitResult
data=
{
submitResult
}
/>;
default
:
default
:
return
null
;
return
null
;
}
}
...
...
ui/publicTags/submit/PublicTagsSubmitForm.tsx
View file @
f8d8e686
...
@@ -3,7 +3,7 @@ import React from 'react';
...
@@ -3,7 +3,7 @@ import React from 'react';
import
type
{
SubmitHandler
}
from
'
react-hook-form
'
;
import
type
{
SubmitHandler
}
from
'
react-hook-form
'
;
import
{
useForm
,
FormProvider
}
from
'
react-hook-form
'
;
import
{
useForm
,
FormProvider
}
from
'
react-hook-form
'
;
import
type
{
FormFields
}
from
'
./types
'
;
import
type
{
FormFields
,
FormSubmitResult
}
from
'
./types
'
;
import
type
{
PublicTagTypesResponse
}
from
'
types/api/addressMetadata
'
;
import
type
{
PublicTagTypesResponse
}
from
'
types/api/addressMetadata
'
;
import
delay
from
'
lib/delay
'
;
import
delay
from
'
lib/delay
'
;
...
@@ -21,9 +21,10 @@ import PublicTagsSubmitFieldTags from './fields/PublicTagsSubmitFieldTags';
...
@@ -21,9 +21,10 @@ import PublicTagsSubmitFieldTags from './fields/PublicTagsSubmitFieldTags';
interface
Props
{
interface
Props
{
config
:
PublicTagTypesResponse
|
undefined
;
config
:
PublicTagTypesResponse
|
undefined
;
onSubmitResult
:
(
result
:
FormSubmitResult
)
=>
void
;
}
}
const
PublicTagsSubmitForm
=
({
config
}:
Props
)
=>
{
const
PublicTagsSubmitForm
=
({
config
,
onSubmitResult
}:
Props
)
=>
{
const
isMobile
=
useIsMobile
();
const
isMobile
=
useIsMobile
();
const
formApi
=
useForm
<
FormFields
>
({
const
formApi
=
useForm
<
FormFields
>
({
...
@@ -38,8 +39,11 @@ const PublicTagsSubmitForm = ({ config }: Props) => {
...
@@ -38,8 +39,11 @@ const PublicTagsSubmitForm = ({ config }: Props) => {
// eslint-disable-next-line no-console
// eslint-disable-next-line no-console
console
.
log
(
'
__>__
'
,
data
,
config
);
console
.
log
(
'
__>__
'
,
data
,
config
);
await
delay
(
5000
);
await
delay
(
1000
);
},
[
config
]);
onSubmitResult
([
{
error
:
null
,
payload
:
data
},
]);
},
[
config
,
onSubmitResult
]);
return
(
return
(
<
FormProvider
{
...
formApi
}
>
<
FormProvider
{
...
formApi
}
>
...
...
ui/publicTags/submit/PublicTagsSubmitResult.tsx
View file @
f8d8e686
import
{
Box
}
from
'
@chakra-ui/react
'
;
import
{
Alert
,
Box
,
Grid
,
GridItem
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
const
PublicTagsSubmitResult
=
()
=>
{
import
type
{
FormSubmitResult
}
from
'
./types
'
;
return
<
Box
>
PublicTagsSubmitResult
</
Box
>;
import
makePrettyLink
from
'
lib/makePrettyLink
'
;
import
LinkExternal
from
'
ui/shared/LinkExternal
'
;
import
PublicTagsSubmitResultSuccess
from
'
./result/PublicTagsSubmitResultSuccess
'
;
import
PublicTagsSubmitResultWithErrors
from
'
./result/PublicTagsSubmitResultWithErrors
'
;
interface
Props
{
data
:
FormSubmitResult
;
}
const
PublicTagsSubmitResult
=
({
data
}:
Props
)
=>
{
const
hasErrors
=
data
.
some
((
item
)
=>
item
.
error
!==
null
);
const
companyWebsite
=
makePrettyLink
(
data
[
0
].
payload
.
companyWebsite
);
return
(
<
div
>
{
!
hasErrors
&&
(
<
Alert
status=
"success"
mb=
{
6
}
>
Success! All tags went into moderation pipeline and soon will appear in the explorer.
</
Alert
>
)
}
<
Box
as=
"h2"
textStyle=
"h4"
>
Company info
</
Box
>
<
Grid
rowGap=
{
3
}
columnGap=
{
6
}
gridTemplateColumns=
"185px 1fr"
mt=
{
6
}
>
<
GridItem
>
Your name
</
GridItem
>
<
GridItem
>
{
data
[
0
].
payload
.
requesterName
}
</
GridItem
>
<
GridItem
>
Email
</
GridItem
>
<
GridItem
>
{
data
[
0
].
payload
.
requesterEmail
}
</
GridItem
>
{
data
[
0
].
payload
.
companyName
&&
(
<>
<
GridItem
>
Company name
</
GridItem
>
<
GridItem
>
{
data
[
0
].
payload
.
companyName
}
</
GridItem
>
</>
)
}
{
companyWebsite
&&
(
<>
<
GridItem
>
Company website
</
GridItem
>
<
GridItem
>
<
LinkExternal
href=
{
companyWebsite
.
url
}
>
{
companyWebsite
.
domain
}
</
LinkExternal
>
</
GridItem
>
</>
)
}
</
Grid
>
<
Box
as=
"h2"
textStyle=
"h4"
mt=
{
8
}
mb=
{
5
}
>
Public tags/labels
</
Box
>
{
hasErrors
?
<
PublicTagsSubmitResultWithErrors
data=
{
data
}
/>
:
<
PublicTagsSubmitResultSuccess
data=
{
data
}
/>
}
</
div
>
);
};
};
export
default
PublicTagsSubmitResult
;
export
default
PublicTagsSubmitResult
;
ui/publicTags/submit/mocks.ts
0 → 100644
View file @
f8d8e686
import
type
{
FormSubmitResultItem
}
from
'
./types
'
;
export
const
item1
:
FormSubmitResultItem
=
{
error
:
null
,
payload
:
{
addresses
:
[
{
hash
:
'
0xa8FCe579a11E551635b9c9CB915BEcd873C51254
'
,
},
],
tags
:
[
{
name
:
'
hello
'
,
type
:
{
label
:
'
name
'
,
value
:
'
name
'
,
},
url
:
'
https://ohhhh.me
'
,
tooltipDescription
:
'
hello again
'
,
bgColor
:
'
add
'
,
textColor
:
'
00aa11
'
,
},
],
requesterName
:
'
tomm
'
,
requesterEmail
:
'
tom@ohhhh.me
'
,
companyName
:
'
OHHHH
'
,
companyWebsite
:
'
https://ohhhh.me
'
,
description
:
'
chao
'
,
reCaptcha
:
'
xxxx
'
,
},
};
ui/publicTags/submit/result/PublicTagsSubmitResultSuccess.tsx
0 → 100644
View file @
f8d8e686
import
{
Box
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
{
FormSubmitResult
}
from
'
../types
'
;
interface
Props
{
data
:
FormSubmitResult
;
}
const
PublicTagsSubmitResultSuccess
=
(
props
:
Props
)
=>
{
return
<
Box
>
{
props
.
data
.
length
}
</
Box
>;
};
export
default
PublicTagsSubmitResultSuccess
;
ui/publicTags/submit/result/PublicTagsSubmitResultWithErrors.tsx
0 → 100644
View file @
f8d8e686
import
{
Box
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
{
FormSubmitResult
}
from
'
../types
'
;
interface
Props
{
data
:
FormSubmitResult
;
}
const
PublicTagsSubmitResultWithErrors
=
(
props
:
Props
)
=>
{
return
<
Box
>
{
props
.
data
.
length
}
</
Box
>;
};
export
default
PublicTagsSubmitResultWithErrors
;
ui/publicTags/submit/types.ts
View file @
f8d8e686
...
@@ -22,3 +22,10 @@ export interface FormFieldTag {
...
@@ -22,3 +22,10 @@ export interface FormFieldTag {
textColor
:
string
|
undefined
;
textColor
:
string
|
undefined
;
tooltipDescription
:
string
|
undefined
;
tooltipDescription
:
string
|
undefined
;
}
}
export
interface
FormSubmitResultItem
{
error
:
unknown
|
null
;
payload
:
FormFields
;
}
export
type
FormSubmitResult
=
Array
<
FormSubmitResultItem
>
;
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