2019-10-30 14:14:31 -06:00
|
|
|
import { Callback } from "i18next";
|
2019-02-04 09:31:52 -07:00
|
|
|
import _React, { createElement } from "react";
|
2019-01-31 10:24:10 -07:00
|
|
|
import { render } from "react-dom";
|
|
|
|
import { PasswordReset } from "./password_reset";
|
|
|
|
import { bail } from "../util";
|
2017-10-16 07:18:57 -06:00
|
|
|
|
|
|
|
export const MISSING_DIV = "Add a div with id `root` to the page first.";
|
|
|
|
|
2019-10-30 14:14:31 -06:00
|
|
|
export const onInit: Callback = async () => {
|
2017-10-16 07:18:57 -06:00
|
|
|
const node = document.createElement("DIV");
|
|
|
|
node.id = "root";
|
|
|
|
document.body.appendChild(node);
|
|
|
|
|
2019-02-04 09:31:52 -07:00
|
|
|
const reactElem = createElement(PasswordReset, {});
|
2017-10-16 07:18:57 -06:00
|
|
|
const domElem = document.getElementById("root");
|
|
|
|
|
|
|
|
return (domElem) ? render(reactElem, domElem) : bail(MISSING_DIV);
|
|
|
|
};
|