/* eslint-disable no-case-declarations */
import React from 'react';
import loadable from '@loadable/component';

export default function index({ module }) {
  const Component = () => {
    switch (module?.mode) {
      case 'image_text':
        const ImageWithText = loadable(() => import('./image-text'));
        return <ImageWithText module={module} />;
      case 'icon':
        const Icon = loadable(() => import('./icon'));
        return <Icon module={module} />;
      default:
        const Image = loadable(() => import('./image'));
        return <Image module={module} />;
    }
  };

  return <>{Component && <Component />}</>;
}
