File size: 2,327 Bytes
7d5e8c7
 
72b62d5
 
 
 
 
 
 
 
 
 
7d5e8c7
 
 
 
 
 
 
 
 
 
 
 
 
72b62d5
7d5e8c7
 
 
 
72b62d5
7d5e8c7
 
 
 
 
 
72b62d5
 
 
 
 
7d5e8c7
 
72b62d5
 
7d5e8c7
 
72b62d5
 
7d5e8c7
 
 
72b62d5
 
 
 
 
 
 
 
 
 
 
 
7d5e8c7
 
72b62d5
 
 
7d5e8c7
72b62d5
7d5e8c7
72b62d5
 
 
 
 
7d5e8c7
72b62d5
 
 
 
7d5e8c7
72b62d5
7d5e8c7
72b62d5
7d5e8c7
72b62d5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { useState } from "react"
import axios from "axios"
import FontLoader from "./components/FontLoader"
import Header from "./components/Header"
import Footer from "./components/Footer"
import VerifyForm from "./components/VerifyForm"
import ResultsPanel from "./components/ResultsPanel"
import AboutSection from "./sections/AboutSection"
import FoundersSection from "./sections/FoundersSection"
import ContactSection from "./sections/ContactSection"
import { API_URL } from "./constants"
import "./App.css"

export default function App() {
  const [claim, setClaim] = useState("")
  const [loading, setLoading] = useState(false)
  const [result, setResult] = useState(null)
  const [error, setError] = useState(null)
  const [expandedPapers, setExpandedPapers] = useState({})

  const verifyClaim = async () => {
    if (!claim.trim()) return
    setLoading(true)
    setError(null)
    setResult(null)
    setExpandedPapers({})

    try {
      const response = await axios.post(`${API_URL}/verify`, { claim }, { timeout: 90000 })
      setResult(response.data)
    } catch {
      setError("Failed to connect to API. Please try again.")
    } finally {
      setLoading(false)
    }
  }

  const handleClear = () => {
    setClaim("")
    setResult(null)
    setError(null)
    setExpandedPapers({})
  }

  const handleNavigate = (id) => {
    document.getElementById(id)?.scrollIntoView({ behavior: "smooth", block: "start" })
  }

  const togglePaper = (index) => {
    setExpandedPapers((prev) => ({ ...prev, [index]: !prev[index] }))
  }

  return (
    <>
      <FontLoader />
      <div className="app">
        <Header onNavigate={handleNavigate} />

        <main className="main">
          <VerifyForm
            claim={claim}
            loading={loading}
            onClaimChange={setClaim}
            onVerify={verifyClaim}
            onClear={handleClear}
          />

          {error && (
            <div className="error-banner" role="alert">
              {error}
            </div>
          )}

          <ResultsPanel
            result={result}
            expandedPapers={expandedPapers}
            onTogglePaper={togglePaper}
          />

          <AboutSection />
          <FoundersSection />
          <ContactSection />
        </main>

        <Footer />
      </div>
    </>
  )
}