Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display dates that don't have a time specification #1582

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/core/models/cost-center/cost-center.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CostCenter } from './cost-center.model';
export type CostCenterData = Omit<CostCenter, 'orders'> & {
orders?: {
orderNo: string;
orderDate: number;
orderDate: number[];
orderStatus: string;
items: number;
buyer: { attributes: Attribute[] };
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/models/cost-center/cost-center.mapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ describe('Cost Center Mapper', () => {
{
orderNo: '1',
items: 2,
orderDate: 1234,
orderDate: [2024, 1, 10],
buyer: { attributes: [{ name: 'firstName', value: 'John' }] },
orderTotalGross: { currency: 'USD', value: 1000.23 },
orderTotalNet: { currency: 'USD', value: 800.87 },
},
{
orderNo: '2',
items: 4,
orderDate: 2341,
orderDate: [2024, 1, 10],
buyer: { attributes: [{ name: 'firstName', value: 'Jack' }] },
orderTotalGross: { currency: 'USD', value: 1000.23 },
orderTotalNet: { currency: 'USD', value: 800.87 },
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/models/cost-center/cost-center.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class CostCenterMapper {
orders: data.orders?.map(order => ({
documentNo: order.orderNo,
status: order.orderStatus,
creationDate: order.orderDate,
creationDate: order.orderDate.toString(),
attributes: order.buyer.attributes,
totalProductQuantity: order.items,
totals: {
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/models/order/order.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ShippingMethodData } from 'ish-core/models/shipping-method/shipping-met

export interface OrderBaseData extends BasketBaseData {
documentNumber: string;
creationDate: number;
creationDate: string;
orderCreation: {
status: 'COMPLETED' | 'ROLLED_BACK' | 'STOPPED' | 'CONTINUE';
stopAction?: {
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/models/order/order.mapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { OrderMapper } from './order.mapper';
describe('Order Mapper', () => {
const orderBaseData = {
documentNumber: '4711',
creationDate: 0,
creationDate: '2024-01-26T09:52:16Z',
status: 'New',
statusCode: 'NEW',
id: 'order_1234',
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/models/order/order.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type OrderBasket = Omit<AbstractBasket<OrderLineItem>, 'approval'>;

export interface Order extends OrderBasket {
documentNo: string;
creationDate: number;
creationDate: string;
orderCreation: {
status: 'COMPLETED' | 'ROLLED_BACK' | 'STOPPED' | 'CONTINUE';
stopAction?: {
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/pipes/date.pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ describe('Date Pipe', () => {
`('should transform $date to', ({ date, format, EN, DE }) => {
test(`${EN} with format ${format} for english local`, () => {
translateService.use('en');
expect(datePipe.transform(date, format)).toEqual(EN);
expect(datePipe.transform(date, format, '+0000')).toEqual(EN);
});
test(`${DE} with format ${format} for german locale`, () => {
translateService.use('de');
expect(datePipe.transform(date, format)).toEqual(DE);
expect(datePipe.transform(date, format, '+0000')).toEqual(DE);
});
});
});
3 changes: 2 additions & 1 deletion src/app/core/pipes/date.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export function formatISHDate(
} else {
date = value;
}
return formatDate(date, format, lang, timezone || '+0000');
// if no time zone is given take the user's current time zone
return formatDate(date, format, lang, timezone);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export interface OrderTemplateData extends OrderTemplateHeader {
itemsCount?: number;
name?: string;
uri?: string;
creationDate?: Date;
creationDate?: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface OrderTemplate extends OrderTemplateHeader {
id: string;
items?: OrderTemplateItem[];
itemsCount?: number;
creationDate?: Date;
creationDate?: number;
}

export interface OrderTemplateItem {
Expand Down
Loading