Skip to content

Commit

Permalink
func to component
Browse files Browse the repository at this point in the history
  • Loading branch information
mabaasit committed Sep 26, 2024
1 parent a0eb2be commit 5f03a49
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions packages/compass-global-writes/src/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,35 @@ type GlobalWritesProps = {
shardingStatus: ShardingStatus;
};

function getStateViewBasedOnShardingStatus(shardingStatus: ShardingStatus) {
switch (shardingStatus) {
case ShardingStatuses.NOT_READY:
return (
<div className={centeredContent}>
<SpinLoaderWithLabel progressText="Loading …" />
</div>
);
case ShardingStatuses.UNSHARDED:
return <UnshardedState />;
case ShardingStatuses.SHARDING:
return <ShardingState />;
default:
return null;
function ShardingStateView({
shardingStatus,
}: {
shardingStatus: ShardingStatus;
}) {
if (shardingStatus === ShardingStatuses.NOT_READY) {
return (
<div className={centeredContent}>
<SpinLoaderWithLabel progressText="Loading …" />
</div>
);
}

if (shardingStatus === ShardingStatuses.UNSHARDED) {
return <UnshardedState />;
}

if (shardingStatus === ShardingStatuses.SHARDING) {
return <ShardingState />;
}

return null;
}

export function GlobalWrites({ shardingStatus }: GlobalWritesProps) {
return (
<div className={containerStyles}>
<WorkspaceContainer className={workspaceContentStyles}>
{getStateViewBasedOnShardingStatus(shardingStatus)}
<ShardingStateView shardingStatus={shardingStatus} />
</WorkspaceContainer>
</div>
);
Expand Down

0 comments on commit 5f03a49

Please sign in to comment.