import * as React from "react";
import * as System from "~/components/system";
import SystemPage from "~/components/system/SystemPage";
import ViewSourceLink from "~/components/system/ViewSourceLink";
import { createPow } from "@textile/powergate-client";
const EXAMPLE_CODE = `import * as React from 'react';
import { CreateToken } from 'slate-react-system';
import { createPow } from "@textile/powergate-client";
class Example extends React.Component {
state = {
token: null
}
_handleCreateToken = () => {
// NOTE
// Requires PowerGate to be running locally.
const PowerGate = createPow({ host: 'http://0.0.0.0:6002' });
const FFS = await PowerGate.ffs.create();
return FFS.token ? FFS.token : null;
}
render() {
return (
);
}
}
`;
export default class GeneratePowergateToken extends React.Component {
state = {
token: null,
};
_handleCreateToken = () => {
let token;
/* TODO(jim): Stub hosted Powergate.
const PowerGate = createPow({ host: 'http://0.0.0.0:6002' });
const FFS = await PowerGate.ffs.create();
token = FFS.token ? FFS.token : null;
*/
// NOTE(jim): Demo purposes.
token = "82324ce3-3fb4-4eea-ac75-f7797d96a403";
this.setState({ token });
};
render() {
return (
Generate Powergate token{" "}
Here is an example of an experience for generating a{" "}
powergate token
{" "}
in the client.
Code
{EXAMPLE_CODE}
);
}
}