import { useMemo } from 'react';
import Viewer from 'react-viewer';
import { checkIsImage } from '@/webPublic/one_stop_public/libs/UploadCom';
export const ImgViewer = (props) => {
	const { onClose, path } = props;
	
  const images = useMemo(
		() => {
			return props?.images?.filter(i => checkIsImage(i?.src));
		},
		[props.images]
	);
  const activeIndex = useMemo(
		() => {
      if(path) {
        return images?.findIndex((item) => item?.src === path);
      }
      return 0
		},
		[path]
	);
	return (
		<Viewer visible={true} onClose={onClose} activeIndex={activeIndex} images={images} />
	);
};
