59}: MenuBarProps) => {
60 const navigate = useNavigate()
61 const goHome = () => navigate("/dashboard")
62 switch (variant) { 63 case "dashboard": 64 return ( 65 <MenuBarBase 66 leftSlot={<LogoButton onClick={goHome} />} 67 rightSlot={<MenuDrawer />} 68 > 69 {(publicAddress?.length ?? 0) > 0 && ( 70 <Link to="/receive" className="btn flex gap-1 min-h-10 h-10"> 71 {truncateString({ 72 value: publicAddress ?? "", 73 firstCharCount: 5, 74 endCharCount: 3, 75 })} 76 </Link> 77 )} 78 </MenuBarBase> 79 ) 80 case "wallet": 81 return ( 82 <MenuBarBase 83 leftSlot={<LogoButton onClick={goHome} />} 84 rightSlot={ 85 <div className="flex space-x-2"> 86 <div 87 className="tooltip tooltip-secondary tooltip-bottom" 88 data-tip="Network management" 89 > 90 <Link 91 to="/networks" 92 type="button" 93 className="flex flex-col btn min-h-10 h-10" 94 onClick={onNetworkClicked} 95 > 96 <p className="text-sm">{currentNetwork}</p> 97 {networkManagement ? ( 98 <ChevronUpIcon width={24} height={24} /> 99 ) : (100 <ChevronDownIcon width={24} height={24} />101 )}102 </Link>103 </div>104 <button105 type="button"106 className="btn btn-circle min-h-10 h-10 w-10"107 onClick={onCloseClicked}108 >109 <XIcon width={24} height={24} />110 </button>111 </div>112 }113 />114 )115 case "card":116 return (117 <MenuBarBase118 leftSlot={<LogoButton onClick={goHome} />}119 rightSlot={120 <div className="flex space-x-2">121 <button122 type="button"123 className="btn btn-circle min-h-10 h-10 w-10"124 onClick={onCloseClicked}125 >126 <XIcon width={24} height={24} />127 </button>128 </div>129 }130 />131 )132 case "back":133 return (134 <MenuBarBase135 leftSlot={136 <button137 type="button"138 className="btn btn-circle min-h-10 h-10 w-10"139 onClick={onBackClicked}140 >141 <ArrowLeftIcon width={24} height={24} />142 </button>143 }144 />145 )146 case "back-stop":147 return (148 <MenuBarBase149 leftSlot={150 <button151 type="button"152 className="btn btn-circle min-h-10 h-10 w-10"153 onClick={onBackClicked}154 >155 <ArrowLeftIcon width={24} height={24} />156 </button>157 }158 rightSlot={159 <button160 type="button"161 className="btn btn-circle min-h-10 h-10 w-10"162 onClick={onCloseClicked}163 >164 <XIcon width={24} height={24} />165 </button>166 }167 />168 )169 case "stop":170 return (171 <MenuBarBase172 rightSlot={173 <button174 type="button"175 className="btn btn-circle min-h-10 h-10 w-10"176 onClick={onCloseClicked}177 >178 <XIcon width={24} height={24} />179 </button>180 }181 />182 )183 }184}
Some code conventions require that all switch statements have a default case, even if the default case is empty. The idea is to always explicitly state what the default behavior should be so that it's clear that the developer didn't forget to handle the default fallback case.
switch (a) {
case 1:
/* code */
break;
}
switch (a) {
case 1:
/* code */
break;
default:
/* code */
break;
}
switch (a) {
case 1:
/* code */
break;
// no default
}
switch (a) {
case 1:
/* code */
break;
// No Default
}