@commercelayer/app-elements 1.9.7 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ import type { Promotion } from '@commercelayer/sdk';
2
+ import type { DisplayStatus } from './types';
3
+ interface PromotionDisplayStatus extends DisplayStatus {
4
+ status: 'disabled' | 'active' | 'upcoming' | 'expired';
5
+ }
6
+ export declare function getPromotionDisplayStatus(promotion: Omit<Promotion, 'type'>): PromotionDisplayStatus;
7
+ export {};
@@ -74,6 +74,29 @@ export declare function getIsoDateAtDaysBefore({ isoString, days, timezone }: {
74
74
  days: number;
75
75
  timezone?: string;
76
76
  }): string | undefined;
77
+ /**
78
+ * Given the event date (`startsAt` and `expiresAt`) it returns whether the the event is `active`, `past` or `upcoming`.
79
+ */
80
+ export declare function getEventDateInfo({ startsAt, expiresAt, timezone }: {
81
+ /** The activation date/time of the event (ISO date string. Example '2022-10-06T11:59:30.371Z'). */
82
+ startsAt: DateISOString;
83
+ /** The expiration date/time of the promotion (must be after startsAt) (ISO date string. Example '2022-10-06T11:59:30.371Z'). */
84
+ expiresAt: DateISOString;
85
+ /** Set a specific timezone, when not passed default value is 'UTC' */
86
+ timezone?: string;
87
+ }): 'active' | 'past' | 'upcoming';
88
+ /**
89
+ * Format a date range as a nice string also specifying a custom timezone
90
+ * @returns a nice string representation. Example: '1-21 Jul, 2022' or 'Jul 21, 2022 - Jan 12, 2023'
91
+ */
92
+ export declare function formatDateRange({ rangeFrom, rangeTo, timezone }: {
93
+ /** JavaScript ISO date string. Example '2022-10-06T11:59:30.371Z' */
94
+ rangeFrom: DateISOString;
95
+ /** JavaScript ISO date string. Example '2022-11-06T11:59:30.371Z' */
96
+ rangeTo: DateISOString;
97
+ /** Set a specific timezone, when not passed default value is 'UTC' */
98
+ timezone?: string;
99
+ }): string;
77
100
  export interface Event {
78
101
  date: string;
79
102
  }