Matchu
81b2a2b4a2
We add jsbuilding-rails to get esbuild running in the app, and then we copy-paste the files we need from impress-2020 into here! I stopped at the point where it was building successfully, but it's not running correctly: it's not sure about `process.env` in `next`, and I think the right next step is to delete the NextJS deps altogether and use React Router instead.
32 lines
1,006 B
JavaScript
32 lines
1,006 B
JavaScript
import * as React from "react";
|
|
|
|
/**
|
|
* useSupport returns the Support secret that the server requires for Support
|
|
* actions... if the user has it set. For most users, this returns nothing!
|
|
*
|
|
* Specifically, we return an object of:
|
|
* - isSupportUser: true iff the `supportSecret` is set
|
|
* - supportSecret: the secret saved to this device, or null if not set
|
|
*
|
|
* To become a Support user, you visit /?supportSecret=..., which saves the
|
|
* secret to your device.
|
|
*
|
|
* Note that this hook doesn't check that the secret is *correct*, so it's
|
|
* possible that it will return an invalid secret. That's okay, because
|
|
* the server checks the provided secret for each Support request.
|
|
*/
|
|
function useSupport() {
|
|
const supportSecret = React.useMemo(
|
|
() =>
|
|
typeof localStorage !== "undefined"
|
|
? localStorage.getItem("supportSecret")
|
|
: null,
|
|
[]
|
|
);
|
|
|
|
const isSupportUser = supportSecret != null;
|
|
|
|
return { isSupportUser, supportSecret };
|
|
}
|
|
|
|
export default useSupport;
|