From 7bfe903934bc5593dbd6f449d3dcb1508738ffc5 Mon Sep 17 00:00:00 2001 From: dschlabach Date: Thu, 14 Nov 2024 13:46:26 -0500 Subject: [PATCH] refactor --- .../nextjs-app-router/components/Demo.tsx | 115 ++++-------------- 1 file changed, 24 insertions(+), 91 deletions(-) diff --git a/playground/nextjs-app-router/components/Demo.tsx b/playground/nextjs-app-router/components/Demo.tsx index 61818be3f7..8b58821008 100644 --- a/playground/nextjs-app-router/components/Demo.tsx +++ b/playground/nextjs-app-router/components/Demo.tsx @@ -18,7 +18,7 @@ import TransactionDefaultDemo from './demo/TransactionDefault'; import WalletDemo from './demo/Wallet'; import WalletDefaultDemo from './demo/WalletDefault'; -const activeComponentMapping = { +const activeComponentMapping: Record = { [OnchainKitComponent.Fund]: FundDemo, [OnchainKitComponent.Identity]: IdentityDemo, [OnchainKitComponent.Transaction]: TransactionDemo, @@ -62,63 +62,9 @@ function Demo() { : 'border-gray-300 bg-white text-black hover:bg-gray-100' }`; - // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: TODO: refactor - function renderActiveComponent() { - if (activeComponent && activeComponentMapping[activeComponent]) { - const Component = activeComponentMapping[activeComponent]; - return ; - } - - if (activeComponent === OnchainKitComponent.Transaction) { - return ; - } - - if (activeComponent === OnchainKitComponent.Checkout) { - return ; - } - - if (activeComponent === OnchainKitComponent.Swap) { - return ; - } - - if (activeComponent === OnchainKitComponent.SwapDefault) { - return ; - } - - if (activeComponent === OnchainKitComponent.Wallet) { - return ; - } - - if (activeComponent === OnchainKitComponent.WalletDefault) { - return ; - } - - if (activeComponent === OnchainKitComponent.TransactionDefault) { - return ; - } - - if (activeComponent === OnchainKitComponent.NFTMintCard) { - return ; - } - - if (activeComponent === OnchainKitComponent.NFTCard) { - return ; - } - - if (activeComponent === OnchainKitComponent.NFTMintCardDefault) { - return ; - } - - if (activeComponent === OnchainKitComponent.NFTCardDefault) { - return ; - } - - if (activeComponent === OnchainKitComponent.IdentityCard) { - return ; - } - - return <>; - } + const ActiveComponent = activeComponent + ? activeComponentMapping[activeComponent] + : null; return ( <> @@ -150,43 +96,30 @@ function Demo() {
-
- -
- -
+
- {renderActiveComponent()} + {ActiveComponent && }