File size: 1,165 Bytes
d51321a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { useState } from 'react';
import Header from './components/Header';
import Hero from './components/Hero';
import Results from './components/Results';
import { analyzeRepository } from './services/uvifyApi';
import type { UvifyResult } from './types/uvify';

function App() {
  const [results, setResults] = useState<UvifyResult[]>([]);
  const [isLoading, setIsLoading] = useState(false);
  const [error, setError] = useState<string>('');
  const [currentSource, setCurrentSource] = useState<string>('');

  const handleAnalyze = async (source: string) => {
    setIsLoading(true);
    setError('');
    setResults([]);
    setCurrentSource(source);

    try {
      const data = await analyzeRepository(source);
      setResults(data);
    } catch (err) {
      setError(err instanceof Error ? err.message : 'Failed to analyze repository');
    } finally {
      setIsLoading(false);
    }
  };

  return (
    <div className="min-h-screen bg-gray-900 text-white">
      <Header />
      <Hero onAnalyze={handleAnalyze} isLoading={isLoading} />
      <Results results={results} source={currentSource} error={error} />
    </div>
  );
}

export default App