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
42ea53d1
Commit
42ea53d1
authored
Nov 03, 2022
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ssr referrer
parent
4a8f8a3d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
7 deletions
+12
-7
appContext.tsx
lib/appContext.tsx
+2
-4
getServerSideProps.ts
lib/next/getServerSideProps.ts
+2
-0
Transaction.tsx
ui/pages/Transaction.tsx
+8
-3
No files found.
lib/appContext.tsx
View file @
42ea53d1
...
@@ -7,13 +7,11 @@ type Props = {
...
@@ -7,13 +7,11 @@ type Props = {
pageProps
:
PageProps
;
pageProps
:
PageProps
;
}
}
const
AppContext
=
createContext
<
PageProps
>
({
cookies
:
''
});
const
AppContext
=
createContext
<
PageProps
>
({
cookies
:
''
,
referrer
:
''
});
export
function
AppWrapper
({
children
,
pageProps
}:
Props
)
{
export
function
AppWrapper
({
children
,
pageProps
}:
Props
)
{
const
appProps
=
{
cookies
:
pageProps
.
cookies
};
return
(
return
(
<
AppContext
.
Provider
value=
{
app
Props
}
>
<
AppContext
.
Provider
value=
{
page
Props
}
>
{
children
}
{
children
}
</
AppContext
.
Provider
>
</
AppContext
.
Provider
>
);
);
...
...
lib/next/getServerSideProps.ts
View file @
42ea53d1
...
@@ -2,12 +2,14 @@ import type { GetServerSideProps, GetServerSidePropsResult } from 'next';
...
@@ -2,12 +2,14 @@ import type { GetServerSideProps, GetServerSidePropsResult } from 'next';
export
type
Props
=
{
export
type
Props
=
{
cookies
:
string
;
cookies
:
string
;
referrer
:
string
;
}
}
export
const
getServerSideProps
:
GetServerSideProps
=
async
({
req
}):
Promise
<
GetServerSidePropsResult
<
Props
>>
=>
{
export
const
getServerSideProps
:
GetServerSideProps
=
async
({
req
}):
Promise
<
GetServerSidePropsResult
<
Props
>>
=>
{
return
{
return
{
props
:
{
props
:
{
cookies
:
req
.
headers
.
cookie
||
''
,
cookies
:
req
.
headers
.
cookie
||
''
,
referrer
:
req
.
headers
.
referer
||
''
,
},
},
};
};
};
};
ui/pages/Transaction.tsx
View file @
42ea53d1
...
@@ -7,6 +7,7 @@ import type { Transaction } from 'types/api/transaction';
...
@@ -7,6 +7,7 @@ import type { Transaction } from 'types/api/transaction';
import
type
{
RoutedTab
}
from
'
ui/shared/RoutedTabs/types
'
;
import
type
{
RoutedTab
}
from
'
ui/shared/RoutedTabs/types
'
;
import
eastArrowIcon
from
'
icons/arrows/east.svg
'
;
import
eastArrowIcon
from
'
icons/arrows/east.svg
'
;
import
{
useAppContext
}
from
'
lib/appContext
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
isBrowser
from
'
lib/isBrowser
'
;
import
isBrowser
from
'
lib/isBrowser
'
;
import
networkExplorers
from
'
lib/networks/networkExplorers
'
;
import
networkExplorers
from
'
lib/networks/networkExplorers
'
;
...
@@ -32,6 +33,12 @@ const TABS: Array<RoutedTab> = [
...
@@ -32,6 +33,12 @@ const TABS: Array<RoutedTab> = [
const
TransactionPageContent
=
()
=>
{
const
TransactionPageContent
=
()
=>
{
const
router
=
useRouter
();
const
router
=
useRouter
();
const
fetch
=
useFetch
();
const
fetch
=
useFetch
();
const
appProps
=
useAppContext
();
const
isInBrowser
=
isBrowser
();
const
referrer
=
isInBrowser
?
window
.
document
.
referrer
:
appProps
.
referrer
;
const
hasGoBackLink
=
referrer
&&
referrer
.
includes
(
'
/txs
'
);
const
{
data
}
=
useQuery
<
unknown
,
unknown
,
Transaction
>
(
const
{
data
}
=
useQuery
<
unknown
,
unknown
,
Transaction
>
(
[
'
tx
'
,
router
.
query
.
id
],
[
'
tx
'
,
router
.
query
.
id
],
...
@@ -48,12 +55,10 @@ const TransactionPageContent = () => {
...
@@ -48,12 +55,10 @@ const TransactionPageContent = () => {
return
<
ExternalLink
key=
{
explorer
.
baseUrl
}
title=
{
`Open in ${ explorer.title }`
}
href=
{
url
.
toString
()
}
/>;
return
<
ExternalLink
key=
{
explorer
.
baseUrl
}
title=
{
`Open in ${ explorer.title }`
}
href=
{
url
.
toString
()
}
/>;
});
});
const
hasGoBackLink
=
isBrowser
()
&&
window
.
document
.
referrer
.
includes
(
'
/txs
'
);
return
(
return
(
<
Page
>
<
Page
>
{
hasGoBackLink
&&
(
{
hasGoBackLink
&&
(
<
Link
mb=
{
6
}
display=
"inline-flex"
href=
{
window
.
document
.
referrer
}
>
<
Link
mb=
{
6
}
display=
"inline-flex"
href=
{
referrer
}
>
<
Icon
as=
{
eastArrowIcon
}
boxSize=
{
6
}
mr=
{
2
}
transform=
"rotate(180deg)"
/>
<
Icon
as=
{
eastArrowIcon
}
boxSize=
{
6
}
mr=
{
2
}
transform=
"rotate(180deg)"
/>
Transactions
Transactions
</
Link
>
</
Link
>
...
...
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