Skip to content

Commit 8c69c4f

Browse files
committed
refactor initial form config defaults
1 parent ed7dec0 commit 8c69c4f

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

examples/vue-app/src/home.vue

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -265,25 +265,7 @@ const defaultAdapters = (chainNamespace: ChainNamespaceType) => {
265265
});
266266
};
267267
268-
const configFromSessionStorage = () => {
269-
const storedConfig = JSON.parse(sessionStorage.getItem("web3AuthExampleConfig")) ?? {};
270-
return storedConfig;
271-
};
272-
273-
const configFromURL = () => {
274-
const params = new URLSearchParams(document.location.search);
275-
const chainParams = params.get("chain");
276-
const authModeParams = params.get("auth");
277-
const whitelabelParams = params.get("whitelabel");
278-
279-
return {
280-
...(["ethereum", "solana", "binance", "polygon"].includes(chainParams) && { chain: chainParams }),
281-
...(authModeParams === "custom" && { authMode: "ownAuth" }),
282-
...(whitelabelParams === "yes" && { selectedUiMode: "whitelabel" }),
283-
};
284-
};
285-
286-
const initialFormConfig = {
268+
const defaultFormConfig = {
287269
chain: "ethereum",
288270
authMode: "hosted",
289271
selectedUiMode: "default",
@@ -305,6 +287,28 @@ const initialFormConfig = {
305287
loginMethodsOrder: DEFAULT_LOGIN_PROVIDERS,
306288
},
307289
},
290+
};
291+
292+
const configFromSessionStorage = () => {
293+
const storedConfig = JSON.parse(sessionStorage.getItem("web3AuthExampleConfig")) ?? {};
294+
return storedConfig;
295+
};
296+
297+
const configFromURL = () => {
298+
const params = new URLSearchParams(document.location.search);
299+
const chainParams = params.get("chain");
300+
const authModeParams = params.get("auth");
301+
const whitelabelParams = params.get("whitelabel");
302+
303+
return {
304+
...(["ethereum", "solana", "binance", "polygon"].includes(chainParams) && { chain: chainParams }),
305+
...(authModeParams === "custom" && { authMode: "ownAuth" }),
306+
...(whitelabelParams === "yes" && { selectedUiMode: "whitelabel" }),
307+
};
308+
};
309+
310+
const initialFormConfig = {
311+
...defaultFormConfig,
308312
...configFromSessionStorage(),
309313
...configFromURL(),
310314
};

0 commit comments

Comments
 (0)