@mxenabled/connect-widget 0.10.4 → 0.11.0

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.es.js CHANGED
@@ -74891,46 +74891,73 @@ const getViewByStatus = (status) => {
74891
74891
  const VerifyExistingMember = (props) => {
74892
74892
  useAnalyticsPath(...PageviewInfo.CONNECT_VERIFY_EXISTING_MEMBER);
74893
74893
  const { api } = useApi();
74894
+ const config = useSelector(selectConfig);
74894
74895
  const dispatch = useDispatch();
74895
74896
  const { members, onAddNew } = props;
74896
- const iavMembers = members.filter(
74897
- (member) => member.verification_is_enabled && member.is_managed_by_user
74898
- // Only show user-managed members that support verification
74899
- );
74900
- const [selectedMember, setSelectedMember] = useState(null);
74901
- const [{ isLoadingInstitution, institutionError }, setInstitution] = useState({
74902
- isLoadingInstitution: false,
74903
- institutionError: null
74904
- });
74897
+ const iavMembers = useMemo(() => {
74898
+ return members.filter(
74899
+ (member) => member.verification_is_enabled && member.is_managed_by_user
74900
+ // Only show user-managed members that support verification
74901
+ );
74902
+ }, [members]);
74903
+ const [institutions, setInstitutions] = useState(/* @__PURE__ */ new Map());
74904
+ const [loading, setLoading] = useState(true);
74905
+ const [error, setError] = useState(null);
74905
74906
  const tokens = useTokens();
74906
74907
  const styles = getStyles$g(tokens);
74907
- const handleMemberClick = (selectedMember2) => {
74908
- setSelectedMember(selectedMember2);
74909
- setInstitution((state) => ({ ...state, isLoadingInstitution: true }));
74910
- };
74908
+ const handleMemberClick = useCallback(
74909
+ (selectedMember) => {
74910
+ const institution = institutions.get(selectedMember.institution_guid);
74911
+ if (institution) {
74912
+ if (selectedMember.is_oauth) {
74913
+ dispatch(startOauth$1(selectedMember, institution));
74914
+ } else {
74915
+ dispatch(verifyExistingConnection$1(selectedMember, institution));
74916
+ }
74917
+ }
74918
+ },
74919
+ [dispatch, institutions]
74920
+ );
74911
74921
  useEffect(() => {
74912
74922
  focusElement(document.getElementById("connect-select-institution"));
74913
74923
  }, []);
74914
74924
  useEffect(() => {
74915
- if (!isLoadingInstitution || !selectedMember) return;
74916
- api.loadInstitutionByGuid(selectedMember.institution_guid).then((institution) => {
74917
- if (selectedMember.is_oauth) {
74918
- dispatch(startOauth$1(selectedMember, institution));
74919
- } else {
74920
- dispatch(verifyExistingConnection$1(selectedMember, institution));
74925
+ const fetchInstitutionsProgressively = async () => {
74926
+ setLoading(true);
74927
+ setError(null);
74928
+ const institutionMap = /* @__PURE__ */ new Map();
74929
+ for (const member of iavMembers) {
74930
+ try {
74931
+ const institution = await api.loadInstitutionByGuid(member.institution_guid);
74932
+ if (institution) {
74933
+ institutionMap.set(member.institution_guid, institution);
74934
+ }
74935
+ } catch (err) {
74936
+ setError(err);
74937
+ }
74921
74938
  }
74922
- }).catch((error) => {
74923
- setInstitution((state) => ({
74924
- ...state,
74925
- isLoadingInstitution: false,
74926
- institutionError: error
74927
- }));
74939
+ setInstitutions(new Map(institutionMap));
74940
+ setLoading(false);
74941
+ };
74942
+ if (iavMembers.length > 0) {
74943
+ fetchInstitutionsProgressively();
74944
+ } else {
74945
+ setLoading(false);
74946
+ }
74947
+ }, [api, iavMembers]);
74948
+ const productSupportingMembers = useMemo(() => {
74949
+ return iavMembers.filter((member) => {
74950
+ const institution = institutions.get(member.institution_guid);
74951
+ if (institution) {
74952
+ return instutionSupportRequestedProducts(config, institution);
74953
+ }
74954
+ return false;
74928
74955
  });
74929
- }, [isLoadingInstitution, selectedMember]);
74930
- if (isLoadingInstitution) {
74956
+ }, [config, institutions, iavMembers]);
74957
+ if (loading) {
74931
74958
  return /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingSpinner, { showText: true });
74932
74959
  }
74933
- if (institutionError) {
74960
+ if (error) {
74934
74961
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
74935
74962
  GenericError,
74936
74963
  {
@@ -74977,12 +75004,12 @@ const VerifyExistingMember = (props) => {
74977
75004
  children: _n(
74978
75005
  "%1 Connected institution",
74979
75006
  "%1 Connected institutions",
74980
- iavMembers.length,
74981
- iavMembers.length
75007
+ productSupportingMembers.length,
75008
+ productSupportingMembers.length
74982
75009
  )
74983
75010
  }
74984
75011
  ),
74985
- iavMembers.map((member) => {
75012
+ productSupportingMembers.map((member) => {
74986
75013
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
74987
75014
  UtilityRow,
74988
75015
  {