Skip to content

Commit

Permalink
DLF332 - Correction de la récupération du panier enregistré
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmugnier committed Jun 16, 2021
1 parent 4f99e2b commit a83e409
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 149 deletions.
16 changes: 7 additions & 9 deletions src/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@
if (initialized) {
isLoading = false;
if (!authInstance.isInRole([Roles.Store.Value, Roles.Producer.Value])) {
await cart.initialize({ query, mutate }, errorsHandlers, authInstance.authenticated, $authRegistered);
}
if (!authInstance.isInRole([Roles.Store.Value, Roles.Producer.Value]))
await cart.initialize({ query, mutate }, errorsHandlers, authInstance.authenticated);
}
});
Expand All @@ -59,6 +58,9 @@
signalrInstance.start();
await loginFreshdesk();
if (!authInstance.isInRole([Roles.Store.Value, Roles.Producer.Value]))
await cart.initialize({ query, mutate }, errorsHandlers, authInstance.authenticated);
await query({
query: GET_UNREAD_NOTIFICATIONS_COUNT,
errorsHandler: errorsHandlers,
Expand All @@ -73,12 +75,8 @@
}
});
window.addEventListener("beforeinstallprompt", (e) => {});
window.addEventListener("appinstalled", (evt) => {
//TODO: register user points
});
window.addEventListener("beforeinstallprompt", () => {});
window.addEventListener("appinstalled", () => {});
window.addEventListener("load", () => {});
onMount(async () => {
Expand Down
12 changes: 2 additions & 10 deletions src/components/controls/ProductCartQuantity.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
let quantity = 0;
let displayFeedback = false;
$: isDisabled = disabled || $cart.isSaving || $cart.conflicts.length > 0;
$: product = $cart.products.find((i) => i.id == productId);
$: product = $cart.products.filter((p) => p.producer).find((i) => i.id === productId);
onMount(() => {
displayFeedback = false;
Expand Down Expand Up @@ -54,13 +54,7 @@
// avant l'exécution de la fonction, alors productId n'est plus défini. On passe donc directement la valeur de productId
// à la fonction comme paramètre pour éviter un problème lié à un unmount triggered "trop tôt"
const updateProductQuantity = debounce(async (quantity, _productId) => {
const hasUpdatedProductInCart = await cart.updateProduct(_productId, quantity);
if (!hasUpdatedProductInCart) {
quantity = 0;
disabled = true;
}
await cart.updateProduct(_productId, quantity);
if (userFeedback) triggerFeedback();
}, 800);
Expand All @@ -77,7 +71,6 @@
// reset de la quantité
$: if (!productId) quantity = 0;
$: product ? (quantity = product.quantity) : (quantity = 0);
</script>

<div class="m-auto {!noMargin ? 'lg:mt-4 lg:mb-4' : ''}">
Expand Down Expand Up @@ -184,5 +177,4 @@
input[type="number"] {
-moz-appearance: textfield;
}
</style>
2 changes: 1 addition & 1 deletion src/routes/search-products/Cart.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
>
</div>
{:else}
{#each $cart.products as line (line.id)}
{#each $cart.products.filter((p) => p.producer) as line (line.id)}
<div
transition:fly|local={{ duration: 300 }}
animate:flip={{ duration: 300 }}
Expand Down
3 changes: 1 addition & 2 deletions src/services/SheaftAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
authAuthorized,
} from "./../stores/auth.js";
import { clearLocalStorage } from "./../helpers/storage";
import { stringify } from "qs";

class SheaftAuth {
constructor(oidcSettings) {
Expand Down Expand Up @@ -151,7 +150,7 @@ class SheaftAuth {
}

isInRole(roles) {
if (!roles || !this.authenticated) return false;
if (!roles) return false;

var rolesToTest = [];
if (!Array.isArray(roles)) rolesToTest = [roles];
Expand Down
Loading

0 comments on commit a83e409

Please sign in to comment.