pavansuresh commited on
Commit
ca72b4d
·
verified ·
1 Parent(s): dfbba46

Delete index.html

Browse files
Files changed (1) hide show
  1. index.html +0 -147
index.html DELETED
@@ -1,147 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Contract Management App</title>
7
- <script src="https://cdn.jsdelivr.net/npm/react@18.2.0/umd/react.development.js"></script>
8
- <script src="https://cdn.jsdelivr.net/npm/react-dom@18.2.0/umd/react-dom.development.js"></script>
9
- <script src="https://cdn.jsdelivr.net/npm/axios@1.4.0/dist/axios.min.js"></script>
10
- <script src="https://cdn.tailwindcss.com"></script>
11
- <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone@6.26.0/babel.min.js"></script>
12
- </head>
13
- <body>
14
- <div id="root"></div>
15
- <script type="text/babel">
16
- function App() {
17
- const [file, setFile] = React.useState(null);
18
- const [results, setResults] = React.useState(null);
19
- const [error, setError] = React.useState(null);
20
- const [contractId, setContractId] = React.useState(null);
21
- const [salesforceId, setSalesforceId] = React.useState(null);
22
- const [isAuthenticated, setIsAuthenticated] = React.useState(false);
23
-
24
- React.useEffect(() => {
25
- // Check authentication status
26
- axios.get('http://localhost:5000/')
27
- .then(response => {
28
- if (response.data.message.includes("Welcome")) {
29
- setIsAuthenticated(false);
30
- } else {
31
- setIsAuthenticated(true);
32
- }
33
- })
34
- .catch(() => setIsAuthenticated(false));
35
- }, []);
36
-
37
- const handleFileChange = (event) => {
38
- setFile(event.target.files[0]);
39
- setError(null);
40
- };
41
-
42
- const handleLogin = () => {
43
- window.location.href = 'http://localhost:5000/login';
44
- };
45
-
46
- const handleUpload = async () => {
47
- if (!file) {
48
- setError("Please select a file to upload.");
49
- return;
50
- }
51
- const formData = new FormData();
52
- formData.append('contract', file);
53
- try {
54
- const response = await axios.post('http://localhost:5000/upload_contract', formData);
55
- setResults(response.data);
56
- setContractId(response.data.contract_id);
57
- setSalesforceId(response.data.salesforce_id);
58
- setError(null);
59
- } catch (err) {
60
- setError("Error uploading contract: " + (err.response?.data?.error || err.message));
61
- }
62
- };
63
-
64
- const fetchContract = async (id) => {
65
- try {
66
- const response = await axios.get(`http://localhost:5000/get_contract/${id}`);
67
- setResults(response.data);
68
- setError(null);
69
- } catch (err) {
70
- setError("Error fetching contract: " + (err.response?.data?.error || err.message));
71
- }
72
- };
73
-
74
- return (
75
- <div className="container mx-auto p-6 max-w-4xl">
76
- <h1 className="text-3xl font-bold text-gray-800 mb-6">Contract Management App</h1>
77
- {!isAuthenticated && (
78
- <button
79
- onClick={handleLogin}
80
- className="bg-blue-500 text-white px-6 py-2 rounded-full hover:bg-blue-600 transition mb-6"
81
- >
82
- Login with Salesforce
83
- </button>
84
- )}
85
- {isAuthenticated && (
86
- <>
87
- <div className="bg-white shadow-md rounded-lg p-6 mb-6">
88
- <h2 className="text-xl font-semibold mb-4">Upload Contract</h2>
89
- <input
90
- type="file"
91
- accept=".pdf,.txt"
92
- onChange={handleFileChange}
93
- className="mb-4 block w-full text-sm text-gray-500
94
- file:mr-4 file:py-2 file:px-4
95
- file:rounded-full file:border-0
96
- file:text-sm file:font-semibold
97
- file:bg-blue-50 file:text-blue-700
98
- hover:file:bg-blue-100"
99
- />
100
- <button
101
- onClick={handleUpload}
102
- className="bg-blue-500 text-white px-6 py-2 rounded-full hover:bg-blue-600 transition"
103
- >
104
- Upload and Analyze
105
- </button>
106
- {error && <p className="text-red-500 mt-4">{error}</p>}
107
- </div>
108
- {results && (
109
- <div className="bg-white shadow-md rounded-lg p-6">
110
- <h2 className="text-xl font-semibold mb-4">
111
- Analysis Results (Contract ID: {contractId}, Salesforce ID: {salesforceId})
112
- </h2>
113
- <div className="mb-6">
114
- <h3 className="text-lg font-medium text-gray-700">Extracted Entities</h3>
115
- <ul className="list-disc pl-6 mt-2">
116
- {results.entities.map((ent, index) => (
117
- <li key={index} className="text-gray-600">
118
- <span className="font-medium">{ent.type}</span>: {ent.entity}
119
- </li>
120
- ))}
121
- </ul>
122
- </div>
123
- <div>
124
- <h3 className="text-lg font-medium text-gray-700">Compliance Analysis</h3>
125
- <ul className="list-disc pl-6 mt-2">
126
- {results.compliance.map((res, index) => (
127
- <li
128
- key={index}
129
- className={res.risk === "high_risk" ? "text-red-600" : "text-green-600"}
130
- >
131
- <span className="font-medium">{res.risk}</span> ({(res.score * 100).toFixed(2)}%): {res.text}
132
- </li>
133
- ))}
134
- </ul>
135
- </div>
136
- </div>
137
- )}
138
- </>
139
- )}
140
- </div>
141
- );
142
- }
143
-
144
- ReactDOM.render(<App />, document.getElementById('root'));
145
- </script>
146
- </body>
147
- </html>