@scayle/storefront-core
Version:
Collection of essential utilities to work with the Storefront API
39 lines (38 loc) • 1.51 kB
TypeScript
import type { Campaign } from '@scayle/storefront-api';
/**
* Checks if a given campaign is currently active.
*
* Determines if the current time falls within the campaign's start and end dates.
*
* @see https://scayle.dev/en/core-documentation/checkout-guide/features/promotions/discounts-and-offers/price-campaigns
*
* @param campaign The campaign to check.
*
* @returns True if the campaign is active, false otherwise.
*/
export declare const isCampaignActive: (campaign?: Campaign) => boolean;
/**
* Checks if a given campaign has not yet ended.
*
* Compares the campaign's end date with the current time.
*
* @see https://scayle.dev/en/core-documentation/checkout-guide/features/promotions/discounts-and-offers/price-campaigns
*
* @param campaign The campaign to check.
*
* @returns True if the campaign has not ended, false otherwise.
*/
export declare const campaignHasNotEnded: (campaign: Campaign) => boolean;
/**
* Sorts campaigns by their start date in ascending order.
*
* Uses the difference between start times to determine order.
*
* @see https://scayle.dev/en/core-documentation/checkout-guide/features/promotions/discounts-and-offers/price-campaigns
*
* @param a The first campaign to compare.
* @param b The second campaign to compare.
*
* @returns A negative number if `a` starts before `b`, a positive number if `a` starts after `b`, and 0 if they start at the same time.
*/
export declare const sortCampaignsByDateAscending: (a: Campaign, b: Campaign) => number;