@lmnto/h-mall-shared 1.0.22 → 1.0.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lmnto/h-mall-shared",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "scripts": {
@@ -23,6 +23,8 @@ export default function HomeBanners({
23
23
  onCategoryChange,
24
24
  }) {
25
25
  const { featureFlags } = useMainContext();
26
+ const isMembershipFeatureEnabled =
27
+ featureFlags?.[FeatureCodes.ENABLE_MEMBERSHIP_FEATURE]?.isActive;
26
28
 
27
29
  const renderNote = () => {
28
30
  return (
@@ -291,6 +293,7 @@ export default function HomeBanners({
291
293
  onCategoryChange(CATEGORY_FOR_SUBSCRIPTION);
292
294
  }}
293
295
  isSubscriptionActive={isSubscriptionActive}
296
+ isMembershipFeatureEnabled={isMembershipFeatureEnabled}
294
297
  />
295
298
  </Carousel>
296
299
  </div>
@@ -8,18 +8,20 @@ import { useMemo } from "react";
8
8
 
9
9
  export type SubscriptionBannerProps = {
10
10
  isSubscriptionActive: boolean;
11
+ isMembershipFeatureEnabled?: boolean;
11
12
  callback: () => void;
12
13
  };
13
14
 
14
15
  export default function SubscriptionBanner({
15
16
  isSubscriptionActive,
17
+ isMembershipFeatureEnabled = true,
16
18
  callback,
17
19
  }: SubscriptionBannerProps) {
18
20
  const scopeT = _useScopedI18n("products.subscriptionBanner");
19
21
  const { user } = useUserStore();
20
22
 
21
23
  const renderBanner = useMemo(() => {
22
- if (isSubscriptionActive)
24
+ if (isSubscriptionActive) {
23
25
  return (
24
26
  <div className="justify-between rounded-xl h-[200px] sm:h-[150px] p-[5%] lg:p-[2%] subscriptionBanner">
25
27
  <div className="w-full md:w-5/6 lg:w-3/4 xl:w-2/3">
@@ -39,6 +41,30 @@ export default function SubscriptionBanner({
39
41
  </div>
40
42
  </div>
41
43
  );
44
+ }
45
+
46
+ if (!isMembershipFeatureEnabled) {
47
+ return (
48
+ <div className="justify-between rounded-xl h-[200px] sm:h-[150px] p-[5%] lg:p-[2%] subscriptionBanner">
49
+ <div className="w-full md:w-5/6 lg:w-3/4 xl:w-2/3">
50
+ <Typography
51
+ variant="h6"
52
+ className="font-medium text-sm text-black-500 mb-1"
53
+ >
54
+ {scopeT("welcome")}
55
+ </Typography>
56
+
57
+ <Typography
58
+ variant="h3"
59
+ className="font-semibold text-sm md:text-base text-black-500"
60
+ >
61
+ {scopeT("membershipFeatureUnavailableWelcome")}
62
+ </Typography>
63
+ </div>
64
+ </div>
65
+ );
66
+ }
67
+
42
68
  return (
43
69
  <div className="justify-between rounded-xl h-[200px] p-[5%] lg:p-[2%] subscriptionBannerBuy">
44
70
  <div className="w-full md:w-5/6 lg:w-3/4 xl:w-2/3">
@@ -57,14 +83,12 @@ export default function SubscriptionBanner({
57
83
  {scopeT("subscriptionActivationPending")}
58
84
  </Typography>
59
85
  ) : (
60
- <>
61
- <Typography
62
- variant="h2"
63
- className="font-semibold text-sm md:text-base text-black-500"
64
- >
65
- {scopeT("inactiveSubscription")} 🚀
66
- </Typography>
67
- </>
86
+ <Typography
87
+ variant="h2"
88
+ className="font-semibold text-sm md:text-base text-black-500"
89
+ >
90
+ {scopeT("inactiveSubscription")} 🚀
91
+ </Typography>
68
92
  )}
69
93
  <ButtonCustom
70
94
  onClick={callback}
@@ -77,7 +101,13 @@ export default function SubscriptionBanner({
77
101
  </div>
78
102
  </div>
79
103
  );
80
- }, [isSubscriptionActive, callback, scopeT, user]);
104
+ }, [
105
+ isSubscriptionActive,
106
+ isMembershipFeatureEnabled,
107
+ callback,
108
+ scopeT,
109
+ user,
110
+ ]);
81
111
 
82
112
  return <>{renderBanner}</>;
83
113
  }
@@ -1,28 +1,40 @@
1
1
  import { useQuery } from "@tanstack/react-query";
2
+ import { useEffect, useState } from "react";
2
3
  import { usePathname } from "next/navigation";
3
- import { useEffect } from "react";
4
-
5
4
  import { QueryKeys } from "../constants/query-keys";
6
5
  import { UsersService } from "../services/api";
7
6
  import { IUserProfile } from "../types/user";
8
7
 
9
8
  const useOnlineUser = () => {
9
+ const [onlineUser, setOnlineUser] = useState<IUserProfile>();
10
+
10
11
  const pathname = usePathname();
11
12
 
12
- const { data: onlineUser, refetch: getUser } = useQuery<IUserProfile>({
13
+
14
+ const { data: onlineData, refetch: getUser } = useQuery({
13
15
  queryKey: [QueryKeys.users.GET_USER],
14
16
  queryFn: () => UsersService.usersControllerGetProfile(),
17
+ enabled: true,
18
+ });
19
+
20
+ const { refetch: getAletaAuth } = useQuery({
21
+ queryKey: ["ALETA_AUTH"],
22
+ queryFn: () => UsersService.paymentGatewayControllerGetProfile(),
15
23
  enabled: false,
16
- staleTime: 0,
17
24
  });
18
25
 
19
26
  useEffect(() => {
20
- void getUser();
21
- }, [pathname, getUser]);
27
+ (async () => await setOnlineUser(onlineData))();
28
+ }, [setOnlineUser, onlineData]);
29
+
30
+ useEffect(() => {
31
+ getUser();
32
+ }, [getUser, pathname]);
22
33
 
23
34
  return {
24
35
  onlineUser,
25
36
  getUser,
37
+ getAletaAuth,
26
38
  };
27
39
  };
28
40
 
@@ -59,6 +59,8 @@ export default {
59
59
  buySubscriptionBtn: "Buy Subscription",
60
60
  subscriptionActivationPending:
61
61
  "Subscription activation still in progress. Please check back later or contact support.",
62
+ membershipFeatureUnavailableWelcome:
63
+ "Welcome to H Mall! Explore our products and discover what we have to offer.",
62
64
  },
63
65
  quantityComponent: {
64
66
  quantity: "Quantity",
@@ -56,6 +56,10 @@ export default {
56
56
  inactiveSubscription:
57
57
  "Sblocca vantaggi esclusivi rinnovando il tuo abbonamento oggi",
58
58
  buySubscriptionBtn: "Acquista abbonamento",
59
+ subscriptionActivationPending:
60
+ "Attivazione dell'abbonamento ancora in corso. Riprova più tardi o contatta l'assistenza.",
61
+ membershipFeatureUnavailableWelcome:
62
+ "Benvenuto su H Mall! Esplora i nostri prodotti e scopri cosa abbiamo da offrire.",
59
63
  },
60
64
  quantityComponent: {
61
65
  quantity: "Quantità",