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 &&

{`Welcome to ${state.config.settings.app.name}`}

}

This application is using NEWSAFE
the decentralized identity and access management service.


{isConfigured ? ( <>

Please sign in using your account at auth.newsafe.org


) : (

This application had not been configured correctly.


If you are the developer of the app:

} type="error" />
)} )} ); };