Skip to content

Commit

Permalink
Fix - Correction de l'affichage des orders expirées
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmugnier committed Jun 11, 2021
1 parent 163afc9 commit 4f99e2b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 22 deletions.
7 changes: 3 additions & 4 deletions src/routes/my-orders/ListMyOrders.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import OrderStatus from "../../enums/OrderStatusKind";
import PageHeader from "../../components/PageHeader.svelte";
import PageBody from "../../components/PageBody.svelte";
import Actions from "../../components/table/Actions.svelte";
const errorsHandler = new SheaftErrors();
const { query } = getContext("api");
Expand All @@ -28,7 +27,7 @@
isLoading = true;
await query({
query: MY_ORDERS,
variables: { orderBy: { createdOn: OrderByDirection.DESC } },
variables: { orderBy: { createdOn: OrderByDirection.DESC }, first: 50 },
errorsHandler,
success: (res) => {
items.set(
Expand All @@ -38,7 +37,8 @@
p.status !== PurchaseOrderStatusKind.Cancelled.Value &&
p.status !== PurchaseOrderStatusKind.Withdrawned.Value &&
p.status !== PurchaseOrderStatusKind.Refused.Value &&
p.status !== PurchaseOrderStatusKind.Delivered.Value,
p.status !== PurchaseOrderStatusKind.Delivered.Value &&
p.status !== PurchaseOrderStatusKind.Expired.Value,
}))
);
},
Expand Down Expand Up @@ -93,7 +93,6 @@
});
$: hiddenNavigation = $items.filter((o) => !o.active).length < 1 || $items.filter((o) => o.active).length < 1;
</script>

<TransitionWrapper>
Expand Down
54 changes: 36 additions & 18 deletions src/routes/my-orders/MyOrderDetails.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
case PurchaseOrderStatusKind.Waiting.Value:
case PurchaseOrderStatusKind.Accepted.Value:
case PurchaseOrderStatusKind.Refused.Value:
case PurchaseOrderStatusKind.Expired.Value:
return 1;
case PurchaseOrderStatusKind.Processing.Value:
return 2;
Expand Down Expand Up @@ -77,7 +78,8 @@
order.status != PurchaseOrderStatusKind.Delivered.Value &&
order.status != PurchaseOrderStatusKind.Shipping.Value &&
order.status != PurchaseOrderStatusKind.Processing.Value &&
order.status != PurchaseOrderStatusKind.Refused.Value;
order.status != PurchaseOrderStatusKind.Refused.Value &&
order.status != PurchaseOrderStatusKind.Expired.Value;
</script>

<TransitionWrapper>
Expand All @@ -87,7 +89,21 @@
{isLoading}
loadingMessage="Récupération des informations de votre commande en cours... veuillez patienter."
>
{#if order.status == PurchaseOrderStatusKind.Cancelled.Value || order.status == PurchaseOrderStatusKind.Withdrawned.Value}
{#if order.status === PurchaseOrderStatusKind.Expired.Value}
<div
class="py-5 px-8 md:px-5 overflow-x-auto -mx-4 md:mx-0 bg-gray-100
shadow rounded mb-3"
>
<p class="uppercase font-bold leading-none">Commande expirée</p>
<div class="mt-2">
<p>La commande est expirée, vous ne pouvez plus interagir avec.</p>
{#if order.reason}
<p class="mt-2 font-semibold">Raison : {order.reason}</p>
{/if}
</div>
</div>
{/if}
{#if order.status === PurchaseOrderStatusKind.Cancelled.Value || order.status == PurchaseOrderStatusKind.Withdrawned.Value}
<div
class="py-5 px-8 md:px-5 overflow-x-auto -mx-4 md:mx-0 bg-gray-100
shadow rounded mb-3"
Expand All @@ -101,7 +117,7 @@
</div>
</div>
{/if}
{#if order.status == PurchaseOrderStatusKind.Refused.Value}
{#if order.status === PurchaseOrderStatusKind.Refused.Value}
<div
class="py-5 px-8 md:px-5 overflow-x-auto -mx-4 md:mx-0 bg-red-100
shadow rounded mb-3"
Expand Down Expand Up @@ -130,7 +146,7 @@
</div>
</div>
{/if}
{#if order.status == PurchaseOrderStatusKind.Shipping.Value}
{#if order.status === PurchaseOrderStatusKind.Shipping.Value}
<div
class="py-5 px-5 overflow-x-auto -mx-4 md:mx-0 bg-green-100 shadow
rounded mb-3"
Expand All @@ -141,7 +157,7 @@
</div>
</div>
{/if}
{#if order.status == PurchaseOrderStatusKind.Delivered.Value}
{#if order.status === PurchaseOrderStatusKind.Delivered.Value}
<div
class="py-5 px-5 overflow-x-auto -mx-4 md:mx-0 bg-green-100 shadow
rounded mb-3"
Expand All @@ -159,7 +175,7 @@
{/if}
</div>
{/if}
{#if order.status !== PurchaseOrderStatusKind.Refused.Value && order.status !== PurchaseOrderStatusKind.Cancelled.Value && order.status !== PurchaseOrderStatusKind.Withdrawned.Value && order.status !== PurchaseOrderStatusKind.Delivered.Value && order.expectedDelivery.expectedDeliveryDate}
{#if order.status !== PurchaseOrderStatusKind.Refused.Value && order.status !== PurchaseOrderStatusKind.Cancelled.Value && order.status !== PurchaseOrderStatusKind.Withdrawned.Value && order.status !== PurchaseOrderStatusKind.Delivered.Value && order.status !== PurchaseOrderStatusKind.Expired.Value && order.expectedDelivery.expectedDeliveryDate}
<div
class="py-5 px-5 overflow-x-auto -mx-4 md:mx-0 bg-white shadow
md:rounded md:mb-3 border-t md:border-none border-gray-400"
Expand Down Expand Up @@ -232,7 +248,7 @@
</div>
</div>
{/if}
{#if order.status !== PurchaseOrderStatusKind.Cancelled.Value && order.status !== PurchaseOrderStatusKind.Withdrawned.Value && order.status !== PurchaseOrderStatusKind.Refused.Value}
{#if order.status !== PurchaseOrderStatusKind.Cancelled.Value && order.status !== PurchaseOrderStatusKind.Withdrawned.Value && order.status !== PurchaseOrderStatusKind.Refused.Value && order.status !== PurchaseOrderStatusKind.Expired.Value}
<div
class="px-0 py-5 md:py-0 md:px-5 overflow-x-auto -mx-4 md:mx-0 bg-white
border-t md:border-l md:border-r border-gray-400"
Expand All @@ -247,7 +263,7 @@
{/if}
</div>
<div class="md-step-title text-xs md:text-base">
{#if order.status == PurchaseOrderStatusKind.Waiting.Value}En attente{:else}Acceptée{/if}
{order.status === PurchaseOrderStatusKind.Waiting.Value ? "En attente" : "Acceptée"}
</div>
<div class="md-step-bar-left hidden md:block" />
<div class="md-step-bar-right hidden md:block" />
Expand Down Expand Up @@ -316,7 +332,7 @@
{format(new Date(order.createdOn), "PPPPp", { locale: fr })}
</p>
</div>
{#if order.status == PurchaseOrderStatusKind.Delivered.Value}
{#if order.status === PurchaseOrderStatusKind.Delivered.Value}
<div class="flex items-center mb-2">
<p>
<span class="text-gray-600">Livrée le :</span>
Expand Down Expand Up @@ -497,17 +513,19 @@
</div>
</div>
</div>
<div class:hidden={!canCancelOrder} class="bg-white shadow md:rounded overflow-hidden md:mb-3 -mx-4 md:mx-0">
<div class="px-4 md:px-8 py-5">
<p class="uppercase font-bold">Annuler la commande</p>
<div class="mt-5">
<p>Vous pouvez annuler votre commande tant que celle-ci n'est pas en cours de préparation.</p>
<button on:click={cancelOrder} class="btn btn-lg btn-accent shadow mt-3 font-semibold">
Annuler ma commande
</button>
{#if canCancelOrder}
<div class="bg-white shadow md:rounded overflow-hidden md:mb-3 -mx-4 md:mx-0">
<div class="px-4 md:px-8 py-5">
<p class="uppercase font-bold">Annuler la commande</p>
<div class="mt-5">
<p>Vous pouvez annuler votre commande tant que celle-ci n'est pas en cours de préparation.</p>
<button on:click={cancelOrder} class="btn btn-lg btn-accent shadow mt-3 font-semibold">
Annuler ma commande
</button>
</div>
</div>
</div>
</div>
{/if}
</PageBody>
</TransitionWrapper>

Expand Down

0 comments on commit 4f99e2b

Please sign in to comment.