l-min-components 1.7.1496 → 1.7.1498
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
|
@@ -125,6 +125,52 @@ const AppMainLayout = ({ children }) => {
|
|
|
125
125
|
}
|
|
126
126
|
}, [generalData]);
|
|
127
127
|
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (generalData?.selectedAccount?.type) {
|
|
130
|
+
// when we get the default account type (getDefaultAccount?.data?.type),
|
|
131
|
+
// if url is not containing settings, notifications or help,
|
|
132
|
+
// check if url contains default account type and if it doesn't
|
|
133
|
+
// navigate the user using href to /default account type in lower case
|
|
134
|
+
const currentUrl = window.location.pathname;
|
|
135
|
+
const defaultAccountType = getDefaultAccount?.data?.type?.toLowerCase();
|
|
136
|
+
|
|
137
|
+
const excludedPaths = ["settings", "notifications", "help"];
|
|
138
|
+
const shouldSkipNavigation = excludedPaths.some((path) =>
|
|
139
|
+
currentUrl.includes(path)
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
if (!shouldSkipNavigation && defaultAccountType) {
|
|
143
|
+
const urlContainsAccountType = currentUrl.includes(defaultAccountType);
|
|
144
|
+
|
|
145
|
+
console.log(
|
|
146
|
+
{
|
|
147
|
+
currentUrl,
|
|
148
|
+
defaultAccountType,
|
|
149
|
+
urlContainsAccountType,
|
|
150
|
+
shouldSkipNavigation,
|
|
151
|
+
hostname: window.location.hostname,
|
|
152
|
+
},
|
|
153
|
+
"Navigation Debug"
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
if (!urlContainsAccountType) {
|
|
157
|
+
// Use setTimeout to ensure navigation happens after React Router is ready
|
|
158
|
+
setTimeout(() => {
|
|
159
|
+
const targetUrl = `/${defaultAccountType}`;
|
|
160
|
+
console.log(`Navigating to: ${targetUrl}`);
|
|
161
|
+
|
|
162
|
+
// Try using window.location.replace for staging compatibility
|
|
163
|
+
if (window.location.hostname.includes("staging")) {
|
|
164
|
+
window.location.replace(targetUrl);
|
|
165
|
+
} else {
|
|
166
|
+
window.location.href = targetUrl;
|
|
167
|
+
}
|
|
168
|
+
}, 100);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}, [generalData?.selectedAccount?.type]);
|
|
173
|
+
|
|
128
174
|
//find account name
|
|
129
175
|
|
|
130
176
|
const findAccountNames = useCallback(
|
|
@@ -188,48 +234,6 @@ const AppMainLayout = ({ children }) => {
|
|
|
188
234
|
handleSetDefaultAccount(getDefaultAccount?.data?.id);
|
|
189
235
|
|
|
190
236
|
setSelectedAccount(getDefaultAccount?.data);
|
|
191
|
-
|
|
192
|
-
// when we get the default account type (getDefaultAccount?.data?.type),
|
|
193
|
-
// if url is not containing settings, notifications or help,
|
|
194
|
-
// check if url contains default account type and if it doesn't
|
|
195
|
-
// navigate the user using href to /default account type in lower case
|
|
196
|
-
const currentUrl = window.location.pathname;
|
|
197
|
-
const defaultAccountType = getDefaultAccount?.data?.type?.toLowerCase();
|
|
198
|
-
|
|
199
|
-
const excludedPaths = ["settings", "notifications", "help"];
|
|
200
|
-
const shouldSkipNavigation = excludedPaths.some((path) =>
|
|
201
|
-
currentUrl.includes(path)
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
if (!shouldSkipNavigation && defaultAccountType) {
|
|
205
|
-
const urlContainsAccountType = currentUrl.includes(defaultAccountType);
|
|
206
|
-
|
|
207
|
-
console.log(
|
|
208
|
-
{
|
|
209
|
-
currentUrl,
|
|
210
|
-
defaultAccountType,
|
|
211
|
-
urlContainsAccountType,
|
|
212
|
-
shouldSkipNavigation,
|
|
213
|
-
hostname: window.location.hostname,
|
|
214
|
-
},
|
|
215
|
-
"Navigation Debug"
|
|
216
|
-
);
|
|
217
|
-
|
|
218
|
-
if (!urlContainsAccountType) {
|
|
219
|
-
// Use setTimeout to ensure navigation happens after React Router is ready
|
|
220
|
-
setTimeout(() => {
|
|
221
|
-
const targetUrl = `/${defaultAccountType}`;
|
|
222
|
-
console.log(`Navigating to: ${targetUrl}`);
|
|
223
|
-
|
|
224
|
-
// Try using window.location.replace for staging compatibility
|
|
225
|
-
if (window.location.hostname.includes("staging")) {
|
|
226
|
-
window.location.replace(targetUrl);
|
|
227
|
-
} else {
|
|
228
|
-
window.location.href = targetUrl;
|
|
229
|
-
}
|
|
230
|
-
}, 100);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
237
|
}
|
|
234
238
|
}, [getDefaultAccount?.data]);
|
|
235
239
|
|