diff --git a/src/helpers/app.js b/src/helpers/app.js index 66e04a95..c552698f 100644 --- a/src/helpers/app.js +++ b/src/helpers/app.js @@ -187,7 +187,7 @@ export const unfreezeBody = () => { window.scrollTo(0, parseInt(scrollY || "0") * -1); }; -export const formatMoney = (price) => `${price.toFixed(2).replace(".", ",")}€`; +export const formatMoney = (price) => (price ? `${price.toFixed(2).replace(".", ",")}€` : ""); export const isBio = (tags) => { if (typeof tags === "string") return tags.indexOf("bio") > -1; diff --git a/src/routes/catalogs/AddProductModal.svelte b/src/routes/catalogs/AddProductModal.svelte index 55d90f25..0b57a385 100644 --- a/src/routes/catalogs/AddProductModal.svelte +++ b/src/routes/catalogs/AddProductModal.svelte @@ -19,7 +19,7 @@ ...$products, ...temp.map((r) => ({ ...r, - addedOn: Date.now(), + addedOn: null, })), ]; close(); @@ -44,8 +44,6 @@ ...p, checked: false, })); - - if (allProducts.length == 0) close(); }, error: () => close(), errorNotification: "Impossible de récupérer les informations des produits", @@ -53,29 +51,34 @@ }); $: hasSelectedAll = allProducts.filter((p) => !p.checked).length == 0; -

Choisir des produits à ajouter

-
toggleAll()}> -
- -
-

Tout sélectionner

-
- {#each allProducts as product} -
(product.checked = !product.checked)} - > + {#if allProducts.length > 0} +
toggleAll()}>
- +
-

{product.name}

+

Tout sélectionner

- {/each} - + {#each allProducts as product} +
(product.checked = !product.checked)} + > +
+ +
+

{product.name}

+
+ {/each} + + {:else} +

Vous ne possédez pas de produits.

+ + {/if}
diff --git a/src/routes/catalogs/CatalogForm.svelte b/src/routes/catalogs/CatalogForm.svelte index 06117e8d..4c439dfa 100644 --- a/src/routes/catalogs/CatalogForm.svelte +++ b/src/routes/catalogs/CatalogForm.svelte @@ -21,7 +21,6 @@ onDestroy(async () => { await form.destroy(); }); -
form.validateAndSubmit(submit)}> @@ -36,7 +35,7 @@ disabled={$form.isSubmitting} id="grid-product" type="text" - placeholder="Catalogue petits magasins été" + placeholder="Catalogue GMS" />
diff --git a/src/routes/catalogs/CatalogProducts.svelte b/src/routes/catalogs/CatalogProducts.svelte index 496cc0d5..5b856bed 100644 --- a/src/routes/catalogs/CatalogProducts.svelte +++ b/src/routes/catalogs/CatalogProducts.svelte @@ -15,7 +15,8 @@ errorsHandler; const routerInstance = GetRouterInstance(); - const { open, clearApolloCache } = getContext("modal"); + const { open } = getContext("modal"); + const { clearApolloCache } = getContext("api"); const headers = [ { label: "Nom", mobile: true }, @@ -59,9 +60,7 @@ }); $: $products = catalog.products; - $: invalidCatalogProducts = - $products.length == 0 || ($products.length > 0 && $products.filter((p) => !p.wholeSalePricePerUnit).length); - + $: invalidCatalogProducts = $products.length > 0 && $products.filter((p) => !p.wholeSalePricePerUnit).length; @@ -112,7 +111,9 @@ - {#if catalog.id && catalog.id.length > 0} + {#if catalog.id && catalog.id.length > 0 && $products.length > 0 && $products.filter((p) => !p.addedOn).length < 1}