diff options
author | Sebastian <sebasjm@gmail.com> | 2021-04-14 17:10:48 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2021-04-14 17:10:53 -0300 |
commit | 14b76f2c318bf483bd7534c8761aec720d067532 (patch) | |
tree | 6c26ae7f36c58dc71b64da3443654fee210854d4 /packages/frontend/src/paths/instance/products/update/UpdatePage.tsx | |
parent | dd03dc5877bbeca17efb4dc5007f62a7dd90eb16 (diff) | |
download | merchant-backoffice-14b76f2c318bf483bd7534c8761aec720d067532.tar.gz merchant-backoffice-14b76f2c318bf483bd7534c8761aec720d067532.tar.bz2 merchant-backoffice-14b76f2c318bf483bd7534c8761aec720d067532.zip |
create and update product form
Diffstat (limited to 'packages/frontend/src/paths/instance/products/update/UpdatePage.tsx')
-rw-r--r-- | packages/frontend/src/paths/instance/products/update/UpdatePage.tsx | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/packages/frontend/src/paths/instance/products/update/UpdatePage.tsx b/packages/frontend/src/paths/instance/products/update/UpdatePage.tsx new file mode 100644 index 0000000..40319a8 --- /dev/null +++ b/packages/frontend/src/paths/instance/products/update/UpdatePage.tsx @@ -0,0 +1,63 @@ +/* + This file is part of GNU Taler + (C) 2021 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 + Foundation; either version 3, or (at your option) any later version. + + GNU Taler 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +/** +* +* @author Sebastian Javier Marchano (sebasjm) +*/ + +import { h, VNode } from "preact"; +import { MerchantBackend, WithId } from "../../../../declaration"; +import { Message } from "preact-messages"; +import { ProductForm } from "../../../../components/product/ProductForm"; +import { useListener } from "../../../../hooks"; + +type Entity = MerchantBackend.Products.ProductPatchDetail & WithId + +interface Props { + onUpdate: (d: Entity) => void; + onBack?: () => void; + product: Entity; +} + +export function UpdatePage({ product, onUpdate, onBack }: Props): VNode { + const [submitForm, addFormSubmitter] = useListener<Entity | undefined>((result) => { + if (result) onUpdate(result) + }) + + return <div> + <section class="section is-main-section"> + <div class="columns"> + <div class="column" /> + <div class="column is-two-thirds"> + <ProductForm initial={product} onSubscribe={(a) => { + addFormSubmitter(() => { + const p = a() + return p as any + }) + }} /> + + <div class="buttons is-right mt-5"> + {onBack && <button class="button" onClick={onBack} ><Message id="Cancel" /></button>} + <button class="button is-success" onClick={submitForm} ><Message id="Confirm" /></button> + </div> + + </div> + <div class="column" /> + </div> + </section> + </div> +}
\ No newline at end of file |