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
6830dc22
Commit
6830dc22
authored
Sep 13, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temporary auth form
parent
148c81e3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
8 deletions
+59
-8
index.tsx
pages/[network_type]/[network_sub_type]/index.tsx
+59
-8
No files found.
pages/[network_type]/[network_sub_type]/index.tsx
View file @
6830dc22
import
{
Center
,
VStack
,
Box
}
from
'
@chakra-ui/react
'
;
import
{
VStack
,
Textarea
,
Button
,
Alert
,
AlertTitle
,
AlertDescription
,
Link
,
Code
}
from
'
@chakra-ui/react
'
;
import
capitalize
from
'
lodash/capitalize
'
;
import
type
{
NextPage
,
GetStaticPaths
}
from
'
next
'
;
import
type
{
NextPage
,
GetStaticPaths
}
from
'
next
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
type
{
ChangeEvent
}
from
'
react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
useToast
from
'
lib/hooks/useToast
'
;
import
getAvailablePaths
from
'
lib/networks/getAvailablePaths
'
;
import
getAvailablePaths
from
'
lib/networks/getAvailablePaths
'
;
import
Page
from
'
ui/shared/Page
'
;
import
Page
from
'
ui/shared/Page
'
;
import
PageHeader
from
'
ui/shared/PageHeader
'
;
const
Home
:
NextPage
=
()
=>
{
const
Home
:
NextPage
=
()
=>
{
const
router
=
useRouter
();
const
router
=
useRouter
();
const
toast
=
useToast
();
const
[
isFormVisible
,
setFormVisibility
]
=
React
.
useState
(
false
);
const
[
token
,
setToken
]
=
React
.
useState
(
''
);
React
.
useEffect
(()
=>
{
const
token
=
cookies
.
get
(
cookies
.
NAMES
.
API_TOKEN
);
if
(
!
token
)
{
setFormVisibility
(
true
);
}
},
[]);
const
handleTokenChange
=
React
.
useCallback
((
event
:
ChangeEvent
<
HTMLTextAreaElement
>
)
=>
{
setToken
(
event
.
target
.
value
);
},
[]);
const
handleSetTokenClick
=
React
.
useCallback
(()
=>
{
cookies
.
set
(
cookies
.
NAMES
.
API_TOKEN
,
token
);
setToken
(
''
);
toast
({
position
:
'
top-right
'
,
title
:
'
Success 🥳
'
,
description
:
'
Successfully set cookie
'
,
status
:
'
success
'
,
variant
:
'
subtle
'
,
isClosable
:
true
,
onCloseComplete
:
()
=>
{
setFormVisibility
(
false
);
},
});
},
[
toast
,
token
]);
return
(
return
(
<
Page
>
<
Page
>
<
Center
h=
"100%"
fontSize=
{
{
base
:
'
sm
'
,
lg
:
'
xl
'
}
}
>
<
VStack
gap=
{
4
}
alignItems=
"flex-start"
maxW=
"800px"
>
<
VStack
gap=
{
4
}
>
<
PageHeader
text=
{
<
Box
>
`Home Page for ${ capitalize(router.query.network_type as string) } ${ capitalize(router.query.network_sub_type as string) } network`
<
p
>
home page for
{
router
.
query
.
network_type
}
{
router
.
query
.
network_sub_type
}
network
</
p
>
}
/>
</
Box
>
{
/* will be deleted when we move to new CI */
}
</
VStack
>
{
isFormVisible
&&
(
</
Center
>
<>
<
Alert
status=
"error"
flexDirection=
"column"
alignItems=
"flex-start"
>
<
AlertTitle
fontSize=
"md"
>
!!! Temporary solution for authentication !!!
</
AlertTitle
>
<
AlertDescription
mt=
{
3
}
>
To Sign in go to
<
Link
>
https://blockscout.com/poa/core
</
Link
>
first, sign in there, copy obtained API token from cookie
<
Code
ml=
{
1
}
>
{
cookies
.
NAMES
.
API_TOKEN
}
</
Code
>
and paste it in the form below. After submitting the form you should be successfully
authenticated in current environment
</
AlertDescription
>
</
Alert
>
<
Textarea
value=
{
token
}
onChange=
{
handleTokenChange
}
placeholder=
"API token"
/>
<
Button
onClick=
{
handleSetTokenClick
}
>
Set cookie
</
Button
>
</>
)
}
</
VStack
>
</
Page
>
</
Page
>
);
);
};
};
...
...
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