Merge pull request #1995 from SkynetLabs/link-to-skynetfree

Invite siasky.net users to manage their account via skynetfree.net
This commit is contained in:
Matthew Sevey 2022-04-11 15:08:22 -04:00 committed by GitHub
commit 5dcb57d982
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

View File

@ -3,7 +3,14 @@ import { useFormik, getIn, setIn } from "formik";
import classnames from "classnames";
import SelfServiceMessages from "./SelfServiceMessages";
export default function SelfServiceForm({ fieldsConfig, onSubmit, title, validationSchema = null, button = "Submit" }) {
export default function SelfServiceForm({
fieldsConfig,
onSubmit,
title,
onError,
validationSchema = null,
button = "Submit",
}) {
const [messages, setMessages] = React.useState([]);
const fields = fieldsConfig.sort((a, b) => (a.position < b.position ? -1 : 1));
const formik = useFormik({
@ -21,6 +28,9 @@ export default function SelfServiceForm({ fieldsConfig, onSubmit, title, validat
const data = await error.response.json();
if (data.message) {
if (typeof onError === "function") {
onError(data.message);
}
setMessages((messages) => [...messages, { type: "error", text: data.message }]);
}
} else {

View File

@ -23,6 +23,8 @@ export default function Recovery() {
useAnonRoute(); // ensure user is not logged in
const [success, setSuccess] = React.useState(false);
const [skynetFreeInviteVisible, setSkynetFreeInviteVisible] = React.useState(false);
const isSiaskyNet = typeof window !== "undefined" && window.location.hostname === "account.siasky.net";
const onSubmit = async (values) => {
await accountsApi.post("user/recover/request", {
@ -64,6 +66,16 @@ export default function Recovery() {
</Link>{" "}
for a new account
</p>
{skynetFreeInviteVisible && isSiaskyNet && (
<div className="font-content rounded border border-blue-200 mt-6 p-4 bg-blue-100">
<p>
All Siasky.net accounts have been moved to{" "}
<a className="text-primary" href="https://skynetfree.net">
SkynetFree.net
</a>
</p>
</div>
)}
</div>
{!success && (
@ -72,6 +84,9 @@ export default function Recovery() {
validationSchema={validationSchema}
onSubmit={onSubmit}
button="Send recovery link"
onError={(errorMessage) =>
setSkynetFreeInviteVisible(errorMessage === "registrations are currently disabled")
}
/>
)}