aboutsummaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui/src/paths/admin/list/TableActive.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/admin/list/TableActive.tsx')
-rw-r--r--packages/merchant-backoffice-ui/src/paths/admin/list/TableActive.tsx45
1 files changed, 24 insertions, 21 deletions
diff --git a/packages/merchant-backoffice-ui/src/paths/admin/list/TableActive.tsx b/packages/merchant-backoffice-ui/src/paths/admin/list/TableActive.tsx
index 885a351d2..cff3c5a02 100644
--- a/packages/merchant-backoffice-ui/src/paths/admin/list/TableActive.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/admin/list/TableActive.tsx
@@ -1,6 +1,6 @@
/*
This file is part of GNU Taler
- (C) 2021-2023 Taler Systems S.A.
+ (C) 2021-2024 Taler Systems S.A.
GNU Taler is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -19,19 +19,21 @@
* @author Sebastian Javier Marchano (sebasjm)
*/
-import { useTranslationContext } from "@gnu-taler/web-util/browser";
-import { h, VNode } from "preact";
+import { TalerMerchantApi } from "@gnu-taler/taler-util";
+import {
+ useTranslationContext
+} from "@gnu-taler/web-util/browser";
+import { VNode, h } from "preact";
import { StateUpdater, useEffect, useState } from "preact/hooks";
-import { MerchantBackend } from "../../../declaration.js";
+import { useSessionContext } from "../../../context/session.js";
interface Props {
- instances: MerchantBackend.Instances.Instance[];
+ instances: TalerMerchantApi.Instance[];
onUpdate: (id: string) => void;
- onDelete: (id: MerchantBackend.Instances.Instance) => void;
- onPurge: (id: MerchantBackend.Instances.Instance) => void;
+ onDelete: (id: TalerMerchantApi.Instance) => void;
+ onPurge: (id: TalerMerchantApi.Instance) => void;
onCreate: () => void;
selected?: boolean;
- setInstanceName: (s: string) => void;
}
export function CardTable({
@@ -39,7 +41,6 @@ export function CardTable({
onCreate,
onUpdate,
onPurge,
- setInstanceName,
onDelete,
selected,
}: Props): VNode {
@@ -114,7 +115,6 @@ export function CardTable({
instances={instances}
onPurge={onPurge}
onUpdate={onUpdate}
- setInstanceName={setInstanceName}
onDelete={onDelete}
rowSelection={rowSelection}
rowSelectionHandler={rowSelectionHandler}
@@ -130,12 +130,11 @@ export function CardTable({
}
interface TableProps {
rowSelection: string[];
- instances: MerchantBackend.Instances.Instance[];
+ instances: TalerMerchantApi.Instance[];
onUpdate: (id: string) => void;
- onDelete: (id: MerchantBackend.Instances.Instance) => void;
- onPurge: (id: MerchantBackend.Instances.Instance) => void;
+ onDelete: (id: TalerMerchantApi.Instance) => void;
+ onPurge: (id: TalerMerchantApi.Instance) => void;
rowSelectionHandler: StateUpdater<string[]>;
- setInstanceName: (s: string) => void;
}
function toggleSelected<T>(id: T): (prev: T[]) => T[] {
@@ -146,13 +145,14 @@ function toggleSelected<T>(id: T): (prev: T[]) => T[] {
function Table({
rowSelection,
rowSelectionHandler,
- setInstanceName,
instances,
onUpdate,
onDelete,
onPurge,
}: TableProps): VNode {
const { i18n } = useTranslationContext();
+ const { lib } = useSessionContext();
+ const { impersonate } = useSessionContext();
return (
<div class="table-container">
<table class="table is-fullwidth is-striped is-hoverable is-fullwidth">
@@ -201,9 +201,12 @@ function Table({
</td>
<td>
<a
- href={`#/orders?instance=${i.id}`}
- onClick={(e) => {
- setInstanceName(i.id);
+ href={`#/orders`}
+ onClick={async (_e) => {
+ // e.preventDefault();
+ const newInstanceApi = lib.subInstanceApi(i.id);
+ //not checking /config since this comes from instance list
+ impersonate(new URL(newInstanceApi.instance.baseUrl));
}}
>
{i.id}
@@ -254,7 +257,7 @@ function EmptyTable(): VNode {
<div class="content has-text-grey has-text-centered">
<p>
<span class="icon is-large">
- <i class="mdi mdi-emoticon-sad mdi-48px" />
+ <i class="mdi mdi-magnify mdi-48px" />
</span>
</p>
<p>
@@ -267,7 +270,7 @@ function EmptyTable(): VNode {
}
interface Actions {
- element: MerchantBackend.Instances.Instance;
+ element: TalerMerchantApi.Instance;
type: "DELETE" | "UPDATE";
}
@@ -276,7 +279,7 @@ function notEmpty<TValue>(value: TValue | null | undefined): value is TValue {
}
function buildActions(
- instances: MerchantBackend.Instances.Instance[],
+ instances: TalerMerchantApi.Instance[],
selected: string[],
action: "DELETE",
): Actions[] {