This repository has been archived on 2022-10-07. You can view files and clone it, but cannot push or open issues or pull requests.
2022-01-12 12:44:23 +00:00
|
|
|
import * as React from "react";
|
|
|
|
import skynetClient from "./skynetClient";
|
|
|
|
|
|
|
|
export default function useAccountsUrl() {
|
|
|
|
const [url, setUrl] = React.useState("");
|
2022-02-02 18:22:09 +00:00
|
|
|
const createAccountsUrl = React.useCallback((path = "") => url && new URL(path, url).toString(), [url]);
|
2022-01-12 12:44:23 +00:00
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
(async function resolve() {
|
|
|
|
const portalUrl = new URL(await skynetClient.portalUrl());
|
|
|
|
|
|
|
|
portalUrl.host = `account.${portalUrl.host}`;
|
|
|
|
|
|
|
|
setUrl(portalUrl.toString());
|
|
|
|
})();
|
|
|
|
}, [setUrl]);
|
|
|
|
|
2022-02-02 18:05:30 +00:00
|
|
|
return createAccountsUrl;
|
2022-01-12 12:44:23 +00:00
|
|
|
}
|