From cf7f819685c19adfe6443a6bdd10f3afe10b247d Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 19 Dec 2022 16:25:09 -0300 Subject: templates --- .../src/paths/instance/orders/list/index.tsx | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'packages/merchant-backoffice-ui/src/paths/instance/orders') diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx index b5fe7611c..315d78c63 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx @@ -23,7 +23,7 @@ import { h, VNode, Fragment } from "preact"; import { useState } from "preact/hooks"; import { Loading } from "../../../../components/exception/loading.js"; import { NotificationCard } from "../../../../components/menu/index.js"; -import { MerchantBackend, WithId } from "../../../../declaration.js"; +import { MerchantBackend } from "../../../../declaration.js"; import { HttpError } from "../../../../hooks/backend.js"; import { InstanceOrderFilter, @@ -44,7 +44,7 @@ interface Props { onCreate: () => void; } -export default function ({ +export default function OrderList({ onUnauthorized, onLoadError, onCreate, @@ -56,13 +56,19 @@ export default function ({ MerchantBackend.Orders.OrderHistoryEntry | undefined >(undefined); - const setNewDate = (date?: Date) => setFilter((prev) => ({ ...prev, date })); + const setNewDate = (date?: Date): void => + setFilter((prev) => ({ ...prev, date })); const result = useInstanceOrders(filter, setNewDate); const { refundOrder, getPaymentURL } = useOrderAPI(); const [notif, setNotif] = useState(undefined); + const i18n = useTranslator(); + const [errorOrderId, setErrorOrderId] = useState( + undefined, + ); + if (result.clientError && result.isUnauthorized) return onUnauthorized(); if (result.clientError && result.isNotfound) return onNotFound(); if (result.loading) return ; @@ -78,12 +84,7 @@ export default function ({ ? "is-active" : ""; - const i18n = useTranslator(); - const [errorOrderId, setErrorOrderId] = useState( - undefined, - ); - - async function testIfOrderExistAndSelect(orderId: string) { + async function testIfOrderExistAndSelect(orderId: string): Promise { if (!orderId) { setErrorOrderId(i18n`Enter an order id`); return; @@ -189,7 +190,7 @@ function RefundModalForTable({ onNotFound, onConfirm, onCancel, -}: RefundProps) { +}: RefundProps): VNode { const result = useOrderDetails(id); if (result.clientError && result.isUnauthorized) return onUnauthorized(); @@ -206,6 +207,6 @@ function RefundModalForTable({ ); } -async function copyToClipboard(text: string) { +async function copyToClipboard(text: string): Promise { return navigator.clipboard.writeText(text); } -- cgit v1.2.3