@@ -34,45 +34,37 @@ enum HeaderType {
3434// ネットワーク切り替えコンポーネントを作成
3535const NetworkSwitcher = ( {
3636 switchToChain,
37- connectedChainId,
3837} : {
3938 switchToChain : ( chain : Chain ) => Promise < boolean > ;
40- connectedChainId ?: number ;
4139} ) => {
42- const isWrongNetwork =
43- connectedChainId && connectedChainId !== currentChain . id ;
44-
4540 return (
4641 < MenuItem value = "network" display = "block" >
4742 < Text fontWeight = "bold" mb = { 2 } >
4843 Network
4944 </ Text >
50- { isWrongNetwork ? (
51- < >
52- < Text color = "red.500" fontSize = "sm" mb = { 2 } >
53- ⚠️ 異なるネットワークに接続されています
54- </ Text >
55- < CommonButton
56- key = { currentChain . id }
57- onClick = { ( ) => switchToChain ( currentChain ) }
58- w = "100%"
59- mb = { 1 }
60- colorScheme = "red"
61- >
62- { currentChain . name } に切り替える
63- </ CommonButton >
64- </ >
65- ) : (
45+ { /* チェーン切り替えボタンを表示 */ }
46+ { /* {supportedChains.map((chain) => (
6647 <CommonButton
67- key = { currentChain . id }
68- onClick = { ( ) => switchToChain ( currentChain ) }
48+ key={chain .id}
49+ onClick={() => switchToChain(chain )}
6950 w="100%"
7051 mb={1}
71- variant = "solid"
52+ variant={chain.id === currentChain.id ? "solid" : "outline"}
7253 >
73- { currentChain . name }
54+ {chain .name}
7455 </CommonButton>
75- ) }
56+ ))} */ }
57+
58+ { /* 現在のチェーンを表示 */ }
59+ < CommonButton
60+ key = { currentChain . id }
61+ onClick = { ( ) => switchToChain ( currentChain ) }
62+ w = "100%"
63+ mb = { 1 }
64+ variant = { "solid" }
65+ >
66+ { currentChain . name }
67+ </ CommonButton >
7668 </ MenuItem >
7769 ) ;
7870} ;
@@ -145,10 +137,6 @@ export const Header = () => {
145137
146138 const { switchToChain } = useSwitchNetwork ( ) ;
147139
148- const connectedChainId = wallets [ 0 ]
149- ? Number ( wallets [ 0 ] . chainId . split ( ":" ) [ 1 ] )
150- : undefined ;
151-
152140 return headerType !== HeaderType . NonHeader ? (
153141 < Flex justifyContent = "space-between" w = "100%" py = { 3 } >
154142 < Box display = "flex" height = "48px" flex = "1" alignItems = "center" >
@@ -189,10 +177,7 @@ export const Header = () => {
189177 </ Text >
190178 < Text fontSize = "xs" > { abbreviateAddress ( identity . address ) } </ Text >
191179 </ MenuItem >
192- < NetworkSwitcher
193- switchToChain = { switchToChain }
194- connectedChainId = { connectedChainId }
195- />
180+ < NetworkSwitcher switchToChain = { switchToChain } />
196181 < MenuItem value = "logout" onClick = { handleLogout } >
197182 Logout
198183 </ MenuItem >
@@ -201,25 +186,12 @@ export const Header = () => {
201186 ) : (
202187 < MenuRoot closeOnSelect = { false } >
203188 < MenuTrigger asChild >
204- < CommonButton
205- w = "auto"
206- my = "auto"
207- colorScheme = {
208- connectedChainId && connectedChainId !== currentChain . id
209- ? "red"
210- : undefined
211- }
212- >
213- { connectedChainId && connectedChainId !== currentChain . id
214- ? "⚠️ ネットワークを切り替えてください"
215- : currentChain . name }
189+ < CommonButton w = "auto" my = "auto" >
190+ { currentChain . name }
216191 </ CommonButton >
217192 </ MenuTrigger >
218193 < MenuContent >
219- < NetworkSwitcher
220- switchToChain = { switchToChain }
221- connectedChainId = { connectedChainId }
222- />
194+ < NetworkSwitcher switchToChain = { switchToChain } />
223195 < MenuItem value = "logout" onClick = { handleLogout } >
224196 Logout
225197 </ MenuItem >
0 commit comments