-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #545 from mysteriumnetwork/settings-port-forwarding
Add card with port forwarding to the settings page
- Loading branch information
Showing
4 changed files
with
50 additions
and
3 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
43 changes: 43 additions & 0 deletions
43
src/pages/Authenticated/SettingsPage/PortForwardingCard.tsx
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Copyright (c) 2024 BlockDev AG | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
import { useState } from 'react' | ||
import errors from '../../../commons/errors' | ||
import { useAppSelector } from '../../../commons/hooks' | ||
import complexActions from '../../../redux/complex.actions' | ||
import { selectors } from '../../../redux/selectors' | ||
import Card from '../../../components/Cards/Card' | ||
import Button from '../../../components/Buttons/Button' | ||
import { Form } from '../../../components/Inputs/Form' | ||
import { LabeledInput } from '../../../components/Inputs/LabeledInput' | ||
|
||
export default function PortForwardingCard() { | ||
const config = useAppSelector(selectors.currentConfig) | ||
const [loading, setLoading] = useState<boolean>(false) | ||
const [value, setValue] = useState<string>(config.data.udp.ports) | ||
async function handleConfigSave() { | ||
setLoading(true) | ||
try { | ||
await complexActions.setUserConfig({ udp: { ports: value } }) | ||
} catch (err) { | ||
errors.parseToastError(err) | ||
} finally { | ||
setLoading(false) | ||
} | ||
} | ||
return ( | ||
<Card fluid> | ||
<Form className="flex flex-col w-full max-w-[500px] min-w-[240px] gap-4" onSubmit={handleConfigSave}> | ||
<div className="flex w-full flex-col"> | ||
<LabeledInput fluid label="UDP Port range" value={value} onChange={setValue} errorMessagePadding={false} /> | ||
</div> | ||
<div className="w-full sm:w-52"> | ||
<Button fluid disabled={loading} type="submit" label="Save" /> | ||
</div> | ||
</Form> | ||
</Card> | ||
) | ||
} |
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