@salla.sa/twilight-components
Version:
Salla Web Component
38 lines (37 loc) • 2.53 kB
TypeScript
/**
* Helper functions for salla-bullet-delivery component
*/
import type { Branch, BulletDeliveryResult } from './interfaces';
/** First working-hours slot from API branch.working_hours[].times[]. */
export declare const getBranchFirstSlot: (workingHours: Branch["working_hours"]) => {
from: string;
to: string;
} | null;
/** Nearest available branch by distance; single pass O(n). */
export declare function findNearestBranch(branches: Branch[], userLat: number, userLon: number): Branch | null;
/** 24h time string → locale 12h (e.g. "23:55" → "11:55 PM"). */
export declare function formatTimeTo12h(time24: string, locale: string): string;
/** Working hours display: "until X" when from is 00:00, else "from - to" in 12h. */
export declare function formatWorkingHoursDisplay(from: string, to: string, locale: string, untilLabel: string): string;
export declare const filterBranches: (branches: Branch[], searchQuery: string) => Branch[];
export declare const getIntentSubtitle: (intent: BulletDeliveryResult, toAddress: string, fromBranch: string) => string;
export declare const getIntentCountryId: (i?: BulletDeliveryResult | null) => number;
export declare const getIntentCountryCode: (i?: BulletDeliveryResult | null) => string;
export declare const getIntentRegionId: (i?: BulletDeliveryResult | null) => number;
export declare const getIntentCityId: (i?: BulletDeliveryResult | null) => number;
export declare const getIntentDistrictId: (i?: BulletDeliveryResult | null) => number;
export declare const getIntentBranchId: (i?: BulletDeliveryResult | null) => number;
/** Intent coordinates (branch tab only; address flow no longer uses coordinates). */
export declare const getIntentLatitude: (i?: BulletDeliveryResult | null) => number;
export declare const getIntentLongitude: (i?: BulletDeliveryResult | null) => number;
export declare const hasSessionAddressIntent: (intent: BulletDeliveryResult | null) => boolean;
export declare const requireRegionAndDistrictForSA: (countryCode: string | undefined | null, regionId?: number | string | null, districtIdOrName?: number | string | null) => boolean;
export declare function buildAddressLocationPayloadFromSelection(options: {
cityId?: number | string | null;
regionId?: number | string | null;
countryId: number | string;
districtId?: number | string | null;
countryCode?: string | null;
description?: string | null;
}): Record<string, unknown>;
export declare const getGeolocationErrorMessage: (errorCode: number) => string;