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
ad2b2658
Commit
ad2b2658
authored
Apr 05, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
form main info
parent
f24e2658
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
171 additions
and
2 deletions
+171
-2
TokenInfoForm.tsx
ui/tokenInfo/TokenInfoForm.tsx
+40
-2
TokenInfoFieldAddress.tsx
ui/tokenInfo/fields/TokenInfoFieldAddress.tsx
+37
-0
TokenInfoFieldRequesterEmail.tsx
ui/tokenInfo/fields/TokenInfoFieldRequesterEmail.tsx
+45
-0
TokenInfoFieldRequesterName.tsx
ui/tokenInfo/fields/TokenInfoFieldRequesterName.tsx
+44
-0
types.ts
ui/tokenInfo/types.ts
+5
-0
No files found.
ui/tokenInfo/TokenInfoForm.tsx
View file @
ad2b2658
import
{
Box
}
from
'
@chakra-ui/react
'
;
import
{
Grid
,
GridItem
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
SubmitHandler
}
from
'
react-hook-form
'
;
import
{
useForm
}
from
'
react-hook-form
'
;
import
type
{
Fields
}
from
'
./types
'
;
import
TokenInfoFieldAddress
from
'
./fields/TokenInfoFieldAddress
'
;
import
TokenInfoFieldRequesterEmail
from
'
./fields/TokenInfoFieldRequesterEmail
'
;
import
TokenInfoFieldRequesterName
from
'
./fields/TokenInfoFieldRequesterName
'
;
interface
Props
{
interface
Props
{
id
:
number
;
id
:
number
;
}
}
const
TokenInfoForm
=
({
id
}:
Props
)
=>
{
const
TokenInfoForm
=
({
id
}:
Props
)
=>
{
return
<
Box
>
TokenInfoForm for
{
id
}
</
Box
>;
const
formApi
=
useForm
<
Fields
>
({
mode
:
'
onBlur
'
,
defaultValues
:
{
address
:
'
0x9d2a7b2b09b1d4786e36699d9f56b8c04e92cbb9
'
,
},
});
const
{
handleSubmit
,
formState
,
control
}
=
formApi
;
const
onFormSubmit
:
SubmitHandler
<
Fields
>
=
React
.
useCallback
(
async
(
data
)
=>
{
// eslint-disable-next-line no-console
console
.
log
(
'
__>__
'
,
id
,
data
);
},
[
id
]);
const
onSubmit
=
handleSubmit
(
onFormSubmit
);
return
(
<
form
noValidate
onSubmit=
{
onSubmit
}
>
<
div
>
Requests are sent to a moderator for review and approval. This process can take several days.
</
div
>
<
Grid
mt=
{
8
}
gridTemplateColumns=
"1fr 1fr"
columnGap=
{
5
}
rowGap=
{
5
}
>
<
GridItem
colSpan=
{
2
}
>
<
TokenInfoFieldAddress
control=
{
control
}
/>
</
GridItem
>
<
GridItem
>
<
TokenInfoFieldRequesterName
control=
{
control
}
formState=
{
formState
}
/>
</
GridItem
>
<
GridItem
>
<
TokenInfoFieldRequesterEmail
control=
{
control
}
formState=
{
formState
}
/>
</
GridItem
>
</
Grid
>
</
form
>
);
};
};
export
default
TokenInfoForm
;
export
default
TokenInfoForm
;
ui/tokenInfo/fields/TokenInfoFieldAddress.tsx
0 → 100644
View file @
ad2b2658
import
{
FormControl
,
Input
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
{
Control
,
ControllerRenderProps
}
from
'
react-hook-form
'
;
import
{
Controller
}
from
'
react-hook-form
'
;
import
type
{
Fields
}
from
'
../types
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholder
'
;
interface
Props
{
control
:
Control
<
Fields
>
;
}
const
TokenInfoFieldAddress
=
({
control
}:
Props
)
=>
{
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
Fields
,
'
address
'
>
})
=>
{
return
(
<
FormControl
variant=
"floating"
id=
{
field
.
name
}
isRequired
size=
"lg"
>
<
Input
{
...
field
}
required
isDisabled
/>
<
InputPlaceholder
text=
"Token contract address"
/>
</
FormControl
>
);
},
[]);
return
(
<
Controller
name=
"address"
control=
{
control
}
render=
{
renderControl
}
/>
);
};
export
default
React
.
memo
(
TokenInfoFieldAddress
);
ui/tokenInfo/fields/TokenInfoFieldRequesterEmail.tsx
0 → 100644
View file @
ad2b2658
import
{
FormControl
,
Input
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
{
Control
,
ControllerRenderProps
,
FormState
}
from
'
react-hook-form
'
;
import
{
Controller
}
from
'
react-hook-form
'
;
import
type
{
Fields
}
from
'
../types
'
;
import
{
EMAIL_REGEXP
}
from
'
lib/validations/email
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholder
'
;
interface
Props
{
formState
:
FormState
<
Fields
>
;
control
:
Control
<
Fields
>
;
isReadOnly
?:
boolean
;
}
const
TokenInfoFieldRequesterEmail
=
({
formState
,
control
,
isReadOnly
}:
Props
)
=>
{
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
Fields
,
'
requester_email
'
>
})
=>
{
const
error
=
'
requester_email
'
in
formState
.
errors
?
formState
.
errors
.
requester_email
:
undefined
;
return
(
<
FormControl
variant=
"floating"
id=
{
field
.
name
}
isRequired
size=
"lg"
>
<
Input
{
...
field
}
required
isInvalid=
{
Boolean
(
error
)
}
isDisabled=
{
formState
.
isSubmitting
||
isReadOnly
}
autoComplete=
"off"
/>
<
InputPlaceholder
text=
"Requester email"
error=
{
error
}
/>
</
FormControl
>
);
},
[
formState
.
errors
,
formState
.
isSubmitting
,
isReadOnly
]);
return
(
<
Controller
name=
"requester_email"
control=
{
control
}
render=
{
renderControl
}
rules=
{
{
required
:
true
,
pattern
:
EMAIL_REGEXP
}
}
/>
);
};
export
default
React
.
memo
(
TokenInfoFieldRequesterEmail
);
ui/tokenInfo/fields/TokenInfoFieldRequesterName.tsx
0 → 100644
View file @
ad2b2658
import
{
FormControl
,
Input
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
{
Control
,
ControllerRenderProps
,
FormState
}
from
'
react-hook-form
'
;
import
{
Controller
}
from
'
react-hook-form
'
;
import
type
{
Fields
}
from
'
../types
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholder
'
;
interface
Props
{
formState
:
FormState
<
Fields
>
;
control
:
Control
<
Fields
>
;
isReadOnly
?:
boolean
;
}
const
TokenInfoFieldRequesterName
=
({
formState
,
control
,
isReadOnly
}:
Props
)
=>
{
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
Fields
,
'
requester_name
'
>
})
=>
{
const
error
=
'
requester_name
'
in
formState
.
errors
?
formState
.
errors
.
requester_name
:
undefined
;
return
(
<
FormControl
variant=
"floating"
id=
{
field
.
name
}
isRequired
size=
"lg"
>
<
Input
{
...
field
}
required
isInvalid=
{
Boolean
(
error
)
}
isDisabled=
{
formState
.
isSubmitting
||
isReadOnly
}
autoComplete=
"off"
/>
<
InputPlaceholder
text=
"Requester name"
error=
{
error
}
/>
</
FormControl
>
);
},
[
formState
.
errors
,
formState
.
isSubmitting
,
isReadOnly
]);
return
(
<
Controller
name=
"requester_name"
control=
{
control
}
render=
{
renderControl
}
rules=
{
{
required
:
true
}
}
/>
);
};
export
default
React
.
memo
(
TokenInfoFieldRequesterName
);
ui/tokenInfo/types.ts
0 → 100644
View file @
ad2b2658
export
interface
Fields
{
address
:
string
;
requester_name
:
string
;
requester_email
:
string
;
}
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