/* This file is part of GNU Anastasis (C) 2021-2022 Anastasis SARL GNU Anastasis is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GNU Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with GNU Anastasis; see the file COPYING. If not, see */ import { AuthenticationProviderStatusError, AuthenticationProviderStatusOk, } from "@gnu-taler/anastasis-core"; import { h, VNode } from "preact"; import { useEffect, useState } from "preact/hooks"; import { TextInput } from "../../../components/fields/TextInput.js"; import { Notifications } from "../../../components/Notifications.js"; import { AnastasisClientFrame } from "../index.js"; import { testProvider, WithoutType, WithType } from "./index.js"; import { useTranslationContext } from "../../../context/translation.js"; export function WithProviderType(props: WithType): VNode { const { i18n } = useTranslationContext(); return (

{i18n.str`Add a provider url for a ${props.providerLabel} service`}

Example: https://kudos.demo.anastasis.lu

{props.testing &&

Testing

}
{props.authProvidersByStatus["ok"].length > 0 ? (

Current providers for {props.providerLabel} service

) : (

No known providers for {props.providerLabel} service

)} {props.authProvidersByStatus["ok"].map((k, i) => { const p = k as AuthenticationProviderStatusOk; return ( ); })}

Providers with errors

{props.authProvidersByStatus["error"].map((k, i) => { const p = k as AuthenticationProviderStatusError; return ( ); })}
); } export function WithoutProviderType(props: WithoutType): VNode { return (

Add a provider url

Example: https://kudos.demo.anastasis.lu

{props.testing &&

Testing

}
{props.authProvidersByStatus["ok"].length > 0 ? (

Current providers

) : (

No known providers, add one.

)} {props.authProvidersByStatus["ok"].map((k, i) => { const p = k as AuthenticationProviderStatusOk; return ( ); })}

Providers with errors

{props.authProvidersByStatus["error"].map((k, i) => { const p = k as AuthenticationProviderStatusError; return ( ); })}
); } function TableRow({ url, info, onDelete, }: { onDelete: (s: string) => Promise; url: string; info: AuthenticationProviderStatusOk; }): VNode { const [status, setStatus] = useState("checking"); useEffect(function () { testProvider(url.endsWith("/") ? url.substring(0, url.length - 1) : url) .then(function () { setStatus("responding"); }) .catch(function () { setStatus("failed to contact"); }); }); return (
{url}
Business Name
{info.business_name}
Supported methods
{info.methods.map((m) => m.type).join(",")}
Maximum storage
{info.storage_limit_in_megabytes} Mb
Status
{status}
); } function TableRowError({ url, info, onDelete, }: { onDelete: (s: string) => void; url: string; info: AuthenticationProviderStatusError; }): VNode { const [status, setStatus] = useState("checking"); useEffect(function () { testProvider(url.endsWith("/") ? url.substring(0, url.length - 1) : url) .then(function () { setStatus("responding"); }) .catch(function () { setStatus("failed to contact"); }); }); return (
{url}
Error
{info.hint}
Code
{info.code}
Status
{status}
); }