import { Alert, Button } from "antd"; import { IOView } from "../types"; import { useActions, useAppState } from "../overmind"; const maybeWithEnv = (v, env: string) => (env === "prod" ? v : `${v}-${env}`); export const NewsafeAuth: IOView<{ redirectPath?: string; redirectUrl?: string; }> = ({ children, redirectPath, redirectUrl }) => { const state = useAppState(); const actions = useActions(); const hostname = state.config.settings.newsafe.currentHost || state.config.settings.app.currentHost; const params = { requestor: state.config.settings.newcoin.daoDomain, referer: hostname, redirectUrl: redirectUrl || redirectPath || `https://${hostname}`, }; const { stage, env } = state.config.env; const newstackConsoleUrl = maybeWithEnv("https://console", env) + ".newstack.dev"; const isConfigured = params.requestor && stage; return ( <> {children || ( <> {isConfigured &&