From 5f03a497acf04177ae48a213796c80f6553affc2 Mon Sep 17 00:00:00 2001 From: Basit Chonka Date: Thu, 26 Sep 2024 15:19:55 +0200 Subject: [PATCH] func to component --- .../src/components/index.tsx | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/packages/compass-global-writes/src/components/index.tsx b/packages/compass-global-writes/src/components/index.tsx index a21bfdc6d4b..f53173abf37 100644 --- a/packages/compass-global-writes/src/components/index.tsx +++ b/packages/compass-global-writes/src/components/index.tsx @@ -34,28 +34,35 @@ type GlobalWritesProps = { shardingStatus: ShardingStatus; }; -function getStateViewBasedOnShardingStatus(shardingStatus: ShardingStatus) { - switch (shardingStatus) { - case ShardingStatuses.NOT_READY: - return ( -
- -
- ); - case ShardingStatuses.UNSHARDED: - return ; - case ShardingStatuses.SHARDING: - return ; - default: - return null; +function ShardingStateView({ + shardingStatus, +}: { + shardingStatus: ShardingStatus; +}) { + if (shardingStatus === ShardingStatuses.NOT_READY) { + return ( +
+ +
+ ); + } + + if (shardingStatus === ShardingStatuses.UNSHARDED) { + return ; } + + if (shardingStatus === ShardingStatuses.SHARDING) { + return ; + } + + return null; } export function GlobalWrites({ shardingStatus }: GlobalWritesProps) { return (
- {getStateViewBasedOnShardingStatus(shardingStatus)} +
);