Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

1.4 KB
Raw Blame
'use client';

import { Block, Center, Spin } from '@lobehub/ui';
import React, { memo } from 'react';

import { AsyncTaskStatus } from '@/types/asyncTask';

import { ActionButtons } from './ActionButtons';
import { ElapsedTime } from './ElapsedTime';
import { styles } from './styles';
import { type LoadingStateProps } from './types';
import { getThumbnailMaxWidth } from './utils';

// Loading state component
export const LoadingState = memo<LoadingStateProps>(
  ({ generation, generationBatch, aspectRatio, onDelete }) => {
    const isGenerating =
      generation.task.status === AsyncTaskStatus.Processing ||
      generation.task.status === AsyncTaskStatus.Pending;

    return (
      <Block
        align={'center'}
        className={`${styles.placeholderContainer} ${styles.placeholderContainerLoading}`}
        justify={'center'}
        variant={'filled'}
        style={{
          aspectRatio,
          maxWidth: getThumbnailMaxWidth(generation, generationBatch),
        }}
      >
        <div className={`${styles.placeholderContainer} ${styles.placeholderContainerLoading}`} />
        <Center gap={8} style={{ zIndex: 2 }}>
          <Spin size="large" variant="network" />
          <ElapsedTime generationId={generation.id} isActive={isGenerating} />
        </Center>
        <ActionButtons onDelete={onDelete} />
      </Block>
    );
  },
);

LoadingState.displayName = 'LoadingState';