Skip to content

Commit

Permalink
fix(admin-ui): Order widget i18n fix
Browse files Browse the repository at this point in the history
* fix(admin-ui): I18n of buttons, add yesterday feat

* fix(admin-ui): I18n order widget cs

* Add missing comma in json
  • Loading branch information
chladog authored Jan 12, 2021
1 parent d18dab0 commit 68b8adb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@
</div>
</div>
<div class="footer">
<div class="btn-group btn-outline-primary btn-sm" *ngIf="timeframe$ | async as timeframe">
<button class="btn" [class.btn-primary]="timeframe === 'day'" (click)="timeframe$.next('day')">
Day
<div class="btn-group btn-outline-primary btn-sm" *ngIf="selection$ | async as selection">
<button class="btn" [class.btn-primary]="selection.date === today" (click)="selection$.next({timeframe: 'day', date: today})">
{{ 'dashboard.today' | translate }}
</button>
<button class="btn" [class.btn-primary]="timeframe === 'week'" (click)="timeframe$.next('week')">
Week
<button class="btn" [class.btn-primary]="selection.date === yesterday" (click)="selection$.next({timeframe: 'day', date: yesterday})">
{{ 'dashboard.yesterday' | translate }}
</button>
<button class="btn" [class.btn-primary]="timeframe === 'month'" (click)="timeframe$.next('month')">
Month
<button class="btn" [class.btn-primary]="selection.timeframe === 'week'" (click)="selection$.next({timeframe: 'week'})">
{{ 'dashboard.thisWeek' | translate }}
</button>
<button class="btn" [class.btn-primary]="selection.timeframe === 'month'" (click)="selection$.next({timeframe: 'month'})">
{{ 'dashboard.thisMonth' | translate }}
</button>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,26 @@ export type Timeframe = 'day' | 'week' | 'month';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class OrderSummaryWidgetComponent implements OnInit {
today = new Date();
yesterday = new Date(new Date().setDate(this.today.getDate() - 1));
totalOrderCount$: Observable<number>;
totalOrderValue$: Observable<number>;
currencyCode$: Observable<string | undefined>;
timeframe$ = new BehaviorSubject<Timeframe>('day');
selection$ = new BehaviorSubject<{ timeframe: Timeframe; date?: Date }>({
timeframe: 'day',
date: this.today,
});
dateRange$: Observable<{ start: Date; end: Date }>;

constructor(private dataService: DataService) {}

ngOnInit(): void {
this.dateRange$ = this.timeframe$.pipe(
this.dateRange$ = this.selection$.pipe(
distinctUntilChanged(),
map(timeframe => {
map(selection => {
return {
start: dayjs().startOf(timeframe).toDate(),
end: dayjs().endOf(timeframe).toDate(),
start: dayjs(selection.date).startOf(selection.timeframe).toDate(),
end: dayjs(selection.date).endOf(selection.timeframe).toDate(),
};
}),
shareReplay(1),
Expand Down
8 changes: 6 additions & 2 deletions packages/admin-ui/src/lib/static/i18n-messages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,14 @@
"latest-orders": "Poslední objednávky",
"orders-summary": "Souhrn objednávek",
"remove-widget": "Odebrat widget",
"thisMonth": "Tento měsíc",
"thisWeek": "Tento týden",
"today": "Dnes",
"total-order-value": "Celkem",
"total-orders": "Celkem objednávek",
"widget-resize": "Změnit velikost",
"widget-width": "Šířka: {width}"
"widget-width": "Šířka: {width}",
"yesterday": "Včera"
},
"datetime": {
"ago-days": "před {count, plural, one {1 dnem} other {{count} dny}}",
Expand Down Expand Up @@ -785,4 +789,4 @@
"job-result": "Výsledek úlohy",
"job-state": "Stav úlohy"
}
}
}
6 changes: 5 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,14 @@
"latest-orders": "Latest orders",
"orders-summary": "Orders summary",
"remove-widget": "Remove widget",
"thisMonth": "This month",
"thisWeek": "This week",
"today": "Today",
"total-order-value": "Total value",
"total-orders": "Total orders",
"widget-resize": "Resize",
"widget-width": "Width: {width}"
"widget-width": "Width: {width}",
"yesterday": "Yesterday"
},
"datetime": {
"ago-days": "{count, plural, one {1 day} other {{count} days}} ago",
Expand Down

0 comments on commit 68b8adb

Please sign in to comment.