@lystech/core 3.0.139 → 3.0.141

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
@@ -197,6 +197,42 @@ declare type AuthUserProfileProps = {
197
197
 
198
198
  export declare const axiosInstance: AxiosInstance;
199
199
 
200
+ export declare function BecomeMember({ title, intro, successUrl, cancelUrl, renderAction, onChoosePlan, onLoginRequired, }: BecomeMemberProps): JSX.Element | null;
201
+
202
+ export declare type BecomeMemberProps = {
203
+ title?: string;
204
+ intro?: string;
205
+ /** Retour après paiement Stripe (défaut : la page courante). */
206
+ successUrl?: string;
207
+ cancelUrl?: string;
208
+ /**
209
+ * Bouton de paiement PROPRE à la boutique pour un plan non relié à un prix
210
+ * Stripe (ex. son propre bouton de paiement). Prime sur `onChoosePlan`.
211
+ */
212
+ renderAction?: (plan: LoyaltyPlan, ctx: {
213
+ renew: boolean;
214
+ }) => ReactNode;
215
+ /** Paiement hors Stripe (PayPal, page dédiée…) pour un plan non relié à Stripe. */
216
+ onChoosePlan?: (plan: LoyaltyPlan) => void;
217
+ /** Le client n'est pas connecté : mener à la connexion. */
218
+ onLoginRequired?: () => void;
219
+ };
220
+
221
+ export declare type BenefitView = {
222
+ benefitUID: string;
223
+ name: string;
224
+ description: string | null;
225
+ kind: "percent_off" | "amount_off" | "free_shipping" | "perk";
226
+ value: number;
227
+ minSubtotal: number;
228
+ minItems: number;
229
+ effectLabel: string;
230
+ audienceLabel: string;
231
+ audienceMode?: "everyone" | "loggedIn" | "members" | "nonMembers" | "plans";
232
+ planUIDs: string[];
233
+ endsOn: string | null;
234
+ };
235
+
200
236
  declare type BillProduct = {
201
237
  UID: string;
202
238
  billUID?: string;
@@ -221,6 +257,12 @@ declare type BillProduct = {
221
257
  lastOrderedOn: string;
222
258
  };
223
259
 
260
+ export declare function BirthdayForm({ title }: BirthdayFormProps): JSX.Element | null;
261
+
262
+ export declare type BirthdayFormProps = {
263
+ title?: string;
264
+ };
265
+
224
266
  declare interface CardItem {
225
267
  label: default_2.ReactNode;
226
268
  labelIcon?: default_2.ReactNode;
@@ -241,7 +283,7 @@ export declare type CheckoutPanelProps = {
241
283
  promoCodes?: string[];
242
284
  /** Paiement confirmé (PayPal tout de suite ; carte au retour, voir useCheckoutReturn). */
243
285
  onPaid?: (info: {
244
- provider: "paypal" | "stripe";
286
+ provider: "paypal" | "stripe" | "store_credit";
245
287
  orderId?: string;
246
288
  }) => void;
247
289
  /** Adresse de retour après un paiement par carte (défaut : la page actuelle). */
@@ -509,6 +551,16 @@ declare interface GenericCardProps {
509
551
 
510
552
  export declare function getFeaturedImages(): Promise<ImageType[]>;
511
553
 
554
+ export declare function getLoyaltyRewards(): Promise<LoyaltyRewards>;
555
+
556
+ export declare function getMyBenefits(): Promise<MyBenefits>;
557
+
558
+ export declare function getMyBirthday(): Promise<MyBirthday>;
559
+
560
+ export declare function getMyLoyalty(): Promise<MyLoyalty>;
561
+
562
+ export declare function getMyLoyaltyLedger(limit?: number): Promise<LedgerRow[]>;
563
+
512
564
  export declare function getSinglePostBySlug(slug: string): Promise<PostType>;
513
565
 
514
566
  export declare function getUserPromoCodes(): Promise<PromoCodeType[]>;
@@ -529,6 +581,18 @@ export declare type ImageType = {
529
581
 
530
582
  export declare function InstallPwaButton({ size, visible, forceVisible, text, knowMoreUrl, knowMoreText, onAction, onPopupClose }: Props_9): JSX.Element | null;
531
583
 
584
+ export declare type LedgerRow = {
585
+ id: number;
586
+ delta: number;
587
+ kind: "earn" | "reverse" | "redeem" | "expire" | "adjust" | "bonus" | "migration" | string;
588
+ sourceType: string;
589
+ sourceRef: string | null;
590
+ availableOn: string;
591
+ createdOn: string;
592
+ note: string | null;
593
+ createdBy: string | null;
594
+ };
595
+
532
596
  declare type Line = {
533
597
  UID: string;
534
598
  quantity: number;
@@ -544,6 +608,102 @@ declare type Line = {
544
608
  */
545
609
  export declare function LoadingCircle(): JSX.Element;
546
610
 
611
+ export declare function LoyaltyAccount({ hideBirthday, hideBecomeMember, hideCodes, ...buy }: LoyaltyAccountProps): JSX.Element;
612
+
613
+ export declare type LoyaltyAccountProps = Pick<BecomeMemberProps, "successUrl" | "cancelUrl" | "onChoosePlan" | "onLoginRequired" | "renderAction"> & {
614
+ /** Masquer les codes personnels (si la boutique les montre déjà ailleurs). */
615
+ hideCodes?: boolean;
616
+ /** Masquer « Mon anniversaire » (si la boutique le gère ailleurs). */
617
+ hideBirthday?: boolean;
618
+ /** Masquer « Devenir membre ». */
619
+ hideBecomeMember?: boolean;
620
+ };
621
+
622
+ export declare const loyaltyKeys: {
623
+ me: (org: string, user: string) => readonly ["loyalty-me", string, string];
624
+ ledger: (org: string, user: string) => readonly ["loyalty-ledger", string, string];
625
+ rewards: (org: string, user: string) => readonly ["loyalty-rewards", string, string];
626
+ benefits: (org: string, user: string) => readonly ["loyalty-benefits", string, string];
627
+ birthday: (org: string, user: string) => readonly ["loyalty-birthday", string, string];
628
+ };
629
+
630
+ export declare type LoyaltyMembership = {
631
+ planUID: string;
632
+ planName: string | null;
633
+ source: "paypal_legacy" | "manual" | "gift" | "stripe";
634
+ ref: string;
635
+ startsOn: string | null;
636
+ endsOn: string | null;
637
+ status: MembershipStatus_2;
638
+ isActive: boolean;
639
+ };
640
+
641
+ export declare type LoyaltyPlan = {
642
+ UID: string;
643
+ name: string | null;
644
+ description: string | null;
645
+ price: number | null;
646
+ durationDays: number | null;
647
+ rank: number;
648
+ badgeLabel: string | null;
649
+ badgeColor: string | null;
650
+ pointsMultiplier: number;
651
+ /** Proposé sur « Devenir membre ». */
652
+ isPublic: boolean;
653
+ /** Achat en ligne par Stripe possible si non nul. */
654
+ stripePriceId: string | null;
655
+ };
656
+
657
+ export declare function LoyaltyPoints({ title, showRewards, historyPreview }: LoyaltyPointsProps): JSX.Element | null;
658
+
659
+ export declare type LoyaltyPointsProps = {
660
+ title?: string;
661
+ /** Afficher les récompenses échangeables (défaut : oui). */
662
+ showRewards?: boolean;
663
+ /** Lignes d'historique visibles avant « Voir tout » (défaut : 8). */
664
+ historyPreview?: number;
665
+ };
666
+
667
+ export declare type LoyaltyPointsSummary = {
668
+ enabled: boolean;
669
+ label: string;
670
+ balance: number;
671
+ pending: number;
672
+ lastEarnOn: string | null;
673
+ expiresOn: string | null;
674
+ };
675
+
676
+ export declare type LoyaltyRewards = {
677
+ enabled: boolean;
678
+ pointsLabel?: string;
679
+ balance: number | null;
680
+ next: {
681
+ reward: {
682
+ name: string;
683
+ costPoints: number;
684
+ };
685
+ missing: number;
686
+ } | null;
687
+ rewards: LoyaltyRewardView[];
688
+ };
689
+
690
+ export declare type LoyaltyRewardView = {
691
+ rewardUID: string;
692
+ name: string;
693
+ description: string | null;
694
+ costPoints: number;
695
+ effect: "percent_off" | "amount_off" | "free_shipping";
696
+ value: number;
697
+ effectLabel: string;
698
+ minSubtotal: number;
699
+ validityDays: number;
700
+ redeemable: {
701
+ ok: boolean;
702
+ reason?: string;
703
+ message?: string;
704
+ };
705
+ };
706
+
547
707
  /** Les adresses que le serveur peut écrire dans un courriel. */
548
708
  export declare const LYSTECH_AUTH_ROUTE_PATHS: readonly ["/account/activation/:token", "/account/reset-password/:token", "/suivi/:token"];
549
709
 
@@ -559,6 +719,54 @@ export declare function LystechNotFoundPage({ homePath, homeLabel, }?: {
559
719
  homeLabel?: string;
560
720
  }): JSX.Element;
561
721
 
722
+ export declare function MemberBenefits({ title, onBecomeMember, showCodes }: MemberBenefitsProps): JSX.Element | null;
723
+
724
+ export declare type MemberBenefitsProps = {
725
+ title?: string;
726
+ onBecomeMember?: () => void;
727
+ /** Montrer « Mes codes personnels » (défaut : oui). */
728
+ showCodes?: boolean;
729
+ };
730
+
731
+ export declare function MembershipBadge({ label, color }: {
732
+ label: string;
733
+ color?: string | null;
734
+ }): JSX.Element;
735
+
736
+ export declare type MembershipState = {
737
+ loading: boolean;
738
+ error: unknown;
739
+ isLoggedIn: boolean;
740
+ isMember: boolean;
741
+ /** A eu une adhésion, plus aucune active. */
742
+ wasMember: boolean;
743
+ activePlanUIDs: string[];
744
+ /** Adhésions actives, avec les réglages de leur plan (badge, rang). */
745
+ active: Array<LoyaltyMembership & {
746
+ plan: LoyaltyPlan | null;
747
+ }>;
748
+ /** Une entrée par plan déjà eu (active ou non). */
749
+ memberships: LoyaltyMembership[];
750
+ /** Tous les plans de la boutique (triés par rang). */
751
+ plans: LoyaltyPlan[];
752
+ /** Plans proposés sur « Devenir membre » (isPublic). */
753
+ availablePlans: LoyaltyPlan[];
754
+ hasPlan: (planUID: string) => boolean;
755
+ program: MyLoyalty["program"] | null;
756
+ points: MyLoyalty["points"];
757
+ refetch: () => void;
758
+ };
759
+
760
+ export declare function MembershipStatus({ title, onBecomeMember }: MembershipStatusProps): JSX.Element | null;
761
+
762
+ declare type MembershipStatus_2 = "active" | "grace" | "canceled_pending" | "expired";
763
+
764
+ export declare type MembershipStatusProps = {
765
+ title?: string;
766
+ /** Mène à « Devenir membre » (ou à la page de la boutique qui le montre). */
767
+ onBecomeMember?: () => void;
768
+ };
769
+
562
770
  declare type MessageParams = {
563
771
  type: "error" | "success" | "warning";
564
772
  message: string;
@@ -593,6 +801,43 @@ declare type ModalPopupProps = {
593
801
  onFinishOpen?: () => void;
594
802
  };
595
803
 
804
+ export declare type MyBenefits = {
805
+ enabled: boolean;
806
+ mine: BenefitView[];
807
+ others: BenefitView[];
808
+ codes: PersonalCode[];
809
+ };
810
+
811
+ export declare type MyBirthday = {
812
+ birthday: string | null;
813
+ year?: number | null;
814
+ month?: number;
815
+ day?: number;
816
+ source: string | null;
817
+ changeAllowedOn: string | null;
818
+ };
819
+
820
+ export declare type MyLoyalty = {
821
+ isLoggedIn: boolean;
822
+ isMember: boolean;
823
+ wasMember: boolean;
824
+ activePlanUIDs: string[];
825
+ /** Une entrée par plan (l'adhésion qui compte). */
826
+ memberships: LoyaltyMembership[];
827
+ /** Tout l'historique, la plus récente d'abord. */
828
+ history: LoyaltyMembership[];
829
+ plans: LoyaltyPlan[];
830
+ program: {
831
+ enabled: boolean;
832
+ pointsLabel: string;
833
+ earnDescription: string | null;
834
+ featuredPlanUID: string | null;
835
+ /** Le programme offre un cadeau d'anniversaire. */
836
+ birthdayEnabled?: boolean;
837
+ };
838
+ points: LoyaltyPointsSummary | null;
839
+ };
840
+
596
841
  declare type OrderBreakdown = {
597
842
  products: {
598
843
  UID: string;
@@ -618,6 +863,10 @@ declare type OrderBreakdown = {
618
863
  taxTotal?: number;
619
864
  /** true : les prix affichés contiennent déjà la taxe. */
620
865
  taxesIncluded?: boolean;
866
+ /** Crédit boutique du client connecté (dollars) : disponible, appliqué, reste à payer. */
867
+ storeCreditAvailable?: number;
868
+ storeCreditApplied?: number;
869
+ amountDue?: number;
621
870
  appliedPromoCodes?: {
622
871
  code: string;
623
872
  promo: string;
@@ -748,6 +997,16 @@ export declare type PaypalInfoType = {
748
997
  enabled: boolean;
749
998
  };
750
999
 
1000
+ export declare type PersonalCode = {
1001
+ id: number;
1002
+ code: string;
1003
+ description: string | null;
1004
+ effectLabel: string;
1005
+ minSubtotal: number;
1006
+ expireOn: string;
1007
+ usesLeft: number;
1008
+ };
1009
+
751
1010
  export declare function PolitiqueAndConditionPage(): JSX.Element;
752
1011
 
753
1012
  export declare type PolitiqueAndConditionsType = {
@@ -1014,6 +1273,7 @@ declare type Props_8 = {
1014
1273
  customerEmail?: string;
1015
1274
  promoCodes?: string[];
1016
1275
  shippingOptionId?: number | string | null;
1276
+ useStoreCredit?: boolean;
1017
1277
  label?: string;
1018
1278
  block?: boolean;
1019
1279
  disabled?: boolean;
@@ -1095,6 +1355,18 @@ declare type PushNotificationContextType = {
1095
1355
 
1096
1356
  export { QueryClient }
1097
1357
 
1358
+ export declare function redeemLoyaltyReward(rewardUID: string, requestId: string): Promise<RedeemResult>;
1359
+
1360
+ export declare type RedeemResult = {
1361
+ ok: true;
1362
+ code: string;
1363
+ promoCodeId: number;
1364
+ expireOn: string;
1365
+ costPoints: number;
1366
+ balance: number;
1367
+ replayed: boolean;
1368
+ };
1369
+
1098
1370
  export declare function registerNewUser(user: RegisterUserType): Promise<AxiosResponse<any, any>>;
1099
1371
 
1100
1372
  declare type RegisterUserType = {
@@ -1106,6 +1378,15 @@ declare type RegisterUserType = {
1106
1378
  birthday?: string;
1107
1379
  };
1108
1380
 
1381
+ export declare function saveMyBirthday(b: {
1382
+ day: number;
1383
+ month: number;
1384
+ year?: number | null;
1385
+ }): Promise<{
1386
+ success: boolean;
1387
+ birthday: string;
1388
+ }>;
1389
+
1109
1390
  export declare interface ShopCatalogCollection {
1110
1391
  UID: string;
1111
1392
  collectionName: string;
@@ -1232,7 +1513,7 @@ declare interface SquareImageProps {
1232
1513
  * crée la session côté backend (POST /stripe/checkout) puis redirige vers la
1233
1514
  * page de paiement Stripe. Aucun formulaire de carte côté client.
1234
1515
  */
1235
- export declare function StripeCheckout({ products, priceId, quantity, successUrl, cancelUrl, customerEmail, promoCodes, shippingOptionId, label, block, disabled, onError, onRedirect, }: Props_8): JSX.Element;
1516
+ export declare function StripeCheckout({ products, priceId, quantity, successUrl, cancelUrl, customerEmail, promoCodes, shippingOptionId, useStoreCredit, label, block, disabled, onError, onRedirect, }: Props_8): JSX.Element;
1236
1517
 
1237
1518
  export declare interface StripeCheckoutInput {
1238
1519
  /** Un seul prix Stripe (ex. depuis le catalogue). */
@@ -1250,6 +1531,8 @@ export declare interface StripeCheckoutInput {
1250
1531
  promoCodes?: string[];
1251
1532
  /** Option de livraison choisie dans le panier. */
1252
1533
  shippingOptionId?: number | string | null;
1534
+ /** Utiliser le crédit boutique : Stripe ne prélève que le reste. */
1535
+ useStoreCredit?: boolean;
1253
1536
  }
1254
1537
 
1255
1538
  export declare function SubscribeToPushNotification({ size, visible, forceVisible, text, knowMoreUrl, knowMoreText, onAction, onPopupClose }: Props_10): JSX.Element;
@@ -1499,8 +1782,18 @@ export declare const useInvitedToOrders: (email: string, organization?: string)
1499
1782
  fetchStatus: FetchStatus;
1500
1783
  };
1501
1784
 
1785
+ export declare function useLoyaltyLedger(enabled?: boolean): UseQueryResult<LedgerRow[], unknown>;
1786
+
1787
+ export declare function useLoyaltyRewards(enabled?: boolean): UseQueryResult<LoyaltyRewards, unknown>;
1788
+
1502
1789
  export declare const useLystechPolitiqueAndConditions: () => UseQueryResult<PolitiqueAndConditionsType[], unknown>;
1503
1790
 
1791
+ export declare function useMembership(): MembershipState;
1792
+
1793
+ export declare function useMyBenefits(enabled?: boolean): UseQueryResult<MyBenefits, unknown>;
1794
+
1795
+ export declare function useMyBirthday(enabled?: boolean): UseQueryResult<MyBirthday, unknown>;
1796
+
1504
1797
  export declare const useOptionalLocation: () => Location_2<any>;
1505
1798
 
1506
1799
  export declare const useOptionalNavigate: () => NavigateFunction | ((to: string | number, options?: {
@@ -1512,7 +1805,9 @@ export declare const useOrderDetailsBreakdown: (organizationUID: string, product
1512
1805
  quantity: number;
1513
1806
  }[], promoCodes: string[],
1514
1807
  /** Option de livraison choisie : le récapitulatif compte son prix (lu en base). */
1515
- shippingOptionId?: number | string | null) => UseQueryResult<OrderBreakdown, unknown>;
1808
+ shippingOptionId?: number | string | null,
1809
+ /** Le client choisit d'utiliser son crédit boutique. */
1810
+ useStoreCredit?: boolean) => UseQueryResult<OrderBreakdown, unknown>;
1516
1811
 
1517
1812
  export declare function useOrganization(): OrganizationContext;
1518
1813
 
@@ -1579,6 +1874,11 @@ export declare type UserSubscription = {
1579
1874
  rewards?: SubscriptionReward[];
1580
1875
  };
1581
1876
 
1877
+ export declare function useSectionsSession(): {
1878
+ cle: string | null;
1879
+ entetes: Record<string, string> | undefined;
1880
+ };
1881
+
1582
1882
  export declare const useSinglePost: (slug: string, organization: string) => UseQueryResult<PostType, unknown>;
1583
1883
 
1584
1884
  export declare const useTheme: () => ThemeContextType;