@lystech/core 3.0.141 → 3.0.143

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 = {
@@ -549,6 +574,8 @@ declare interface GenericCardProps {
549
574
  pending?: boolean;
550
575
  }
551
576
 
577
+ export declare function getActivePromotions(): Promise<ActivePromotions>;
578
+
552
579
  export declare function getFeaturedImages(): Promise<ImageType[]>;
553
580
 
554
581
  export declare function getLoyaltyRewards(): Promise<LoyaltyRewards>;
@@ -844,10 +871,31 @@ declare type OrderBreakdown = {
844
871
  name: string;
845
872
  productType: string;
846
873
  quantity: number;
874
+ /** Prix unitaire PAYÉ (promotionnel quand une campagne est retenue). */
847
875
  itemPrice: number;
848
876
  stackPrice: number;
877
+ /** Présents quand une campagne de promotion baisse le prix de la ligne. */
878
+ regularPrice?: number;
879
+ campaignUID?: string;
880
+ campaignName?: string;
881
+ campaignStacking?: "exclusive" | "stack";
849
882
  }[];
850
883
  totalPrice: number;
884
+ /** Campagnes de promotion retenues (déjà déduites du sous-total). */
885
+ appliedCampaigns?: {
886
+ campaignUID: string;
887
+ name: string;
888
+ savings: number;
889
+ stacking: "exclusive" | "stack";
890
+ }[];
891
+ campaignSavings?: number;
892
+ /** Un code ou un avantage plus avantageux a écarté la promotion (un seul rabais par commande). */
893
+ campaignNotApplied?: string;
894
+ /** Codes valides mais écartés, avec la raison. */
895
+ promoNotApplied?: {
896
+ code: string;
897
+ reason: string;
898
+ }[];
851
899
  totalItems: number;
852
900
  finalPriceWithoutShipping?: number;
853
901
  finalPriceIncludingShippingAndFees?: number;
@@ -987,7 +1035,7 @@ export declare type PackageUpdateEvent = {
987
1035
 
988
1036
  export declare function PastOrdersPage({ billUID, onCollectionInvitationClick }: Props_3): JSX.Element;
989
1037
 
990
- export declare function PaypalCheckout({ products, promoCodes, shippingOptionId, onOrderCreated, onOrderComplete, onShipppingOptionsChange: onShippingOptionsChangeEvent, onInstrumentDeclined, onError, }: Props_7): JSX.Element;
1038
+ export declare function PaypalCheckout({ products, promoCodes, shippingOptionId, intent, useStoreCredit, onOrderCreated, onOrderComplete, onShipppingOptionsChange: onShippingOptionsChangeEvent, onInstrumentDeclined, onError, }: Props_7): JSX.Element;
991
1039
 
992
1040
  export declare type PaypalInfoType = {
993
1041
  clientId: string;
@@ -1056,6 +1104,17 @@ export declare type PostType = {
1056
1104
  fk_createdByAuthKey?: string;
1057
1105
  };
1058
1106
 
1107
+ declare type Priced = {
1108
+ UID?: any;
1109
+ itemPrice?: number;
1110
+ itemRealCost?: number;
1111
+ promo?: PromoInfo;
1112
+ /** Prix d'origine gardé pour défaire la promotion (idempotence). */
1113
+ promoBasePrice?: number;
1114
+ promoBaseRealCost?: number;
1115
+ [key: string]: any;
1116
+ };
1117
+
1059
1118
  declare interface ProductPopupProps {
1060
1119
  product: CartProduct & {
1061
1120
  variants?: any[];
@@ -1071,6 +1130,19 @@ declare interface ProductPopupProps {
1071
1130
  onClose: () => void;
1072
1131
  }
1073
1132
 
1133
+ export declare type ProductPromotion = {
1134
+ regularPrice: number;
1135
+ promoPrice: number;
1136
+ campaignUID: string;
1137
+ campaignName: string;
1138
+ /** Pastille (« -20 % ») ; null : la boutique n'en veut pas. */
1139
+ badge: string | null;
1140
+ /** Montrer le prix courant barré à côté du prix promotionnel. */
1141
+ strikethrough: boolean;
1142
+ endsAt: string | null;
1143
+ stacking: "exclusive" | "stack";
1144
+ };
1145
+
1074
1146
  declare type ProductProp = {
1075
1147
  prop_UID: string;
1076
1148
  prop_value_UID: string;
@@ -1098,6 +1170,29 @@ declare type ProgressiveWebAppContextType = {
1098
1170
  installProgressiveWebApp: () => Promise<void>;
1099
1171
  };
1100
1172
 
1173
+ /** La pastille d'un produit en promotion (« -20 % »). */
1174
+ export declare function PromoBadge({ label, className }: {
1175
+ label?: string | null;
1176
+ className?: string;
1177
+ }): JSX.Element | null;
1178
+
1179
+ export declare function PromoBanner({ promotion, onElapsed, className }: PromoBannerProps): JSX.Element | null;
1180
+
1181
+ export declare interface PromoBannerProps {
1182
+ promotion: Pick<ActivePromotion, "campaignUID" | "name" | "bannerText" | "discountLabel" | "endsAt" | "countdown">;
1183
+ onElapsed?: () => void;
1184
+ className?: string;
1185
+ }
1186
+
1187
+ /**
1188
+ * Les bannières des campagnes actives (celles que la boutique a choisi
1189
+ * d'annoncer), pour une collection ou toute la boutique. Rien sans campagne.
1190
+ */
1191
+ export declare function PromoBanners({ collectionUID, className }: {
1192
+ collectionUID?: string | null;
1193
+ className?: string;
1194
+ }): JSX.Element | null;
1195
+
1101
1196
  export declare function PromoCodeTag({ promoCode, showExpireInfo, onClick, isApplied, onRemove, }: Props_14): JSX.Element;
1102
1197
 
1103
1198
  export declare type PromoCodeType = {
@@ -1114,6 +1209,18 @@ export declare type PromoCodeType = {
1114
1209
  target: string;
1115
1210
  };
1116
1211
 
1212
+ export declare type PromoInfo = {
1213
+ campaignUID: string;
1214
+ campaignName: string;
1215
+ badge: string | null;
1216
+ endsAt: string | null;
1217
+ regularPrice: number;
1218
+ };
1219
+
1220
+ export declare const promotionKeys: {
1221
+ active: (org: string, user: string) => readonly ["promotions-active", string, string];
1222
+ };
1223
+
1117
1224
  declare type Props = {
1118
1225
  children: default_2.ReactNode;
1119
1226
  organization?: string;
@@ -1243,6 +1350,15 @@ declare type Props_7 = {
1243
1350
  promoCodes?: string[];
1244
1351
  /** Option de livraison choisie dans le panier (devient celle de l'ordre PayPal). */
1245
1352
  shippingOptionId?: number | string | null;
1353
+ /**
1354
+ * « capture » (défaut) : prélevé au paiement. « authorize » : la boutique
1355
+ * prélève à l'envoi — PayPal RETIENT les fonds, Lystech prélève plus tard.
1356
+ * Vient de GET /shop/payment-methods (paypalIntent) : le SDK et l'ordre
1357
+ * doivent avoir le même intent, sinon PayPal refuse l'approbation.
1358
+ */
1359
+ intent?: "capture" | "authorize";
1360
+ /** Crédit boutique appliqué au panier : PayPal ne prend que le reste. */
1361
+ useStoreCredit?: boolean;
1246
1362
  onOrderCreated?: (orderId: string) => void;
1247
1363
  onOrderComplete?: (orderId: string) => void;
1248
1364
  onShipppingOptionsChange?: (orderId: string, selectedShippingOption: {
@@ -1395,7 +1511,7 @@ export declare interface ShopCatalogCollection {
1395
1511
  [key: string]: any;
1396
1512
  }
1397
1513
 
1398
- export declare function ShopCatalogPage({ collections, selectedCollection, soldoutProductUIDs, renderProductCard, renderBanner, primaryColor, secondaryColor, itemsPerPage, defaultShowFilters, onCollectionClick, filtersText, allText, }: ShopCatalogPageProps): JSX.Element;
1514
+ export declare function ShopCatalogPage({ collections, selectedCollection, soldoutProductUIDs, renderProductCard, renderBanner, primaryColor, secondaryColor, itemsPerPage, defaultShowFilters, onCollectionClick, filtersText, allText, promotions, }: ShopCatalogPageProps): JSX.Element;
1399
1515
 
1400
1516
  export declare interface ShopCatalogPageProps {
1401
1517
  collections: ShopCatalogCollection[];
@@ -1410,6 +1526,14 @@ export declare interface ShopCatalogPageProps {
1410
1526
  onCollectionClick?: (collection: ShopCatalogCollection) => void;
1411
1527
  filtersText?: string;
1412
1528
  allText?: string;
1529
+ /**
1530
+ * Campagnes de promotion (défaut : oui). Chaque produit passé à
1531
+ * `renderProductCard` porte alors le prix décidé par le serveur
1532
+ * (`itemPrice` = prix promotionnel, `itemRealCost` = prix barré,
1533
+ * `promo.badge` = pastille), et les bannières s'affichent au-dessus.
1534
+ * Sans campagne active : rien ne change.
1535
+ */
1536
+ promotions?: boolean;
1413
1537
  }
1414
1538
 
1415
1539
  export declare interface ShopCatalogProduct {
@@ -1463,6 +1587,8 @@ declare type ShopProductCardProps = {
1463
1587
  keyUID: string;
1464
1588
  name: string;
1465
1589
  }[];
1590
+ /** Posé par withPromotion : campagne en cours (prix décidé par le serveur). */
1591
+ promo?: PromoInfo;
1466
1592
  };
1467
1593
  onClick?: () => void;
1468
1594
  };
@@ -1835,6 +1961,13 @@ export declare const usePopup: () => ProviderType;
1835
1961
 
1836
1962
  export declare const useProgressiveWebApp: () => ProgressiveWebAppContextType;
1837
1963
 
1964
+ export declare function usePromotions(enabled?: boolean): {
1965
+ data: ActivePromotions | undefined;
1966
+ loading: boolean;
1967
+ error: unknown;
1968
+ refetch: () => void;
1969
+ };
1970
+
1838
1971
  export declare const usePushNotifications: () => PushNotificationContextType;
1839
1972
 
1840
1973
  /**
@@ -1887,6 +2020,13 @@ export declare const useUserRoleDetails: (authKey: string, organizationSubdomain
1887
2020
 
1888
2021
  export declare function validatePromoCode(code: string, products: any[]): Promise<AppliedPromoCodeType>;
1889
2022
 
2023
+ export declare function withPromotion<T extends Priced>(product: T, promos?: Record<string, ProductPromotion> | null): T;
2024
+
2025
+ /** Une collection (et les variantes de ses produits) aux prix de la promotion. */
2026
+ export declare function withPromotionsInCollection<C extends {
2027
+ products?: any[];
2028
+ } | undefined | null>(collection: C, data?: ActivePromotions | null): C;
2029
+
1890
2030
 
1891
2031
  export * from "@lystech/sections";
1892
2032