<commit_before>import Head from 'next/head'
import Layout, { siteTitle } from 'components/layout'
import Link from 'next/link'
import useUser from 'lib/useUser'
import { useEffect, useState } from 'react'
import NewLanguageForm from 'components/NewLanguageForm'
import fetchJson, { FetchError } from 'lib/fetchJson'

export default function Home() {
  const { user } = useUser({
    redirectTo: '/login',
  })
  const [userLanguages, setUserLanguages] = useState([])

  useEffect(() => {
    async function getUserLanguages() {
      try {
        const response = await fetchJson<any>('/api/user/languages', {
          method: 'GET',
          headers: { 'Content-Type': 'application/json' },
        })
        setUserLanguages(response)
      } catch (error) {
        if (error instanceof FetchError) {
          console.log(error.data.message)
        } else {
          console.error('An unexpected error happened:', error)
        }
      }
    }
    getUserLanguages()
  }, [setUserLanguages])

  return (<commit_msg>Show error message if user session unable to be initialized<commit_after>import Head from 'next/head'
import Layout, { siteTitle } from 'components/layout'
import Link from 'next/link'
import useUser from 'lib/useUser'
import { useEffect, useState } from 'react'
import NewLanguageForm from 'components/NewLanguageForm'
import fetchJson, { FetchError } from 'lib/fetchJson'

export default function Home() {
  const { user } = useUser({
    redirectTo: '/login',
  })
  const [userLanguages, setUserLanguages] = useState([])

  useEffect(() => {
    async function getUserLanguages() {
      try {
        const response = await fetchJson<any>('/api/user/languages', {
          method: 'GET',
          headers: { 'Content-Type': 'application/json' },
        })
        setUserLanguages(response)
      } catch (error) {
        if (error instanceof FetchError) {
          console.log(error.data.message)
        } else {
          console.error('An unexpected error happened:', error)
        }
      }
    }
    getUserLanguages()
  }, [setUserLanguages])

  if (typeof user === 'undefined') {
    return (
      <Layout home>
        <h1>An error has occurred.</h1>
      </Layout>
    )
  }

  return (
{'fraction_non_alphanumeric': 0.12348993288590604, 'fraction_numerical': 0.0008948545861297539, 'mean_word_length': 2.861830742659758, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5955181', 'n_tokens_mistral': 647, 'n_tokens_neox': 644, 'n_words': 171}