use-get-icon.ts 474 B

12345678910111213141516
  1. import { useCallback } from 'react'
  2. import { apiPrefix } from '@/config'
  3. import { useSelector } from '@/context/app-context'
  4. const useGetIcon = () => {
  5. const currentWorkspace = useSelector(s => s.currentWorkspace)
  6. const getIconUrl = useCallback((fileName: string) => {
  7. return `${apiPrefix}/workspaces/current/plugin/icon?tenant_id=${currentWorkspace.id}&filename=${fileName}`
  8. }, [currentWorkspace.id])
  9. return {
  10. getIconUrl,
  11. }
  12. }
  13. export default useGetIcon