import { useResourceFileStore } from '@kevisual/resources/pages/store/resource-file';
import { useShallow } from 'zustand/shallow';
import { QuickPreview } from './QuickPreview';
import { useMemo } from 'react';
import { getFileType } from '../../FileIcon';

const QuickModules = [
  {
    key: 'link',
    type: 'link',
    categroy: ['image', 'video', 'audio'],
    tooltips: `链接生成，markdown超链接`,
    component: () => <QuickPreview />,
  },
  {
    key: 'preview',
    type: 'all',
    tooltips: `预览页面内容`,
    component: () => <QuickPreview />,
  },
];
export const Quick = () => {
  const { resource } = useResourceFileStore(
    useShallow((state) => ({
      resource: state.resource,
    })),
  );
  const quickModule = useMemo(() => {
    const fileType = getFileType(resource?.name);
    const allCanUseModule = QuickModules.filter((item) => item.type === 'all');
    if (!fileType) {
      return allCanUseModule;
    }
    return QuickModules.filter((item) => item.type === fileType);
  }, [resource]);
  return (
    <>
      <QuickPreview />
    </>
  );
};
