Álvaro Valenzuela Valdes commited on
Commit
6866faa
·
1 Parent(s): 9c9cca9

feat: make top institutions clickable to filter tender search

Browse files
frontend/app/page.tsx CHANGED
@@ -178,10 +178,14 @@ export default function HomePage() {
178
  window.history.pushState({}, '', `?tab=agent_analysis`);
179
  };
180
 
181
- const handleFilterClick = (type: "sector" | "region", value: string) => {
182
  setSearchKeyword(value);
183
  setActiveTab("Tender Search");
184
- handleSearch({ keyword: value });
 
 
 
 
185
  window.history.pushState({}, '', `?tab=tender_search&q=${encodeURIComponent(value)}`);
186
  };
187
 
@@ -352,7 +356,7 @@ export default function HomePage() {
352
  )}
353
  {activeTab === "Proposal Draft" && <ProposalDraft proposal={analysisResult?.proposal_draft ?? ""} />}
354
  {activeTab === "History" && <AnalysisHistory history={analysisHistory} searchHistory={searchHistory} />}
355
- {activeTab === "Database" && <DBManager />}
356
  {activeTab === "About" && <SystemInfo />}
357
  </div>
358
  </main>
 
178
  window.history.pushState({}, '', `?tab=agent_analysis`);
179
  };
180
 
181
+ const handleFilterClick = (type: "sector" | "region" | "buyer", value: string) => {
182
  setSearchKeyword(value);
183
  setActiveTab("Tender Search");
184
+ if (type === "buyer") {
185
+ handleSearch({ buyer: value });
186
+ } else {
187
+ handleSearch({ keyword: value });
188
+ }
189
  window.history.pushState({}, '', `?tab=tender_search&q=${encodeURIComponent(value)}`);
190
  };
191
 
 
356
  )}
357
  {activeTab === "Proposal Draft" && <ProposalDraft proposal={analysisResult?.proposal_draft ?? ""} />}
358
  {activeTab === "History" && <AnalysisHistory history={analysisHistory} searchHistory={searchHistory} />}
359
+ {activeTab === "Database" && <DBManager onFilterClick={handleFilterClick} />}
360
  {activeTab === "About" && <SystemInfo />}
361
  </div>
362
  </main>
frontend/components/DBManager.tsx CHANGED
@@ -4,7 +4,11 @@ import { useState, useEffect } from "react";
4
  import { fetchDetailedDbStats, syncDatabase, clearDatabase } from "../lib/api";
5
  import BrandLoader from "./BrandLoader";
6
 
7
- export default function DBManager() {
 
 
 
 
8
  const [stats, setStats] = useState<any>(null);
9
  const [isLoading, setIsLoading] = useState(true);
10
  const [isActionInProgress, setIsActionInProgress] = useState(false);
@@ -126,10 +130,19 @@ export default function DBManager() {
126
  </h3>
127
  <div className="space-y-4">
128
  {stats?.top_buyers?.map((buyer: any, idx: number) => (
129
- <div key={idx} className="flex items-center justify-between p-4 rounded-2xl bg-white/[0.03] border border-white/5">
130
- <span className="text-sm text-slate-300 truncate max-w-[250px] font-medium">{buyer.name}</span>
131
- <span className="text-lg font-black text-cyan font-mono">{buyer.count}</span>
132
- </div>
 
 
 
 
 
 
 
 
 
133
  ))}
134
  {(!stats?.top_buyers || stats.top_buyers.length === 0) && (
135
  <p className="text-slate-600 italic text-sm py-4">No institutions found in local database.</p>
 
4
  import { fetchDetailedDbStats, syncDatabase, clearDatabase } from "../lib/api";
5
  import BrandLoader from "./BrandLoader";
6
 
7
+ type Props = {
8
+ onFilterClick?: (type: "sector" | "region" | "buyer", value: string) => void;
9
+ };
10
+
11
+ export default function DBManager({ onFilterClick }: Props) {
12
  const [stats, setStats] = useState<any>(null);
13
  const [isLoading, setIsLoading] = useState(true);
14
  const [isActionInProgress, setIsActionInProgress] = useState(false);
 
130
  </h3>
131
  <div className="space-y-4">
132
  {stats?.top_buyers?.map((buyer: any, idx: number) => (
133
+ <button
134
+ key={idx}
135
+ onClick={() => onFilterClick?.("buyer", buyer.name)}
136
+ className="w-full flex items-center justify-between p-4 rounded-2xl bg-white/[0.03] border border-white/5 hover:bg-white/[0.08] hover:border-cyan/30 transition-all group/row cursor-pointer text-left"
137
+ >
138
+ <span className="text-sm text-slate-300 truncate max-w-[250px] font-medium group-hover/row:text-white transition-colors">
139
+ {buyer.name}
140
+ </span>
141
+ <div className="flex items-center gap-3">
142
+ <span className="text-lg font-black text-cyan font-mono">{buyer.count}</span>
143
+ <span className="opacity-0 group-hover/row:opacity-100 transition-opacity text-cyan">📡</span>
144
+ </div>
145
+ </button>
146
  ))}
147
  {(!stats?.top_buyers || stats.top_buyers.length === 0) && (
148
  <p className="text-slate-600 italic text-sm py-4">No institutions found in local database.</p>