summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNic Eigel <nic@eigel.ch>2024-01-14 17:44:02 +0100
committerNic Eigel <nic@eigel.ch>2024-01-14 17:44:02 +0100
commita29db7a4a5311ab5b5d489a1eedfd1f4555773ae (patch)
treeb6f0a43daf7b7eaf1ad95fe09171212c59b48546
parente162a8cb655adc95c8cd8d87319a76c8e9792994 (diff)
downloadwallet-core-a29db7a4a5311ab5b5d489a1eedfd1f4555773ae.tar.gz
wallet-core-a29db7a4a5311ab5b5d489a1eedfd1f4555773ae.tar.bz2
wallet-core-a29db7a4a5311ab5b5d489a1eedfd1f4555773ae.zip
updating makefile, fixing auditor-backoffice
-rw-r--r--Makefile9
-rw-r--r--packages/auditor-backoffice-ui/src/InstanceRoutes.tsx315
-rw-r--r--packages/auditor-backoffice-ui/src/components/menu/index.tsx32
-rw-r--r--packages/auditor-backoffice-ui/src/declaration.d.ts49
-rw-r--r--packages/auditor-backoffice-ui/src/hooks/product.ts10
-rw-r--r--packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/CreatedSuccessfully.tsx3
-rw-r--r--packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/index.tsx16
-rw-r--r--packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/List.stories.tsx18
-rw-r--r--packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/Table.tsx249
-rw-r--r--packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/index.tsx25
-rw-r--r--packages/auditor-backoffice-ui/src/paths/instance/products/create/index.tsx19
-rw-r--r--pnpm-lock.yaml127
12 files changed, 151 insertions, 721 deletions
diff --git a/Makefile b/Makefile
index 73e6cfeda..ca65b1c5a 100644
--- a/Makefile
+++ b/Makefile
@@ -58,7 +58,13 @@ backend-prebuilt:
aml-backoffice-prebuilt:
pnpm install --frozen-lockfile --filter @gnu-taler/aml-backoffice-ui...
pnpm run --filter @gnu-taler/aml-backoffice-ui... build
- ./contrib/copy-aml-backoffice-into-prebuilt.sh
+ ./contrib/copy-aml-backoffice-into-prebuilt.s
+
+.PHONY: auditor-backoffice-prebuilt
+auditor-backoffice-prebuilt:
+ pnpm install --frozen-lockfile --filter @gnu-taler/auditor-backoffice-ui...
+ pnpm run --filter @gnu-taler/auditor-backoffice-ui... build
+ ./contrib/copy-auditor-backoffice-into-prebuilt.sh
.PHONY: challenger-prebuilt
challenger-prebuilt:
@@ -144,6 +150,7 @@ install:
$(MAKE) -C packages/demobank-ui install-nodeps
$(MAKE) -C packages/merchant-backoffice-ui install-nodeps
$(MAKE) -C packages/aml-backoffice-ui install-nodeps
+ $(MAKE) -C packages/auditor-backoffice-ui install-nodeps
.PHONY: install-tools
diff --git a/packages/auditor-backoffice-ui/src/InstanceRoutes.tsx b/packages/auditor-backoffice-ui/src/InstanceRoutes.tsx
index 14ccf773a..163438654 100644
--- a/packages/auditor-backoffice-ui/src/InstanceRoutes.tsx
+++ b/packages/auditor-backoffice-ui/src/InstanceRoutes.tsx
@@ -203,12 +203,6 @@ export function InstanceRoutes({
type: "INFO",
}}
/>
- <InstanceCreatePage
- forceId="default"
- onConfirm={() => {
- route(InstancePaths.order_list);
- }}
- />
</Fragment>
);
}
@@ -251,7 +245,6 @@ export function InstanceRoutes({
}
}}
>
- <Route path="/" component={Redirect} to={InstancePaths.order_list} />
{/**
* Admin pages
*/}
@@ -272,16 +265,6 @@ export function InstanceRoutes({
)}
{admin && (
<Route
- path={AdminPaths.new_instance}
- component={InstanceCreatePage}
- onBack={() => route(AdminPaths.list_instances)}
- onConfirm={() => {
- route(InstancePaths.order_list);
- }}
- />
- )}
- {admin && (
- <Route
path={AdminPaths.update_instance}
component={AdminInstanceUpdatePage}
onBack={() => route(AdminPaths.list_instances)}
@@ -311,22 +294,6 @@ export function InstanceRoutes({
onLoadError={ServerErrorRedirectTo(InstancePaths.error)}
/>
{/**
- * Update instance page
- */}
- <Route
- path={InstancePaths.token}
- component={TokenPage}
- onChange={() => {
- route(`/`);
- }}
- onCancel={() => {
- route(InstancePaths.order_list)
- }}
- onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
- onUnauthorized={LoginPageAccessDenied}
- onLoadError={ServerErrorRedirectTo(InstancePaths.error)}
- />
- {/**
* Inventory pages
*/}
<Route
@@ -404,288 +371,6 @@ export function InstanceRoutes({
route(InstancePaths.deposit_confirmation_list);
}}
/>
- {/**
- * Bank pages
- */}
- <Route
- path={InstancePaths.bank_list}
- component={BankAccountListPage}
- onUnauthorized={LoginPageAccessDenied}
- onLoadError={ServerErrorRedirectTo(InstancePaths.settings)}
- onCreate={() => {
- route(InstancePaths.bank_new);
- }}
- onSelect={(id: string) => {
- route(InstancePaths.bank_update.replace(":bid", id));
- }}
- onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
- />
- <Route
- path={InstancePaths.bank_update}
- component={BankAccountUpdatePage}
- onUnauthorized={LoginPageAccessDenied}
- onLoadError={ServerErrorRedirectTo(InstancePaths.inventory_list)}
- onConfirm={() => {
- route(InstancePaths.bank_list);
- }}
- onBack={() => {
- route(InstancePaths.bank_list);
- }}
- onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
- />
- <Route
- path={InstancePaths.bank_new}
- component={BankAccountCreatePage}
- onConfirm={() => {
- route(InstancePaths.bank_list);
- }}
- onBack={() => {
- route(InstancePaths.bank_list);
- }}
- />
- {/**
- * Order pages
- */}
- <Route
- path={InstancePaths.order_list}
- component={OrderListPage}
- onCreate={() => {
- route(InstancePaths.order_new);
- }}
- onSelect={(id: string) => {
- route(InstancePaths.order_details.replace(":oid", id));
- }}
- onUnauthorized={LoginPageAccessDenied}
- onLoadError={ServerErrorRedirectTo(InstancePaths.settings)}
- onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
- />
- <Route
- path={InstancePaths.order_details}
- component={OrderDetailsPage}
- onUnauthorized={LoginPageAccessDenied}
- onLoadError={ServerErrorRedirectTo(InstancePaths.order_list)}
- onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
- onBack={() => {
- route(InstancePaths.order_list);
- }}
- />
- <Route
- path={InstancePaths.order_new}
- component={OrderCreatePage}
- onConfirm={(orderId: string) => {
- route(InstancePaths.order_details.replace(":oid", orderId));
- }}
- onBack={() => {
- route(InstancePaths.order_list);
- }}
- />
- {/**
- * Transfer pages
- */}
- <Route
- path={InstancePaths.transfers_list}
- component={TransferListPage}
- onUnauthorized={LoginPageAccessDenied}
- onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
- onLoadError={ServerErrorRedirectTo(InstancePaths.settings)}
- onCreate={() => {
- route(InstancePaths.transfers_new);
- }}
- />
- <Route
- path={InstancePaths.transfers_new}
- component={TransferCreatePage}
- onConfirm={() => {
- route(InstancePaths.transfers_list);
- }}
- onBack={() => {
- route(InstancePaths.transfers_list);
- }}
- />
- {/**
- * Webhooks pages
- */}
- <Route
- path={InstancePaths.webhooks_list}
- component={WebhookListPage}
- onUnauthorized={LoginPageAccessDenied}
- onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
- onLoadError={ServerErrorRedirectTo(InstancePaths.settings)}
- onCreate={() => {
- route(InstancePaths.webhooks_new);
- }}
- onSelect={(id: string) => {
- route(InstancePaths.webhooks_update.replace(":tid", id));
- }}
- />
- <Route
- path={InstancePaths.webhooks_update}
- component={WebhookUpdatePage}
- onConfirm={() => {
- route(InstancePaths.webhooks_list);
- }}
- onUnauthorized={LoginPageAccessDenied}
- onLoadError={ServerErrorRedirectTo(InstancePaths.webhooks_list)}
- onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
- onBack={() => {
- route(InstancePaths.webhooks_list);
- }}
- />
- <Route
- path={InstancePaths.webhooks_new}
- component={WebhookCreatePage}
- onConfirm={() => {
- route(InstancePaths.webhooks_list);
- }}
- onBack={() => {
- route(InstancePaths.webhooks_list);
- }}
- />
- {/**
- * Validator pages
- */}
- <Route
- path={InstancePaths.otp_devices_list}
- component={ValidatorListPage}
- onUnauthorized={LoginPageAccessDenied}
- onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
- onLoadError={ServerErrorRedirectTo(InstancePaths.settings)}
- onCreate={() => {
- route(InstancePaths.otp_devices_new);
- }}
- onSelect={(id: string) => {
- route(InstancePaths.otp_devices_update.replace(":vid", id));
- }}
- />
- <Route
- path={InstancePaths.otp_devices_update}
- component={ValidatorUpdatePage}
- onConfirm={() => {
- route(InstancePaths.otp_devices_list);
- }}
- onUnauthorized={LoginPageAccessDenied}
- onLoadError={ServerErrorRedirectTo(InstancePaths.otp_devices_list)}
- onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
- onBack={() => {
- route(InstancePaths.otp_devices_list);
- }}
- />
- <Route
- path={InstancePaths.otp_devices_new}
- component={ValidatorCreatePage}
- onConfirm={() => {
- route(InstancePaths.otp_devices_list);
- }}
- onBack={() => {
- route(InstancePaths.otp_devices_list);
- }}
- />
- {/**
- * Templates pages
- */}
- <Route
- path={InstancePaths.templates_list}
- component={TemplateListPage}
- onUnauthorized={LoginPageAccessDenied}
- onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
- onLoadError={ServerErrorRedirectTo(InstancePaths.settings)}
- onCreate={() => {
- route(InstancePaths.templates_new);
- }}
- onNewOrder={(id: string) => {
- route(InstancePaths.templates_use.replace(":tid", id));
- }}
- onQR={(id: string) => {
- route(InstancePaths.templates_qr.replace(":tid", id));
- }}
- onSelect={(id: string) => {
- route(InstancePaths.templates_update.replace(":tid", id));
- }}
- />
- <Route
- path={InstancePaths.templates_update}
- component={TemplateUpdatePage}
- onConfirm={() => {
- route(InstancePaths.templates_list);
- }}
- onUnauthorized={LoginPageAccessDenied}
- onLoadError={ServerErrorRedirectTo(InstancePaths.templates_list)}
- onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
- onBack={() => {
- route(InstancePaths.templates_list);
- }}
- />
- <Route
- path={InstancePaths.templates_new}
- component={TemplateCreatePage}
- onConfirm={() => {
- route(InstancePaths.templates_list);
- }}
- onBack={() => {
- route(InstancePaths.templates_list);
- }}
- />
- <Route
- path={InstancePaths.templates_use}
- component={TemplateUsePage}
- onOrderCreated={(id: string) => {
- route(InstancePaths.order_details.replace(":oid", id));
- }}
- onUnauthorized={LoginPageAccessDenied}
- onLoadError={ServerErrorRedirectTo(InstancePaths.templates_list)}
- onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
- onBack={() => {
- route(InstancePaths.templates_list);
- }}
- />
- <Route
- path={InstancePaths.templates_qr}
- component={TemplateQrPage}
- onUnauthorized={LoginPageAccessDenied}
- onLoadError={ServerErrorRedirectTo(InstancePaths.templates_list)}
- onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
- onBack={() => {
- route(InstancePaths.templates_list);
- }}
- />
-
- {/**
- * reserves pages
- */}
- <Route
- path={InstancePaths.reserves_list}
- component={ReservesListPage}
- onUnauthorized={LoginPageAccessDenied}
- onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
- onLoadError={ServerErrorRedirectTo(InstancePaths.settings)}
- onSelect={(id: string) => {
- route(InstancePaths.reserves_details.replace(":rid", id));
- }}
- onCreate={() => {
- route(InstancePaths.reserves_new);
- }}
- />
- <Route
- path={InstancePaths.reserves_details}
- component={ReservesDetailsPage}
- onUnauthorized={LoginPageAccessDenied}
- onLoadError={ServerErrorRedirectTo(InstancePaths.reserves_list)}
- onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
- onBack={() => {
- route(InstancePaths.reserves_list);
- }}
- />
- <Route
- path={InstancePaths.reserves_new}
- component={ReservesCreatePage}
- onConfirm={() => {
- route(InstancePaths.reserves_list);
- }}
- onBack={() => {
- route(InstancePaths.reserves_list);
- }}
- />
- <Route path={InstancePaths.kyc} component={ListKYCPage} />
<Route path={InstancePaths.interface} component={Settings} />
{/**
* Example pages
diff --git a/packages/auditor-backoffice-ui/src/components/menu/index.tsx b/packages/auditor-backoffice-ui/src/components/menu/index.tsx
index 03ae3b005..015d3bd05 100644
--- a/packages/auditor-backoffice-ui/src/components/menu/index.tsx
+++ b/packages/auditor-backoffice-ui/src/components/menu/index.tsx
@@ -26,10 +26,6 @@ function getInstanceTitle(path: string, id: string): string {
switch (path) {
case InstancePaths.settings:
return `${id}: Settings`;
- case InstancePaths.order_list:
- return `${id}: Orders`;
- case InstancePaths.order_new:
- return `${id}: New order`;
case InstancePaths.inventory_list:
return `${id}: Inventory`;
case InstancePaths.deposit_confirmation_list:
@@ -38,34 +34,6 @@ function getInstanceTitle(path: string, id: string): string {
return `${id}: New product`;
case InstancePaths.inventory_update:
return `${id}: Update product`;
- case InstancePaths.reserves_new:
- return `${id}: New reserve`;
- case InstancePaths.reserves_list:
- return `${id}: Reserves`;
- case InstancePaths.transfers_list:
- return `${id}: Transfers`;
- case InstancePaths.transfers_new:
- return `${id}: New transfer`;
- case InstancePaths.webhooks_list:
- return `${id}: Webhooks`;
- case InstancePaths.webhooks_new:
- return `${id}: New webhook`;
- case InstancePaths.webhooks_update:
- return `${id}: Update webhook`;
- case InstancePaths.otp_devices_list:
- return `${id}: otp devices`;
- case InstancePaths.otp_devices_new:
- return `${id}: New otp devices`;
- case InstancePaths.otp_devices_update:
- return `${id}: Update otp devices`;
- case InstancePaths.templates_new:
- return `${id}: New template`;
- case InstancePaths.templates_update:
- return `${id}: Update template`;
- case InstancePaths.templates_list:
- return `${id}: Templates`;
- case InstancePaths.templates_use:
- return `${id}: Use template`;
case InstancePaths.interface:
return `${id}: Interface`;
default:
diff --git a/packages/auditor-backoffice-ui/src/declaration.d.ts b/packages/auditor-backoffice-ui/src/declaration.d.ts
index f0c79268c..0c6f599f7 100644
--- a/packages/auditor-backoffice-ui/src/declaration.d.ts
+++ b/packages/auditor-backoffice-ui/src/declaration.d.ts
@@ -298,50 +298,13 @@ export namespace AuditorBackend {
amount_without_fee: string;
}
- // GET /private/products/$PRODUCT_ID
+ // GET /deposit-confirmation/$SERIAL_ID
interface DepositConfirmationDetail {
- // Human-readable product description.
- description: string;
-
- // Map from IETF BCP 47 language tags to localized descriptions
- description_i18n: { [lang_tag: string]: string };
-
- // unit in which the product is measured (liters, kilograms, packages, etc.)
- unit: string;
-
- // The price for one unit of the product. Zero is used
- // to imply that this product is not sold separately, or
- // that the price is not fixed, and must be supplied by the
- // front-end. If non-zero, this price MUST include applicable
- // taxes.
- price: Amount;
-
- // An optional base64-encoded product image
- image: ImageDataUrl;
-
- // a list of taxes paid by the merchant for one unit of this product
- taxes: Tax[];
-
- // Number of units of the product in stock in sum in total,
- // including all existing sales ever. Given in product-specific
- // units.
- // A value of -1 indicates "infinite" (i.e. for "electronic" books).
- total_stock: Integer;
-
- // Number of units of the product that have already been sold.
- total_sold: Integer;
-
- // Number of units of the product that were lost (spoiled, stolen, etc.)
- total_lost: Integer;
-
- // Identifies where the product is in stock.
- address: Location;
-
- // Identifies when we expect the next restocking to happen.
- next_restock?: Timestamp;
-
- // Minimum age buyer must have (in years). Default is 0.
- minimum_age?: Integer;
+ serial_id: string;
+ timestamp: string;
+ refund_deadline: string;
+ wire_deadline: string;
+ amount_without_fee: string;
}
}
diff --git a/packages/auditor-backoffice-ui/src/hooks/product.ts b/packages/auditor-backoffice-ui/src/hooks/product.ts
index b8f55cb77..8ca8d2724 100644
--- a/packages/auditor-backoffice-ui/src/hooks/product.ts
+++ b/packages/auditor-backoffice-ui/src/hooks/product.ts
@@ -18,7 +18,7 @@ import {
HttpResponseOk,
RequestError,
} from "@gnu-taler/web-util/browser";
-import { AuditorBackend, MerchantBackend, WithId } from "../declaration.js";
+import { MerchantBackend, WithId } from "../declaration.js";
import { useBackendInstanceRequest, useMatchMutate } from "./backend.js";
// FIX default import https://github.com/microsoft/TypeScript/issues/49189
@@ -27,7 +27,7 @@ const useSWR = _useSWR as unknown as SWRHook;
export interface ProductAPI {
getProduct: (
- id: string,
+ id: string,
) => Promise<void>;
createProduct: (
data: MerchantBackend.Products.ProductAddDetail,
@@ -122,11 +122,11 @@ export function useInstanceProducts(): HttpResponse<
});
const paths = (list?.data.products || []).map(
- (p) => `/deposit-confirmation/${p.serial_id}`,
+ (p) => `/private/products/${p.product_id}`,
);
const { data: products, error: productError } = useSWR<
- HttpResponseOk<AuditorBackend.DepositConfirmation.DepositConfirmationDetail>[],
- RequestError<AuditorBackend.ErrorDetail>
+ HttpResponseOk<MerchantBackend.Products.ProductDetail>[],
+ RequestError<MerchantBackend.ErrorDetail>
>([paths], multiFetcher, {
refreshInterval: 0,
refreshWhenHidden: false,
diff --git a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/CreatedSuccessfully.tsx b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/CreatedSuccessfully.tsx
index 6b02430cc..573064aea 100644
--- a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/CreatedSuccessfully.tsx
+++ b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/CreatedSuccessfully.tsx
@@ -38,7 +38,6 @@ export function CreatedSuccessfully({
<div class="field-body is-flex-grow-3">
<div class="field">
<p class="control">
- <img src={entity.image} style={{ width: 200, height: 200 }} />
</p>
</div>
</div>
@@ -50,7 +49,6 @@ export function CreatedSuccessfully({
<div class="field-body is-flex-grow-3">
<div class="field">
<p class="control">
- <textarea class="input" readonly value={entity.description} />
</p>
</div>
</div>
@@ -62,7 +60,6 @@ export function CreatedSuccessfully({
<div class="field-body is-flex-grow-3">
<div class="field">
<p class="control">
- <input class="input" readonly value={entity.price} />
</p>
</div>
</div>
diff --git a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/index.tsx b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/index.tsx
index 4b59e9807..99599cfab 100644
--- a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/index.tsx
+++ b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/index.tsx
@@ -34,27 +34,13 @@ interface Props {
onConfirm: () => void;
}
export default function CreateProduct({ onConfirm, onBack }: Props): VNode {
- const { createProduct } = useProductAPI();
+ const { createDepositConfirmation } = useDepositConfirmationAPI();
const [notif, setNotif] = useState<Notification | undefined>(undefined);
const { i18n } = useTranslationContext();
return (
<Fragment>
<NotificationCard notification={notif} />
- <CreatePage
- onBack={onBack}
- onCreate={(request: MerchantBackend.Products.ProductAddDetail) => {
- return createProduct(request)
- .then(() => onConfirm())
- .catch((error) => {
- setNotif({
- message: i18n.str`could not create product`,
- type: "ERROR",
- description: error.message,
- });
- });
- }}
- />
</Fragment>
);
}
diff --git a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/List.stories.tsx b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/List.stories.tsx
index c2c4d548c..41c297d5b 100644
--- a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/List.stories.tsx
+++ b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/List.stories.tsx
@@ -41,21 +41,3 @@ function createExample<Props>(
r.args = props;
return r;
}
-
-export const Example = createExample(TestedComponent, {
- instances: [
- {
- id: "orderid",
- description: "description1",
- description_i18n: {} as any,
- image: "",
- price: "TESTKUDOS:10",
- taxes: [],
- total_lost: 10,
- total_sold: 5,
- total_stock: 15,
- unit: "bar",
- address: {},
- },
- ],
-});
diff --git a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/Table.tsx b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/Table.tsx
index ffd1f12e5..2c97b59e8 100644
--- a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/Table.tsx
+++ b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/Table.tsx
@@ -155,27 +155,6 @@ function Table({
</thead>
<tbody>
{instances.map((i) => {
- const restStockInfo = !i.next_restock
- ? ""
- : i.next_restock.t_s === "never"
- ? "never"
- : `restock at ${format(
- new Date(i.next_restock.t_s * 1000),
- dateFormatForSettings(settings),
- )}`;
- let stockInfo: ComponentChildren = "";
- if (i.total_stock < 0) {
- stockInfo = "infinite";
- } else {
- const totalStock = i.total_stock - i.total_lost - i.total_sold;
- stockInfo = (
- <label title={restStockInfo}>
- {totalStock} {i.unit}
- </label>
- );
- }
-
- const isFree = Amounts.isZero(Amounts.parseOrThrow(i.price));
return (
<Fragment key={i.id}>
@@ -186,69 +165,8 @@ function Table({
}
style={{ cursor: "pointer" }}
>
- <img
- src={i.image ? i.image : emptyImage}
- style={{
- border: "solid black 1px",
- maxHeight: "2em",
- width: "auto",
- height: "auto",
- }}
- />
</td>
- <td
- class="has-tooltip-right"
- data-tooltip={i.description}
- onClick={() =>
- rowSelection !== i.id && rowSelectionHandler(i.id)
- }
- style={{ cursor: "pointer" }}
- >
- {i.description.length > 30 ? i.description.substring(0, 30) + "..." : i.description}
- </td>
- <td
- onClick={() =>
- rowSelection !== i.id && rowSelectionHandler(i.id)
- }
- style={{ cursor: "pointer" }}
- >
- {isFree ? i18n.str`free` : `${i.price} / ${i.unit}`}
- </td>
- <td
- onClick={() =>
- rowSelection !== i.id && rowSelectionHandler(i.id)
- }
- style={{ cursor: "pointer" }}
- >
- {sum(i.taxes)}
- </td>
- <td
- onClick={() =>
- rowSelection !== i.id && rowSelectionHandler(i.id)
- }
- style={{ cursor: "pointer" }}
- >
- {difference(i.price, sum(i.taxes))}
- </td>
- <td
- onClick={() =>
- rowSelection !== i.id && rowSelectionHandler(i.id)
- }
- style={{ cursor: "pointer" }}
- >
- {stockInfo}
- </td>
- <td
- onClick={() =>
- rowSelection !== i.id && rowSelectionHandler(i.id)
- }
- style={{ cursor: "pointer" }}
- >
- <span style={{"whiteSpace":"nowrap"}}>
- {i.total_sold} {i.unit}
- </span>
- </td>
<td class="is-actions-cell right-sticky">
<div class="buttons is-right">
<span
@@ -281,15 +199,6 @@ function Table({
{rowSelection === i.id && (
<tr key="form">
<td colSpan={10}>
- <FastProductUpdateForm
- product={i}
- onUpdate={(prod) =>
- onUpdate(i.id, prod).then((r) =>
- rowSelectionHandler(undefined),
- )
- }
- onCancel={() => rowSelectionHandler(undefined)}
- />
</td>
</tr>
)}
@@ -302,13 +211,6 @@ function Table({
);
}
-interface FastProductUpdateFormProps {
- product: Entity;
- onUpdate: (
- data: MerchantBackend.Products.ProductPatchDetail,
- ) => Promise<void>;
- onCancel: () => void;
-}
interface FastProductUpdate {
incoming: number;
lost: number;
@@ -318,153 +220,7 @@ interface UpdatePrice {
price: string;
}
-function FastProductWithInfiniteStockUpdateForm({
- product,
- onUpdate,
- onCancel,
-}: FastProductUpdateFormProps) {
- const [value, valueHandler] = useState<UpdatePrice>({ price: product.price });
- const { i18n } = useTranslationContext();
-
- return (
- <Fragment>
- <FormProvider<FastProductUpdate>
- name="added"
- object={value}
- valueHandler={valueHandler as any}
- >
- <InputCurrency<FastProductUpdate>
- name="price"
- label={i18n.str`Price`}
- tooltip={i18n.str`update the product with new price`}
- />
- </FormProvider>
-
- <div class="buttons is-expanded">
-
- <div class="buttons mt-5">
- <button class="button mt-5" onClick={onCancel}>
- <i18n.Translate>Clone</i18n.Translate>
- </button>
- </div>
- <div class="buttons is-right mt-5">
- <button class="button" onClick={onCancel}>
- <i18n.Translate>Cancel</i18n.Translate>
- </button>
- <span
- class="has-tooltip-left"
- data-tooltip={i18n.str`update product with new price`}
- >
- <button
- class="button is-info"
- onClick={() =>
- onUpdate({
- ...product,
- price: value.price,
- })
- }
- >
- <i18n.Translate>Confirm update</i18n.Translate>
- </button>
- </span>
- </div>
- </div>
- </Fragment>
- );
-}
-
-function FastProductWithManagedStockUpdateForm({
- product,
- onUpdate,
- onCancel,
-}: FastProductUpdateFormProps) {
- const [value, valueHandler] = useState<FastProductUpdate>({
- incoming: 0,
- lost: 0,
- price: product.price,
- });
-
- const currentStock =
- product.total_stock - product.total_sold - product.total_lost;
-
- const errors: FormErrors<FastProductUpdate> = {
- lost:
- currentStock + value.incoming < value.lost
- ? `lost cannot be greater that current + incoming (max ${currentStock + value.incoming
- })`
- : undefined,
- };
-
- const hasErrors = Object.keys(errors).some(
- (k) => (errors as any)[k] !== undefined,
- );
- const { i18n } = useTranslationContext();
-
- return (
- <Fragment>
- <FormProvider<FastProductUpdate>
- name="added"
- errors={errors}
- object={value}
- valueHandler={valueHandler as any}
- >
- <InputNumber<FastProductUpdate>
- name="incoming"
- label={i18n.str`Incoming`}
- tooltip={i18n.str`add more elements to the inventory`}
- />
- <InputNumber<FastProductUpdate>
- name="lost"
- label={i18n.str`Lost`}
- tooltip={i18n.str`report elements lost in the inventory`}
- />
- <InputCurrency<FastProductUpdate>
- name="price"
- label={i18n.str`Price`}
- tooltip={i18n.str`new price for the product`}
- />
- </FormProvider>
-
- <div class="buttons is-right mt-5">
- <button class="button" onClick={onCancel}>
- <i18n.Translate>Cancel</i18n.Translate>
- </button>
- <span
- class="has-tooltip-left"
- data-tooltip={
- hasErrors
- ? i18n.str`the are value with errors`
- : i18n.str`update product with new stock and price`
- }
- >
- <button
- class="button is-info"
- disabled={hasErrors}
- onClick={() =>
- onUpdate({
- ...product,
- total_stock: product.total_stock + value.incoming,
- total_lost: product.total_lost + value.lost,
- price: value.price,
- })
- }
- >
- <i18n.Translate>Confirm</i18n.Translate>
- </button>
- </span>
- </div>
- </Fragment>
- );
-}
-
-function FastProductUpdateForm(props: FastProductUpdateFormProps) {
- return props.product.total_stock === -1 ? (
- <FastProductWithInfiniteStockUpdateForm {...props} />
- ) : (
- <FastProductWithManagedStockUpdateForm {...props} />
- );
-}
function EmptyTable(): VNode {
const { i18n } = useTranslationContext();
@@ -490,7 +246,4 @@ function difference(price: string, tax: number) {
const p = parseInt(ps[1], 10);
ps[1] = `${p - tax}`;
return ps.join(":");
-}
-function sum(taxes: MerchantBackend.Tax[]) {
- return taxes.reduce((p, c) => p + parseInt(c.tax.split(":")[1], 10), 0);
-}
+} \ No newline at end of file
diff --git a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/index.tsx b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/index.tsx
index dccb3ef25..e3eda37f6 100644
--- a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/index.tsx
+++ b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/index.tsx
@@ -88,31 +88,6 @@ export default function DepositConfirmationList({
palceholder={i18n.str`serial id`}
/>
- <CardTable
- instances={result.data}
- onCreate={onCreate}
- onUpdate={(id, prod) =>
- updateDepositConfirmation(id, prod)
- .then(() =>
- setNotif({
- message: i18n.str`deposit_confirmation updated successfully`,
- type: "SUCCESS",
- }),
- )
- .catch((error) =>
- setNotif({
- message: i18n.str`could not update the deposit_confirmation`,
- type: "ERROR",
- description: error.message,
- }),
- )
- }
- onSelect={(depositConfirmation) => onSelect(depositConfirmation.id)}
- onDelete={(depositConfirmation : AuditorBackend.DepositConfirmation.DepositConfirmationDetail & WithId) =>
- setDeleting(depositConfirmation)
- }
- />
-
{deleting && (
<ConfirmModal
label={`Delete deposit-confirmation`}
diff --git a/packages/auditor-backoffice-ui/src/paths/instance/products/create/index.tsx b/packages/auditor-backoffice-ui/src/paths/instance/products/create/index.tsx
index 775690bd1..0c30ff14c 100644
--- a/packages/auditor-backoffice-ui/src/paths/instance/products/create/index.tsx
+++ b/packages/auditor-backoffice-ui/src/paths/instance/products/create/index.tsx
@@ -23,12 +23,12 @@ import { useTranslationContext } from "@gnu-taler/web-util/browser";
import { Fragment, h, VNode } from "preact";
import { useState } from "preact/hooks";
import { NotificationCard } from "../../../../components/menu/index.js";
-import { MerchantBackend } from "../../../../declaration.js";
+import { AuditorBackend, MerchantBackend } from "../../../../declaration.js";
import { useProductAPI } from "../../../../hooks/product.js";
import { Notification } from "../../../../utils/types.js";
import { CreatePage } from "./CreatePage.js";
-export type Entity = MerchantBackend.Products.ProductAddDetail;
+export type Entity = MerchantBackend.Products.ProductDetail;
interface Props {
onBack?: () => void;
onConfirm: () => void;
@@ -41,20 +41,7 @@ export default function CreateProduct({ onConfirm, onBack }: Props): VNode {
return (
<Fragment>
<NotificationCard notification={notif} />
- <CreatePage
- onBack={onBack}
- onCreate={(request: MerchantBackend.Products.ProductAddDetail) => {
- return createProduct(request)
- .then(() => onConfirm())
- .catch((error) => {
- setNotif({
- message: i18n.str`could not create product`,
- type: "ERROR",
- description: error.message,
- });
- });
- }}
- />
+
</Fragment>
);
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 983963d5d..38f051a36 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -109,6 +109,133 @@ importers:
specifier: 5.3.3
version: 5.3.3
+ packages/auditor-backoffice-ui:
+ dependencies:
+ '@gnu-taler/taler-util':
+ specifier: workspace:*
+ version: link:../taler-util
+ '@gnu-taler/web-util':
+ specifier: workspace:*
+ version: link:../web-util
+ date-fns:
+ specifier: 2.29.3
+ version: 2.29.3
+ history:
+ specifier: 4.10.1
+ version: 4.10.1
+ jed:
+ specifier: 1.1.1
+ version: 1.1.1
+ preact:
+ specifier: 10.11.3
+ version: 10.11.3
+ preact-router:
+ specifier: 3.2.1
+ version: 3.2.1(preact@10.11.3)
+ qrcode-generator:
+ specifier: 1.4.4
+ version: 1.4.4
+ swr:
+ specifier: 2.2.2
+ version: 2.2.2(react@18.2.0)
+ yup:
+ specifier: ^0.32.9
+ version: 0.32.11
+ devDependencies:
+ '@creativebulma/bulma-tooltip':
+ specifier: ^1.2.0
+ version: 1.2.0
+ '@gnu-taler/pogen':
+ specifier: ^0.0.5
+ version: link:../pogen
+ '@types/chai':
+ specifier: ^4.3.0
+ version: 4.3.3
+ '@types/history':
+ specifier: ^4.7.8
+ version: 4.7.11
+ '@types/mocha':
+ specifier: ^8.2.3
+ version: 8.2.3
+ '@types/node':
+ specifier: ^18.11.17
+ version: 18.11.17
+ '@typescript-eslint/eslint-plugin':
+ specifier: ^4.22.0
+ version: 4.33.0(@typescript-eslint/parser@4.33.0)(eslint@7.32.0)(typescript@5.3.3)
+ '@typescript-eslint/parser':
+ specifier: ^4.22.0
+ version: 4.33.0(eslint@7.32.0)(typescript@5.3.3)
+ base64-inline-loader:
+ specifier: ^1.1.1
+ version: 1.1.1(webpack@4.47.0)
+ bulma:
+ specifier: ^0.9.2
+ version: 0.9.4
+ bulma-checkbox:
+ specifier: ^1.1.1
+ version: 1.2.1
+ bulma-radio:
+ specifier: ^1.1.1
+ version: 1.2.0
+ bulma-responsive-tables:
+ specifier: ^1.2.3
+ version: 1.2.5
+ bulma-switch-control:
+ specifier: ^1.1.1
+ version: 1.2.2
+ bulma-timeline:
+ specifier: ^3.0.4
+ version: 3.0.5
+ bulma-upload-control:
+ specifier: ^1.2.0
+ version: 1.2.0
+ chai:
+ specifier: ^4.3.6
+ version: 4.3.6
+ dotenv:
+ specifier: ^8.2.0
+ version: 8.6.0
+ eslint:
+ specifier: ^7.25.0
+ version: 7.32.0
+ eslint-config-preact:
+ specifier: ^1.1.4
+ version: 1.3.0(@typescript-eslint/eslint-plugin@4.33.0)(eslint@7.32.0)(typescript@5.3.3)
+ eslint-plugin-header:
+ specifier: ^3.1.1
+ version: 3.1.1(eslint@7.32.0)
+ html-webpack-inline-chunk-plugin:
+ specifier: ^1.1.1
+ version: 1.1.1
+ html-webpack-inline-source-plugin:
+ specifier: 0.0.10
+ version: 0.0.10
+ html-webpack-skip-assets-plugin:
+ specifier: ^1.0.1
+ version: 1.0.3(html-webpack-plugin@5.5.4)(webpack@4.47.0)
+ inline-chunk-html-plugin:
+ specifier: ^1.1.1
+ version: 1.1.1
+ mocha:
+ specifier: ^9.2.0
+ version: 9.2.2
+ preact-render-to-string:
+ specifier: ^5.2.6
+ version: 5.2.6(preact@10.11.3)
+ sass:
+ specifier: 1.56.1
+ version: 1.56.1
+ source-map-support:
+ specifier: ^0.5.21
+ version: 0.5.21
+ typedoc:
+ specifier: ^0.25.4
+ version: 0.25.4(typescript@5.3.3)
+ typescript:
+ specifier: 5.3.3
+ version: 5.3.3
+
packages/anastasis-cli:
dependencies:
'@gnu-taler/anastasis-core':