@greatapps/common 1.1.260 → 1.1.261

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.
@@ -8,10 +8,11 @@ function useConfigurationsModal({
8
8
  const [activeSection, setActiveSection] = useState(
9
9
  AccountSectionType.MY_PROFILE
10
10
  );
11
+ const isValidSection = (section) => Object.values(AccountSectionType).includes(section);
11
12
  useEffect(() => {
12
- if (isOpen && initialSection) {
13
+ if (isOpen && isValidSection(initialSection)) {
13
14
  setActiveSection(initialSection);
14
- } else if (isOpen && !initialSection) {
15
+ } else if (isOpen) {
15
16
  setActiveSection(AccountSectionType.MY_PROFILE);
16
17
  }
17
18
  }, [isOpen, initialSection]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/account/hooks/useConfigurationsModal.ts"],"sourcesContent":["'use client';\r\n\r\nimport { useState, useCallback, useEffect } from 'react';\r\nimport { AccountSectionType } from '../../../enums/AccountSectionType';\r\n\r\ninterface UseConfigurationsModalProps {\r\n isOpen: boolean;\r\n initialSection?: AccountSectionType;\r\n}\r\n\r\nexport default function useConfigurationsModal({\r\n isOpen,\r\n initialSection,\r\n}: UseConfigurationsModalProps) {\r\n const [activeSection, setActiveSection] = useState<AccountSectionType>(\r\n AccountSectionType.MY_PROFILE\r\n );\r\n\r\n useEffect(() => {\r\n if (isOpen && initialSection) {\r\n setActiveSection(initialSection);\r\n } else if (isOpen && !initialSection) {\r\n setActiveSection(AccountSectionType.MY_PROFILE);\r\n }\r\n }, [isOpen, initialSection]);\r\n\r\n const handleSectionChange = useCallback((section: AccountSectionType) => {\r\n setActiveSection(section);\r\n }, []);\r\n\r\n const resetSection = useCallback(() => {\r\n setActiveSection(AccountSectionType.MY_PROFILE);\r\n }, []);\r\n\r\n return {\r\n activeSection,\r\n setActiveSection: handleSectionChange,\r\n resetSection,\r\n };\r\n}\r\n"],"mappings":";AAEA,SAAS,UAAU,aAAa,iBAAiB;AACjD,SAAS,0BAA0B;AAOpB,SAAR,uBAAwC;AAAA,EAC7C;AAAA,EACA;AACF,GAAgC;AAC9B,QAAM,CAAC,eAAe,gBAAgB,IAAI;AAAA,IACxC,mBAAmB;AAAA,EACrB;AAEA,YAAU,MAAM;AACd,QAAI,UAAU,gBAAgB;AAC5B,uBAAiB,cAAc;AAAA,IACjC,WAAW,UAAU,CAAC,gBAAgB;AACpC,uBAAiB,mBAAmB,UAAU;AAAA,IAChD;AAAA,EACF,GAAG,CAAC,QAAQ,cAAc,CAAC;AAE3B,QAAM,sBAAsB,YAAY,CAAC,YAAgC;AACvE,qBAAiB,OAAO;AAAA,EAC1B,GAAG,CAAC,CAAC;AAEL,QAAM,eAAe,YAAY,MAAM;AACrC,qBAAiB,mBAAmB,UAAU;AAAA,EAChD,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,IACA,kBAAkB;AAAA,IAClB;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/components/account/hooks/useConfigurationsModal.ts"],"sourcesContent":["\"use client\";\r\n\r\nimport { useState, useCallback, useEffect } from \"react\";\r\nimport { AccountSectionType } from \"../../../enums/AccountSectionType\";\r\n\r\ninterface UseConfigurationsModalProps {\r\n isOpen: boolean;\r\n initialSection?: AccountSectionType;\r\n}\r\n\r\nexport default function useConfigurationsModal({\r\n isOpen,\r\n initialSection,\r\n}: UseConfigurationsModalProps) {\r\n const [activeSection, setActiveSection] = useState<AccountSectionType>(\r\n AccountSectionType.MY_PROFILE,\r\n );\r\n\r\n const isValidSection = (\r\n section?: AccountSectionType,\r\n ): section is AccountSectionType =>\r\n Object.values(AccountSectionType).includes(section as AccountSectionType);\r\n\r\n useEffect(() => {\r\n if (isOpen && isValidSection(initialSection)) {\r\n setActiveSection(initialSection);\r\n } else if (isOpen) {\r\n setActiveSection(AccountSectionType.MY_PROFILE);\r\n }\r\n }, [isOpen, initialSection]);\r\n\r\n const handleSectionChange = useCallback((section: AccountSectionType) => {\r\n setActiveSection(section);\r\n }, []);\r\n\r\n const resetSection = useCallback(() => {\r\n setActiveSection(AccountSectionType.MY_PROFILE);\r\n }, []);\r\n\r\n return {\r\n activeSection,\r\n setActiveSection: handleSectionChange,\r\n resetSection,\r\n };\r\n}\r\n"],"mappings":";AAEA,SAAS,UAAU,aAAa,iBAAiB;AACjD,SAAS,0BAA0B;AAOpB,SAAR,uBAAwC;AAAA,EAC7C;AAAA,EACA;AACF,GAAgC;AAC9B,QAAM,CAAC,eAAe,gBAAgB,IAAI;AAAA,IACxC,mBAAmB;AAAA,EACrB;AAEA,QAAM,iBAAiB,CACrB,YAEA,OAAO,OAAO,kBAAkB,EAAE,SAAS,OAA6B;AAE1E,YAAU,MAAM;AACd,QAAI,UAAU,eAAe,cAAc,GAAG;AAC5C,uBAAiB,cAAc;AAAA,IACjC,WAAW,QAAQ;AACjB,uBAAiB,mBAAmB,UAAU;AAAA,IAChD;AAAA,EACF,GAAG,CAAC,QAAQ,cAAc,CAAC;AAE3B,QAAM,sBAAsB,YAAY,CAAC,YAAgC;AACvE,qBAAiB,OAAO;AAAA,EAC1B,GAAG,CAAC,CAAC;AAEL,QAAM,eAAe,YAAY,MAAM;AACrC,qBAAiB,mBAAmB,UAAU;AAAA,EAChD,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,IACA,kBAAkB;AAAA,IAClB;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@greatapps/common",
3
- "version": "1.1.260",
3
+ "version": "1.1.261",
4
4
  "description": "Shared library for GreatApps frontend applications",
5
5
  "main": "./dist/index.mjs",
6
6
  "types": "./src/index.ts",
@@ -1,7 +1,7 @@
1
- 'use client';
1
+ "use client";
2
2
 
3
- import { useState, useCallback, useEffect } from 'react';
4
- import { AccountSectionType } from '../../../enums/AccountSectionType';
3
+ import { useState, useCallback, useEffect } from "react";
4
+ import { AccountSectionType } from "../../../enums/AccountSectionType";
5
5
 
6
6
  interface UseConfigurationsModalProps {
7
7
  isOpen: boolean;
@@ -13,13 +13,18 @@ export default function useConfigurationsModal({
13
13
  initialSection,
14
14
  }: UseConfigurationsModalProps) {
15
15
  const [activeSection, setActiveSection] = useState<AccountSectionType>(
16
- AccountSectionType.MY_PROFILE
16
+ AccountSectionType.MY_PROFILE,
17
17
  );
18
18
 
19
+ const isValidSection = (
20
+ section?: AccountSectionType,
21
+ ): section is AccountSectionType =>
22
+ Object.values(AccountSectionType).includes(section as AccountSectionType);
23
+
19
24
  useEffect(() => {
20
- if (isOpen && initialSection) {
25
+ if (isOpen && isValidSection(initialSection)) {
21
26
  setActiveSection(initialSection);
22
- } else if (isOpen && !initialSection) {
27
+ } else if (isOpen) {
23
28
  setActiveSection(AccountSectionType.MY_PROFILE);
24
29
  }
25
30
  }, [isOpen, initialSection]);