gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant-backoffice] branch master updated (b28ef10 -> 68a315b)


From: gnunet
Subject: [taler-merchant-backoffice] branch master updated (b28ef10 -> 68a315b)
Date: Fri, 20 May 2022 18:47:15 +0200

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a change to branch master
in repository merchant-backoffice.

    from b28ef10  fix: add missing auto_refund
     new 9ac34bf  add remove image button
     new 9ee0648  undefined when there is no number
     new c4a7b72  fix: age as number
     new b72cca7  fix: allow 0
     new 68a315b  feat: add logo, email, website

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/components/form/InputImage.tsx                | 14 +++++++++++---
 .../src/components/form/InputNumber.tsx               |  2 +-
 .../components/instance/DefaultInstanceFormFields.tsx | 19 +++++++++++++++++++
 .../src/components/product/ProductForm.tsx            |  7 ++++---
 packages/merchant-backoffice/src/declaration.d.ts     |  6 ++++++
 packages/merchant-backoffice/src/schemas/index.ts     |  4 ++--
 6 files changed, 43 insertions(+), 9 deletions(-)

diff --git a/packages/merchant-backoffice/src/components/form/InputImage.tsx 
b/packages/merchant-backoffice/src/components/form/InputImage.tsx
index 55a6b66..6cc9b9d 100644
--- a/packages/merchant-backoffice/src/components/form/InputImage.tsx
+++ b/packages/merchant-backoffice/src/components/form/InputImage.tsx
@@ -50,7 +50,9 @@ export function InputImage<T>({ name, readonly, placeholder, 
tooltip, label, hel
     <div class="field-body is-flex-grow-3">
       <div class="field">
         <p class={expand ? "control is-expanded" : "control"}>
-          <img src={!value ? emptyImage : value} style={{ width: 200, height: 
200 }} onClick={() => image.current?.click()} />
+          {value &&
+            <img src={value} style={{ width: 200, height: 200 }} onClick={() 
=> image.current?.click()} />
+          }
           <input
             ref={image} style={{ display: 'none' }}
             type="file" name={String(name)}
@@ -58,11 +60,11 @@ export function InputImage<T>({ name, readonly, 
placeholder, tooltip, label, hel
             onChange={e => {
               const f: FileList | null = e.currentTarget.files
               if (!f || f.length != 1) {
-                return onChange(emptyImage)
+                return onChange(undefined!)
               }
               if (f[0].size > MAX_IMAGE_UPLOAD_SIZE) {
                 setSizeError(true)
-                return onChange(emptyImage)
+                return onChange(undefined!)
               }
               setSizeError(false)
               return f[0].arrayBuffer().then(b => {
@@ -80,6 +82,12 @@ export function InputImage<T>({ name, readonly, placeholder, 
tooltip, label, hel
         {sizeError && <p class="help is-danger">
           <Translate>Image should be smaller than 1 MB</Translate>
         </p>}
+        {!value &&
+          <button class="button" onClick={() => image.current?.click()} 
><Translate>Add</Translate></button>
+        }
+        {value &&
+          <button class="button" onClick={() => onChange(undefined!)} 
><Translate>Remove</Translate></button>
+        }
       </div>
     </div>
   </div>
diff --git a/packages/merchant-backoffice/src/components/form/InputNumber.tsx 
b/packages/merchant-backoffice/src/components/form/InputNumber.tsx
index ac36429..046cda5 100644
--- a/packages/merchant-backoffice/src/components/form/InputNumber.tsx
+++ b/packages/merchant-backoffice/src/components/form/InputNumber.tsx
@@ -31,7 +31,7 @@ export interface Props<T> extends InputProps<T> {
 
 export function InputNumber<T>({ name, readonly, placeholder, tooltip, label, 
help, expand, children, side }: Props<keyof T>) {
   return <InputWithAddon<T> name={name} readonly={readonly} 
-    fromStr={(v) => parseInt(v, 10)} toStr={(v) => `${v}`}
+    fromStr={(v) => !v ? undefined : parseInt(v, 10) } toStr={(v) => `${v}`}
     inputType='number' expand={expand}
     label={label} placeholder={placeholder} help={help} tooltip={tooltip}
     inputExtra={{ min: 0 }}
diff --git 
a/packages/merchant-backoffice/src/components/instance/DefaultInstanceFormFields.tsx
 
b/packages/merchant-backoffice/src/components/instance/DefaultInstanceFormFields.tsx
index 8c59a6d..d80c65c 100644
--- 
a/packages/merchant-backoffice/src/components/instance/DefaultInstanceFormFields.tsx
+++ 
b/packages/merchant-backoffice/src/components/instance/DefaultInstanceFormFields.tsx
@@ -27,6 +27,7 @@ import { Input } from "../form/Input";
 import { InputCurrency } from "../form/InputCurrency";
 import { InputDuration } from "../form/InputDuration";
 import { InputGroup } from "../form/InputGroup";
+import { InputImage } from "../form/InputImage";
 import { InputLocation } from "../form/InputLocation";
 import { InputPaytoForm } from "../form/InputPaytoForm";
 import { InputWithAddon } from "../form/InputWithAddon";
@@ -58,6 +59,24 @@ export function DefaultInstanceFormFields({
         tooltip={i18n`Legal name of the business represented by this 
instance.`}
       />
 
+      <Input<Entity>
+        name="email"
+        label={i18n`Email`}
+        tooltip={i18n`Contact email`}
+      />
+
+      <Input<Entity>
+        name="website"
+        label={i18n`Website URL`}
+        tooltip={i18n`URL.`}
+      />
+
+      <InputImage<Entity>
+        name="logo"
+        label={i18n`Logo`}
+        tooltip={i18n`Logo image.`}
+      />
+
       <InputPaytoForm<Entity>
         name="payto_uris"
         label={i18n`Bank account`}
diff --git 
a/packages/merchant-backoffice/src/components/product/ProductForm.tsx 
b/packages/merchant-backoffice/src/components/product/ProductForm.tsx
index e177caf..9434d3d 100644
--- a/packages/merchant-backoffice/src/components/product/ProductForm.tsx
+++ b/packages/merchant-backoffice/src/components/product/ProductForm.tsx
@@ -33,6 +33,7 @@ import { FormProvider, FormErrors } from 
"../form/FormProvider";
 import { Input } from "../form/Input";
 import { InputCurrency } from "../form/InputCurrency";
 import { InputImage } from "../form/InputImage";
+import { InputNumber } from "../form/InputNumber";
 import { InputStock, Stock } from "../form/InputStock";
 import { InputTaxes } from "../form/InputTaxes";
 import { InputWithAddon } from "../form/InputWithAddon";
@@ -51,8 +52,8 @@ export function ProductForm({ onSubscribe, initial, 
alreadyExist }: Props) {
     description_i18n: {},
     taxes: [],
     next_restock: { t_s: "never" },
-    ...initial,
     price: ":0",
+    ...initial,
     stock:
       !initial || initial.total_stock === -1
         ? undefined
@@ -143,9 +144,9 @@ export function ProductForm({ onSubscribe, initial, 
alreadyExist }: Props) {
           label={i18n`Description`}
           tooltip={i18n`product description for customers`}
         />
-        <Input<Entity>
+        <InputNumber<Entity>
           name="minimum_age"
-          label={i18n`Ages restricted`}
+          label={i18n`Age restricted`}
           tooltip={i18n`is this product restricted for customer below certain 
age?`}
         />
         <Input<Entity>
diff --git a/packages/merchant-backoffice/src/declaration.d.ts 
b/packages/merchant-backoffice/src/declaration.d.ts
index 9b06f8f..f0d257d 100644
--- a/packages/merchant-backoffice/src/declaration.d.ts
+++ b/packages/merchant-backoffice/src/declaration.d.ts
@@ -286,6 +286,12 @@ export namespace MerchantBackend {
             // Merchant name corresponding to this instance.
             name: string;
 
+            email: string;
+            website: string;
+            // An optional base64-encoded logo image
+            logo: ImageDataUrl;
+
+
             // "Authentication" header required to authorize management access 
the instance.
             // Optional, if not given authentication will be disabled for
             // this instance (hopefully authentication checks are still
diff --git a/packages/merchant-backoffice/src/schemas/index.ts 
b/packages/merchant-backoffice/src/schemas/index.ts
index 6901293..00e8019 100644
--- a/packages/merchant-backoffice/src/schemas/index.ts
+++ b/packages/merchant-backoffice/src/schemas/index.ts
@@ -170,7 +170,7 @@ export const ProductCreateSchema = yup.object().shape({
   stock: yup.object({
 
   }).optional(),
-  minimum_age: yup.number().optional().positive(),
+  minimum_age: yup.number().optional().min(0),
 })
 
 export const ProductUpdateSchema = yup.object().shape({
@@ -181,7 +181,7 @@ export const ProductUpdateSchema = yup.object().shape({
   stock: yup.object({
 
   }).optional(),
-  minimum_age: yup.number().optional().positive(),
+  minimum_age: yup.number().optional().min(0),
 })
 
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]