Skip to content

A games launcher for GOG, Amazon and Epic Games for Linux, Windows and macOS.

2.0 KB
Raw Blame
import { useContext } from 'react'
import ContextProvider from 'frontend/state/ContextProvider'
import { Trans, useTranslation } from 'react-i18next'
import { LibraryBig, SearchX } from 'lucide-react'
import { NavLink } from 'react-router-dom'
import EmptyState from 'frontend/components/UI/EmptyState'
import './index.css'
import AddGameButton from '../AddGameButton'

function EmptyLibraryMessage() {
  const { epic, gog, amazon, zoom, itchio, sideloadedLibrary } =
    useContext(ContextProvider)
  const { t, i18n } = useTranslation()

  const hasGames =
    epic.library.length +
      gog.library.length +
      amazon.library.length +
      zoom.library.length +
      itchio.library.length +
      sideloadedLibrary.length >
    0

  if (hasGames) {
    return (
      <EmptyState
        className="noResultsMessage"
        glyph={SearchX}
        title={t('emptyLibrary.noResultsTitle', 'No games found')}
        description={t(
          'emptyLibrary.noResults',
          'The current filters produced no results.'
        )}
      />
    )
  }

  return (
    <EmptyState
      className="noResultsMessage"
      glyph={LibraryBig}
      title={t('emptyLibrary.title', 'Your library is empty.')}
      description={
        <>
          <Trans i18n={i18n} i18nKey="emptyLibrary.description">
            <NavLink to="/login">Log in</NavLink> with your Epic, GOG.com,
            Amazon, itch.io or Zoom accounts and your games will show up here.
            You can also add games from other sources manually.
          </Trans>
          <span className="noResultsMessage__backupHint">
            <Trans i18n={i18n} i18nKey="emptyLibrary.backupHint">
              Have a Heroic backup?{' '}
              <NavLink to="/settings/importexport" state={{ openImport: true }}>
                Restore from it to pick up where you left off
              </NavLink>
              .
            </Trans>
          </span>
        </>
      }
      action={<AddGameButton />}
    />
  )
}

export default EmptyLibraryMessage