Skip to content

Commit

Permalink
feat:insert empty page handling, adapt loading functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
suschneider committed Aug 29, 2024
1 parent e2fd252 commit cec66f0
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface RecurringOrdersState extends EntityState<RecurringOrder> {
error: HttpError;
}

const initialState: RecurringOrdersState = recurringOrdersAdapter.getInitialState({
export const initialState: RecurringOrdersState = recurringOrdersAdapter.getInitialState({
loading: false,
error: undefined,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { createSelector } from '@ngrx/store';
import { selectRouteParam } from 'ish-core/store/core/router';
import { getCustomerState } from 'ish-core/store/customer/customer-store';

import { recurringOrdersAdapter } from './recurring-orders.reducer';
import { initialState, recurringOrdersAdapter } from './recurring-orders.reducer';

const getRecurringOrdersState = createSelector(getCustomerState, state => state.recurringOrders);
const getRecurringOrdersState = createSelector(getCustomerState, state =>
state ? state.recurringOrders : initialState
);

export const getRecurringOrdersLoading = createSelector(getRecurringOrdersState, state => state.loading);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ <h1>{{ 'account.recurring_orders.heading' | translate }}</h1>

<ish-error-message [error]="recurringOrdersError$ | async" [toast]="false" />

<div class="loading-container">
<div class="recurring-orders">
<ng-container *ngIf="recurringOrders$ | async as recurringOrders">
<ish-recurring-order-list [recurringOrders]="recurringOrders" [columnsToDisplay]="columnsToDisplay" />
</ng-container>

<ish-loading *ngIf="recurringOrdersLoading$ | async" />
</div>

<ish-loading *ngIf="recurringOrdersLoading$ | async" />
Original file line number Diff line number Diff line change
@@ -1,112 +1,118 @@
<table
cdk-table
[dataSource]="recurringOrders"
class="table table-lg mobile-optimized"
data-testing-id="recurringOrder-list"
>
<!-- Recurring Order Number -->
<ng-container cdkColumnDef="recurringOrderNo">
<th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-recurringOrder-no">
{{ 'account.recurring_orders.table.id_of_order' | translate }}
</th>
<td
cdk-cell
*cdkCellDef="let recurringOrder"
[attr.data-label]="'account.recurring_orders.table.id_of_order' | translate"
>
<a
[routerLink]="['/account/recurring-orders/', recurringOrder.id]"
[attr.aria-label]="'account.recurring_orders.table.id_of_order.aria_label' | translate"
<ng-container *ngIf="recurringOrders?.length > 0; else emptyList">
<table
cdk-table
[dataSource]="recurringOrders"
class="table table-lg mobile-optimized"
data-testing-id="recurringOrder-list"
>
<!-- Recurring Order Number -->
<ng-container cdkColumnDef="recurringOrderNo">
<th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-recurringOrder-no">
{{ 'account.recurring_orders.table.id_of_order' | translate }}
</th>
<td
cdk-cell
*cdkCellDef="let recurringOrder"
[attr.data-label]="'account.recurring_orders.table.id_of_order' | translate"
>
{{ recurringOrder.number }}
</a>
</td>
</ng-container>
<a
[routerLink]="['/account/recurring-orders/', recurringOrder.id]"
[attr.aria-label]="'account.recurring_orders.table.id_of_order.aria_label' | translate"
>
{{ recurringOrder.number }}
</a>
</td>
</ng-container>

<!-- Creation Date -->
<ng-container cdkColumnDef="creationDate">
<th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-creation-date">
{{ 'account.recurring_orders.table.date_of_order' | translate }}
</th>
<td
cdk-cell
*cdkCellDef="let recurringOrder"
[attr.data-label]="'account.recurring_orders.table.date_of_order' | translate"
>
{{ recurringOrder.creationDate | ishDate }}
</td>
</ng-container>
<!-- Creation Date -->
<ng-container cdkColumnDef="creationDate">
<th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-creation-date">
{{ 'account.recurring_orders.table.date_of_order' | translate }}
</th>
<td
cdk-cell
*cdkCellDef="let recurringOrder"
[attr.data-label]="'account.recurring_orders.table.date_of_order' | translate"
>
{{ recurringOrder.creationDate | ishDate }}
</td>
</ng-container>

<!-- Frequency -->
<ng-container cdkColumnDef="frequency">
<th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-frequency">
{{ 'account.recurring_orders.table.order_frequency' | translate }}
</th>
<td
cdk-cell
*cdkCellDef="let recurringOrder"
[attr.data-label]="'account.recurring_orders.table.order_frequency' | translate"
>
{{ recurringOrder.recurrence.interval | ishFrequency }}
</td>
</ng-container>

<!-- Frequency -->
<ng-container cdkColumnDef="frequency">
<th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-frequency">
{{ 'account.recurring_orders.table.order_frequency' | translate }}
</th>
<td
cdk-cell
*cdkCellDef="let recurringOrder"
[attr.data-label]="'account.recurring_orders.table.order_frequency' | translate"
>
{{ recurringOrder.recurrence.interval | ishFrequency }}
</td>
</ng-container>
<!-- Last Order Date -->
<ng-container cdkColumnDef="lastOrderDate">
<th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-last-order-date">
{{ 'account.recurring_orders.table.last_order_date' | translate }}
</th>
<td
cdk-cell
*cdkCellDef="let recurringOrder"
[attr.data-label]="'account.recurring_orders.table.last_order_date' | translate"
>
{{ recurringOrder.lastOrderDate ? (recurringOrder.lastOrderDate | ishDate) : '-' }}
</td>
</ng-container>

<!-- Last Order Date -->
<ng-container cdkColumnDef="lastOrderDate">
<th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-last-order-date">
{{ 'account.recurring_orders.table.last_order_date' | translate }}
</th>
<td
cdk-cell
*cdkCellDef="let recurringOrder"
[attr.data-label]="'account.recurring_orders.table.last_order_date' | translate"
>
{{ recurringOrder.lastOrderDate ? (recurringOrder.lastOrderDate | ishDate) : '-' }}
</td>
</ng-container>
<!-- Next Order Date -->
<ng-container cdkColumnDef="nextOrderDate">
<th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-next-order-date">
{{ 'account.recurring_orders.table.next_order_date' | translate }}
</th>
<td
cdk-cell
*cdkCellDef="let recurringOrder"
[attr.data-label]="'account.recurring_orders.table.next_order_date' | translate"
>
{{ recurringOrder.nextOrderDate | ishDate }}
</td>
</ng-container>

<!-- Next Order Date -->
<ng-container cdkColumnDef="nextOrderDate">
<th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-next-order-date">
{{ 'account.recurring_orders.table.next_order_date' | translate }}
</th>
<td
cdk-cell
*cdkCellDef="let recurringOrder"
[attr.data-label]="'account.recurring_orders.table.next_order_date' | translate"
>
{{ recurringOrder.nextOrderDate | ishDate }}
</td>
</ng-container>
<!-- Order Total -->
<ng-container cdkColumnDef="orderTotal">
<th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-order-total" class="text-right">
{{ 'account.recurring_orders.table.order_total' | translate }}
</th>
<td
cdk-cell
*cdkCellDef="let recurringOrder"
[attr.data-label]="'account.recurring_orders.table.order_total' | translate"
class="column-price"
>
{{ recurringOrder.totals.total | ishPrice : 'gross' }}
</td>
</ng-container>

<!-- Order Total -->
<ng-container cdkColumnDef="orderTotal">
<th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-order-total" class="text-right">
{{ 'account.recurring_orders.table.order_total' | translate }}
</th>
<td
cdk-cell
*cdkCellDef="let recurringOrder"
[attr.data-label]="'account.recurring_orders.table.order_total' | translate"
class="column-price"
>
{{ recurringOrder.totals.total | ishPrice : 'gross' }}
</td>
</ng-container>
<!-- Actions -->
<ng-container cdkColumnDef="actions">
<th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-order-actions"></th>
<td cdk-cell *cdkCellDef="let recurringOrder" class="column-price text-nowrap">
<ish-switch
id="{{ recurringOrder.id }}"
[active]="recurringOrder.active"
(switchActiveStatus)="switchActiveStatus($event)"
/>
</td>
</ng-container>

<!-- Actions -->
<ng-container cdkColumnDef="actions">
<th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-order-actions"></th>
<td cdk-cell *cdkCellDef="let recurringOrder" class="column-price text-nowrap">
<ish-switch
id="{{ recurringOrder.id }}"
[active]="recurringOrder.active"
(switchActiveStatus)="switchActiveStatus($event)"
/>
</td>
</ng-container>
<!-- Header and Row Declarations -->
<tr cdk-header-row *cdkHeaderRowDef="columnsToDisplay"></tr>
<tr cdk-row *cdkRowDef="let row; columns: columnsToDisplay"></tr>
</table>
</ng-container>

<!-- Header and Row Declarations -->
<tr cdk-header-row *cdkHeaderRowDef="columnsToDisplay"></tr>
<tr cdk-row *cdkRowDef="let row; columns: columnsToDisplay"></tr>
</table>
<ng-template #emptyList>
<p data-testing-id="emptyList">{{ 'account.recurring_orders.no_placed_orders_message' | translate }}</p>
</ng-template>
1 change: 1 addition & 0 deletions src/assets/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@
"account.quotes.widget.view_all_quotes.link": "View all quotes",
"account.recurring_orders.heading": "Recurring orders",
"account.recurring_orders.navigation.link": "Recurring orders",
"account.recurring_orders.no_placed_orders_message": "You have not placed a recurring order yet.",
"account.recurring_orders.subtitle": "Your most recent recurring order appears first. Please allow up to 5 minutes for new orders to appear below.",
"account.recurring_orders.table.date_of_order": "Creation date",
"account.recurring_orders.table.id_of_order": "No.",
Expand Down

0 comments on commit cec66f0

Please sign in to comment.