@lystech/core 3.0.142 → 3.0.144

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.
package/dist/index.d.ts CHANGED
@@ -12,6 +12,28 @@ import { RefetchOptions } from '@tanstack/react-query';
12
12
  import { RefetchQueryFilters } from '@tanstack/react-query';
13
13
  import { UseQueryResult } from '@tanstack/react-query';
14
14
 
15
+ export declare type ActivePromotion = {
16
+ campaignUID: string;
17
+ name: string;
18
+ description: string | null;
19
+ discountLabel: string;
20
+ startsAt: string | null;
21
+ endsAt: string | null;
22
+ banner: boolean;
23
+ bannerText: string | null;
24
+ countdown: boolean;
25
+ badge: string | null;
26
+ scope: "all" | "selection";
27
+ collections: string[];
28
+ };
29
+
30
+ export declare type ActivePromotions = {
31
+ now: string;
32
+ campaigns: ActivePromotion[];
33
+ /** Par UID de produit : le prix promotionnel décidé par le serveur. */
34
+ products: Record<string, ProductPromotion>;
35
+ };
36
+
15
37
  export declare type AppliedPromoCodeType = {
16
38
  promoCodeObject: PromoCodeType;
17
39
  finalTotalPrice: number;
@@ -197,6 +219,9 @@ declare type AuthUserProfileProps = {
197
219
 
198
220
  export declare const axiosInstance: AxiosInstance;
199
221
 
222
+ /** Les campagnes à annoncer en bannière, pour cette collection (ou toute la boutique). */
223
+ export declare function bannersFor(data: ActivePromotions | null | undefined, collectionUID?: string | null): ActivePromotion[];
224
+
200
225
  export declare function BecomeMember({ title, intro, successUrl, cancelUrl, renderAction, onChoosePlan, onLoginRequired, }: BecomeMemberProps): JSX.Element | null;
201
226
 
202
227
  export declare type BecomeMemberProps = {
@@ -257,12 +282,28 @@ declare type BillProduct = {
257
282
  lastOrderedOn: string;
258
283
  };
259
284
 
260
- export declare function BirthdayForm({ title }: BirthdayFormProps): JSX.Element | null;
285
+ export declare function BirthdayForm({ title, onRequestChange }: BirthdayFormProps): JSX.Element | null;
261
286
 
262
287
  export declare type BirthdayFormProps = {
263
288
  title?: string;
289
+ /**
290
+ * « Demander une correction » (date déjà enregistrée). Défaut : ouvre le
291
+ * formulaire d'aide de la boutique, message pré-rempli (`openSupport`).
292
+ */
293
+ onRequestChange?: (current: {
294
+ day: number;
295
+ month: number;
296
+ year: number | null;
297
+ }) => void;
264
298
  };
265
299
 
300
+ /** « 17 avril 1992 », « 17 avril » sans année. */
301
+ export declare function birthdayText(d: {
302
+ day?: number;
303
+ month?: number;
304
+ year?: number | null;
305
+ } | null | undefined): string;
306
+
266
307
  declare interface CardItem {
267
308
  label: default_2.ReactNode;
268
309
  labelIcon?: default_2.ReactNode;
@@ -549,6 +590,8 @@ declare interface GenericCardProps {
549
590
  pending?: boolean;
550
591
  }
551
592
 
593
+ export declare function getActivePromotions(): Promise<ActivePromotions>;
594
+
552
595
  export declare function getFeaturedImages(): Promise<ImageType[]>;
553
596
 
554
597
  export declare function getLoyaltyRewards(): Promise<LoyaltyRewards>;
@@ -654,7 +697,7 @@ export declare type LoyaltyPlan = {
654
697
  stripePriceId: string | null;
655
698
  };
656
699
 
657
- export declare function LoyaltyPoints({ title, showRewards, historyPreview }: LoyaltyPointsProps): JSX.Element | null;
700
+ export declare function LoyaltyPoints({ title, showRewards, historyPreview, showHistory }: LoyaltyPointsProps): JSX.Element | null;
658
701
 
659
702
  export declare type LoyaltyPointsProps = {
660
703
  title?: string;
@@ -662,6 +705,12 @@ export declare type LoyaltyPointsProps = {
662
705
  showRewards?: boolean;
663
706
  /** Lignes d'historique visibles avant « Voir tout » (défaut : 8). */
664
707
  historyPreview?: number;
708
+ /**
709
+ * Montrer la liste « Historique » des mouvements (défaut : oui). Une boutique
710
+ * qui montre les points PAR COMMANDE dans l'historique de commandes
711
+ * (`OrderLoyaltyPoints`) peut la retirer : le solde et les récompenses restent.
712
+ */
713
+ showHistory?: boolean;
665
714
  };
666
715
 
667
716
  export declare type LoyaltyPointsSummary = {
@@ -711,7 +760,7 @@ export declare const LYSTECH_CORE_VERSION: any;
711
760
 
712
761
  export declare function lystechAuthRoutes(): JSX.Element[];
713
762
 
714
- declare function LystechCoreProvider({ children, organization, shouldRedirectAfterLogin, loginRedirectRoute, queryClient, usePushNotifications, useProgressiveWebAppFeatures, useThemeProvider, quickGoogleLoginButtonStyle, enableGoogleQuickLoginButton, showGoogleQuickLoginButton, useGoogleAutoSelect, debugMode, showAskPermissionsButtons, hideSupportButton, supportButtonVariant, onPackageUpdated, triggerOnFirstInstallPackageCallback, packageVersionStorageKey, }: Props): JSX.Element;
763
+ declare function LystechCoreProvider({ children, organization, shouldRedirectAfterLogin, loginRedirectRoute, queryClient, usePushNotifications, useProgressiveWebAppFeatures, useThemeProvider, quickGoogleLoginButtonStyle, enableGoogleQuickLoginButton, showGoogleQuickLoginButton, useGoogleAutoSelect, debugMode, showAskPermissionsButtons, hideSupportButton, supportButtonVariant, supportButtonPaths, onPackageUpdated, triggerOnFirstInstallPackageCallback, packageVersionStorageKey, }: Props): JSX.Element;
715
764
  export default LystechCoreProvider;
716
765
 
717
766
  export declare function LystechNotFoundPage({ homePath, homeLabel, }?: {
@@ -814,7 +863,10 @@ export declare type MyBirthday = {
814
863
  month?: number;
815
864
  day?: number;
816
865
  source: string | null;
866
+ /** Toujours null depuis la règle « saisie unique » (gardé pour compatibilité). */
817
867
  changeAllowedOn: string | null;
868
+ /** Une date existe : le client ne peut plus la changer (demande à l'aide). */
869
+ locked?: boolean;
818
870
  };
819
871
 
820
872
  export declare type MyLoyalty = {
@@ -838,16 +890,44 @@ export declare type MyLoyalty = {
838
890
  points: LoyaltyPointsSummary | null;
839
891
  };
840
892
 
893
+ export declare function openSupport(options?: OpenSupportOptions): boolean;
894
+
895
+ export declare type OpenSupportOptions = {
896
+ /** Texte placé dans le champ « message » (le client peut le modifier). */
897
+ message?: string;
898
+ };
899
+
841
900
  declare type OrderBreakdown = {
842
901
  products: {
843
902
  UID: string;
844
903
  name: string;
845
904
  productType: string;
846
905
  quantity: number;
906
+ /** Prix unitaire PAYÉ (promotionnel quand une campagne est retenue). */
847
907
  itemPrice: number;
848
908
  stackPrice: number;
909
+ /** Présents quand une campagne de promotion baisse le prix de la ligne. */
910
+ regularPrice?: number;
911
+ campaignUID?: string;
912
+ campaignName?: string;
913
+ campaignStacking?: "exclusive" | "stack";
849
914
  }[];
850
915
  totalPrice: number;
916
+ /** Campagnes de promotion retenues (déjà déduites du sous-total). */
917
+ appliedCampaigns?: {
918
+ campaignUID: string;
919
+ name: string;
920
+ savings: number;
921
+ stacking: "exclusive" | "stack";
922
+ }[];
923
+ campaignSavings?: number;
924
+ /** Un code ou un avantage plus avantageux a écarté la promotion (un seul rabais par commande). */
925
+ campaignNotApplied?: string;
926
+ /** Codes valides mais écartés, avec la raison. */
927
+ promoNotApplied?: {
928
+ code: string;
929
+ reason: string;
930
+ }[];
851
931
  totalItems: number;
852
932
  finalPriceWithoutShipping?: number;
853
933
  finalPriceIncludingShippingAndFees?: number;
@@ -882,6 +962,25 @@ declare type OrderBreakdown = {
882
962
  }[];
883
963
  };
884
964
 
965
+ /** « +50 points · utilisables le 26 octobre » ; « 25 points retirés (commande remboursée) ». */
966
+ export declare function OrderLoyaltyPoints({ billUID, className }: OrderLoyaltyPointsProps): JSX.Element | null;
967
+
968
+ export declare type OrderLoyaltyPointsProps = {
969
+ billUID: string;
970
+ className?: string;
971
+ };
972
+
973
+ export declare type OrderPoints = {
974
+ /** Points gagnés par cette commande (somme des gains). */
975
+ earned: number;
976
+ /** Points retirés (remboursement, annulation), en positif. */
977
+ reversed: number;
978
+ /** earned − reversed. */
979
+ net: number;
980
+ /** Gain encore en attente (délai de retour) : date où il devient utilisable. */
981
+ pendingUntil: string | null;
982
+ };
983
+
885
984
  export declare function OrderTrackingPage({ token: tokenProp, shopHref }: Props_4): JSX.Element;
886
985
 
887
986
  export declare type OrderTrackingStep = {
@@ -1056,6 +1155,17 @@ export declare type PostType = {
1056
1155
  fk_createdByAuthKey?: string;
1057
1156
  };
1058
1157
 
1158
+ declare type Priced = {
1159
+ UID?: any;
1160
+ itemPrice?: number;
1161
+ itemRealCost?: number;
1162
+ promo?: PromoInfo;
1163
+ /** Prix d'origine gardé pour défaire la promotion (idempotence). */
1164
+ promoBasePrice?: number;
1165
+ promoBaseRealCost?: number;
1166
+ [key: string]: any;
1167
+ };
1168
+
1059
1169
  declare interface ProductPopupProps {
1060
1170
  product: CartProduct & {
1061
1171
  variants?: any[];
@@ -1071,6 +1181,19 @@ declare interface ProductPopupProps {
1071
1181
  onClose: () => void;
1072
1182
  }
1073
1183
 
1184
+ export declare type ProductPromotion = {
1185
+ regularPrice: number;
1186
+ promoPrice: number;
1187
+ campaignUID: string;
1188
+ campaignName: string;
1189
+ /** Pastille (« -20 % ») ; null : la boutique n'en veut pas. */
1190
+ badge: string | null;
1191
+ /** Montrer le prix courant barré à côté du prix promotionnel. */
1192
+ strikethrough: boolean;
1193
+ endsAt: string | null;
1194
+ stacking: "exclusive" | "stack";
1195
+ };
1196
+
1074
1197
  declare type ProductProp = {
1075
1198
  prop_UID: string;
1076
1199
  prop_value_UID: string;
@@ -1098,6 +1221,29 @@ declare type ProgressiveWebAppContextType = {
1098
1221
  installProgressiveWebApp: () => Promise<void>;
1099
1222
  };
1100
1223
 
1224
+ /** La pastille d'un produit en promotion (« -20 % »). */
1225
+ export declare function PromoBadge({ label, className }: {
1226
+ label?: string | null;
1227
+ className?: string;
1228
+ }): JSX.Element | null;
1229
+
1230
+ export declare function PromoBanner({ promotion, onElapsed, className }: PromoBannerProps): JSX.Element | null;
1231
+
1232
+ export declare interface PromoBannerProps {
1233
+ promotion: Pick<ActivePromotion, "campaignUID" | "name" | "bannerText" | "discountLabel" | "endsAt" | "countdown">;
1234
+ onElapsed?: () => void;
1235
+ className?: string;
1236
+ }
1237
+
1238
+ /**
1239
+ * Les bannières des campagnes actives (celles que la boutique a choisi
1240
+ * d'annoncer), pour une collection ou toute la boutique. Rien sans campagne.
1241
+ */
1242
+ export declare function PromoBanners({ collectionUID, className }: {
1243
+ collectionUID?: string | null;
1244
+ className?: string;
1245
+ }): JSX.Element | null;
1246
+
1101
1247
  export declare function PromoCodeTag({ promoCode, showExpireInfo, onClick, isApplied, onRemove, }: Props_14): JSX.Element;
1102
1248
 
1103
1249
  export declare type PromoCodeType = {
@@ -1114,6 +1260,18 @@ export declare type PromoCodeType = {
1114
1260
  target: string;
1115
1261
  };
1116
1262
 
1263
+ export declare type PromoInfo = {
1264
+ campaignUID: string;
1265
+ campaignName: string;
1266
+ badge: string | null;
1267
+ endsAt: string | null;
1268
+ regularPrice: number;
1269
+ };
1270
+
1271
+ export declare const promotionKeys: {
1272
+ active: (org: string, user: string) => readonly ["promotions-active", string, string];
1273
+ };
1274
+
1117
1275
  declare type Props = {
1118
1276
  children: default_2.ReactNode;
1119
1277
  organization?: string;
@@ -1139,6 +1297,12 @@ declare type Props = {
1139
1297
  * droite). Meme paquet, meme rendu partout — sauf choix explicite.
1140
1298
  */
1141
1299
  supportButtonVariant?: SupportButtonVariant;
1300
+ /**
1301
+ * Pages ou le bouton d'aide est VISIBLE (prefixes d'adresse, ex.
1302
+ * `["/compte", "/panier"]`). Absent = partout (defaut inchange).
1303
+ * Ailleurs, `openSupport()` ouvre quand meme le formulaire.
1304
+ */
1305
+ supportButtonPaths?: string[];
1142
1306
  onPackageUpdated?: (event: PackageUpdateEvent) => void;
1143
1307
  triggerOnFirstInstallPackageCallback?: boolean;
1144
1308
  packageVersionStorageKey?: string;
@@ -1404,7 +1568,7 @@ export declare interface ShopCatalogCollection {
1404
1568
  [key: string]: any;
1405
1569
  }
1406
1570
 
1407
- export declare function ShopCatalogPage({ collections, selectedCollection, soldoutProductUIDs, renderProductCard, renderBanner, primaryColor, secondaryColor, itemsPerPage, defaultShowFilters, onCollectionClick, filtersText, allText, }: ShopCatalogPageProps): JSX.Element;
1571
+ export declare function ShopCatalogPage({ collections, selectedCollection, soldoutProductUIDs, renderProductCard, renderBanner, primaryColor, secondaryColor, itemsPerPage, defaultShowFilters, onCollectionClick, filtersText, allText, promotions, }: ShopCatalogPageProps): JSX.Element;
1408
1572
 
1409
1573
  export declare interface ShopCatalogPageProps {
1410
1574
  collections: ShopCatalogCollection[];
@@ -1419,6 +1583,14 @@ export declare interface ShopCatalogPageProps {
1419
1583
  onCollectionClick?: (collection: ShopCatalogCollection) => void;
1420
1584
  filtersText?: string;
1421
1585
  allText?: string;
1586
+ /**
1587
+ * Campagnes de promotion (défaut : oui). Chaque produit passé à
1588
+ * `renderProductCard` porte alors le prix décidé par le serveur
1589
+ * (`itemPrice` = prix promotionnel, `itemRealCost` = prix barré,
1590
+ * `promo.badge` = pastille), et les bannières s'affichent au-dessus.
1591
+ * Sans campagne active : rien ne change.
1592
+ */
1593
+ promotions?: boolean;
1422
1594
  }
1423
1595
 
1424
1596
  export declare interface ShopCatalogProduct {
@@ -1472,6 +1644,8 @@ declare type ShopProductCardProps = {
1472
1644
  keyUID: string;
1473
1645
  name: string;
1474
1646
  }[];
1647
+ /** Posé par withPromotion : campagne en cours (prix décidé par le serveur). */
1648
+ promo?: PromoInfo;
1475
1649
  };
1476
1650
  onClick?: () => void;
1477
1651
  };
@@ -1611,8 +1785,16 @@ export declare type SubscriptionSubscriber = {
1611
1785
  isGifted: boolean;
1612
1786
  };
1613
1787
 
1614
- export declare function SupportButton({ variant, }?: {
1788
+ export declare function summarizeOrderPoints(rows: LedgerRow[], now?: number): Map<string, OrderPoints>;
1789
+
1790
+ export declare function SupportButton({ variant, showOnPaths, }?: {
1615
1791
  variant?: SupportButtonVariant;
1792
+ /**
1793
+ * Pages ou le declencheur est VISIBLE (prefixes d'adresse : `/compte`
1794
+ * couvre `/compte/...`). Absent = partout (defaut inchange). Ailleurs, le
1795
+ * formulaire reste joignable par `openSupport()`.
1796
+ */
1797
+ showOnPaths?: string[];
1616
1798
  }): JSX.Element | null;
1617
1799
 
1618
1800
  /**
@@ -1793,6 +1975,14 @@ export declare const useInvitedToOrders: (email: string, organization?: string)
1793
1975
 
1794
1976
  export declare function useLoyaltyLedger(enabled?: boolean): UseQueryResult<LedgerRow[], unknown>;
1795
1977
 
1978
+ /** Points par commande (billUID → résumé), pour tout l'historique du client. */
1979
+ export declare function useLoyaltyPointsByOrder(enabled?: boolean): {
1980
+ enabled: boolean;
1981
+ label: string;
1982
+ byOrder: Map<string, OrderPoints>;
1983
+ loading: boolean;
1984
+ };
1985
+
1796
1986
  export declare function useLoyaltyRewards(enabled?: boolean): UseQueryResult<LoyaltyRewards, unknown>;
1797
1987
 
1798
1988
  export declare const useLystechPolitiqueAndConditions: () => UseQueryResult<PolitiqueAndConditionsType[], unknown>;
@@ -1844,6 +2034,13 @@ export declare const usePopup: () => ProviderType;
1844
2034
 
1845
2035
  export declare const useProgressiveWebApp: () => ProgressiveWebAppContextType;
1846
2036
 
2037
+ export declare function usePromotions(enabled?: boolean): {
2038
+ data: ActivePromotions | undefined;
2039
+ loading: boolean;
2040
+ error: unknown;
2041
+ refetch: () => void;
2042
+ };
2043
+
1847
2044
  export declare const usePushNotifications: () => PushNotificationContextType;
1848
2045
 
1849
2046
  /**
@@ -1896,6 +2093,13 @@ export declare const useUserRoleDetails: (authKey: string, organizationSubdomain
1896
2093
 
1897
2094
  export declare function validatePromoCode(code: string, products: any[]): Promise<AppliedPromoCodeType>;
1898
2095
 
2096
+ export declare function withPromotion<T extends Priced>(product: T, promos?: Record<string, ProductPromotion> | null): T;
2097
+
2098
+ /** Une collection (et les variantes de ses produits) aux prix de la promotion. */
2099
+ export declare function withPromotionsInCollection<C extends {
2100
+ products?: any[];
2101
+ } | undefined | null>(collection: C, data?: ActivePromotions | null): C;
2102
+
1899
2103
 
1900
2104
  export * from "@lystech/sections";
1901
2105