-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
38 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,44 @@ | ||
import React from 'react' | ||
import React, { useContext, useState } from 'react' | ||
import { Link } from 'react-router-dom' | ||
import { FlagContext } from './flags' | ||
|
||
export interface NotFoundViewProps { | ||
|
||
} | ||
|
||
export function NotFoundView({}: NotFoundViewProps) { | ||
return <div> | ||
<h1>Whoa there, buddy!</h1> | ||
const { proxyTest } = useContext(FlagContext).flags; | ||
|
||
return <div> | ||
<h2>Whoa there, buddy!</h2> | ||
<p>looks like you found yourself in a bit of a situation. Maybe hit the back button or <Link to='/'>go to the search page</Link>?</p> | ||
|
||
{proxyTest && <ProxyTest />} | ||
</div>; | ||
} | ||
|
||
function ProxyTest() { | ||
const [result, setResult] = useState<any>() | ||
const [port, setPort] = useState<number>(6969); | ||
|
||
const runTest = () => { | ||
setResult(undefined); | ||
(async () => { | ||
try { | ||
const nextResult = await fetch(`http://localhost:${port}/ping`); | ||
const text = await nextResult.text(); | ||
setResult(text) | ||
} catch (e) { | ||
console.error(e); | ||
setResult(e); | ||
} | ||
})() | ||
} | ||
|
||
return <div> | ||
<h3>port check!</h3> | ||
<input type='number' value={port} onChange={e => setPort(parseInt(e.target.value))} /> | ||
<button onClick={runTest}>test</button> | ||
{result && <pre><code>{result.toString()}</code></pre>} | ||
</div> | ||
} |