G2GDataTransferStatusIcon.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import React, { type ComponentPropsWithoutRef } from 'react';
  2. import { LoadingSpinner } from '@growi/ui/dist/components';
  3. import { G2G_PROGRESS_STATUS, type G2GProgressStatus } from '~/interfaces/g2g-transfer';
  4. /**
  5. * Props for {@link G2GDataTransferStatusIcon}
  6. */
  7. interface Props extends ComponentPropsWithoutRef<'span'>{
  8. status: G2GProgressStatus;
  9. }
  10. /**
  11. * Icon for G2G transfer status
  12. */
  13. const G2GDataTransferStatusIcon = ({ status, className, ...props }: Props): JSX.Element => {
  14. if (status === G2G_PROGRESS_STATUS.IN_PROGRESS) {
  15. return (
  16. <LoadingSpinner className={`${className}`} aria-label="in progress" {...props} />
  17. );
  18. }
  19. if (status === G2G_PROGRESS_STATUS.COMPLETED) {
  20. return (
  21. <span className={`material-symbols-outlined text-info ${className}`} aria-label="completed" {...props}>check_circle</span>
  22. );
  23. }
  24. if (status === G2G_PROGRESS_STATUS.ERROR) {
  25. return (
  26. <span className={`material-symbols-outlined text-danger ${className}`} aria-label="error" {...props}>error</span>
  27. );
  28. }
  29. if (status === G2G_PROGRESS_STATUS.SKIPPED) {
  30. return (
  31. <span className={`material-symbols-outlined ${className}`} aria-label="skipped" {...props}>block</span>
  32. );
  33. }
  34. return <span className={`material-symbols-outlined ${className}`} aria-label="pending" {...props}>circle</span>;
  35. };
  36. export default G2GDataTransferStatusIcon;