diff options
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/instance/products/list/index.tsx')
-rw-r--r-- | packages/merchant-backoffice-ui/src/paths/instance/products/list/index.tsx | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/products/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/products/list/index.tsx index 85c50e5ed..274a7c2ea 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/products/list/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/products/list/index.tsx @@ -53,7 +53,7 @@ export default function ProductList({ onNotFound, }: Props): VNode { const result = useInstanceProducts(); - const { deleteProduct, updateProduct } = useProductAPI(); + const { deleteProduct, updateProduct, getProduct } = useProductAPI(); const [deleting, setDeleting] = useState<MerchantBackend.Products.ProductDetail & WithId | null>(null); const [notif, setNotif] = useState<Notification | undefined>(undefined); @@ -74,11 +74,61 @@ export default function ProductList({ return onNotFound(); return onLoadError(result); } + const [errorId, setErrorId] = useState<string | undefined>( + undefined, + ); + + const [productId, setProductId] = useState<string>() + async function testIfProductExistAndSelect(orderId: string | undefined): Promise<void> { + if (!orderId) { + setErrorId(i18n.str`Enter a product id`); + return; + } + try { + await getProduct(orderId); + onSelect(orderId); + setErrorId(undefined); + } catch { + setErrorId(i18n.str`product not found`); + } + } return ( <section class="section is-main-section"> <NotificationCard notification={notif} /> + <div class="level"> + <div class="level-left"> + <div class="level-item"> + <div class="field has-addons"> + <div class="control"> + <input + class={errorId ? "input is-danger" : "input"} + type="text" + value={productId ?? ""} + onChange={(e) => setProductId(e.currentTarget.value)} + placeholder={i18n.str`product id`} + /> + {errorId && <p class="help is-danger">{errorId}</p>} + </div> + <span + class="has-tooltip-bottom" + data-tooltip={i18n.str`jump to product with the given product ID`} + > + <button + class="button" + onClick={(e) => testIfProductExistAndSelect(productId)} + > + <span class="icon"> + <i class="mdi mdi-arrow-right" /> + </span> + </button> + </span> + </div> + </div> + </div> + </div> + <CardTable instances={result.data} onCreate={onCreate} |