From f2f6a533d9764675a7c116b416542983db43dacf Mon Sep 17 00:00:00 2001 From: Yunus Barlas Date: Sun, 3 Dec 2023 13:50:12 +0300 Subject: [PATCH] Fix company report problem and separate report and company list endpoints in example env (#73) --- ui/.env.example | 3 ++- ui/src/report-generation/utils/fetch-example-companies.ts | 7 +++++-- ui/src/report-generation/utils/fetch-report.ts | 7 +++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ui/.env.example b/ui/.env.example index 2609edb..c6abed7 100644 --- a/ui/.env.example +++ b/ui/.env.example @@ -2,4 +2,5 @@ VITE_UNSTRUCTURED_IMPORT_BACKEND_ENDPOINT=http://localhost:7860/ VITE_KG_CHAT_BACKEND_ENDPOINT=ws://localhost:7860/text2text VITE_HAS_API_KEY_ENDPOINT=http://localhost:7860/hasapikey VITE_KG_CHAT_SAMPLE_QUESTIONS_ENDPOINT=http://localhost:7860/questionProposalsForCurrentDb -VITE_REPORT_DATA_ENDPOINT=http://localhost:7860 +VITE_REPORT_DATA_ENDPOINT=http://localhost:7860/companyReport +VITE_REPORT_COMPANY_LIST_ENDPOINT=http://localhost:7860/companyReport/list diff --git a/ui/src/report-generation/utils/fetch-example-companies.ts b/ui/src/report-generation/utils/fetch-example-companies.ts index cfa2361..970981c 100644 --- a/ui/src/report-generation/utils/fetch-example-companies.ts +++ b/ui/src/report-generation/utils/fetch-example-companies.ts @@ -6,8 +6,11 @@ type JSONResponse = { }; export const getCompanies = async () => { - const response = await fetch( - `${import.meta.env.VITE_REPORT_DATA_ENDPOINT}/companyReport/list`, + const LIST_EXAMPLE_COMPANIES_URI = + import.meta.env.VITE_REPORT_COMPANY_LIST_ENDPOINT ?? + "http://localhost:7860/companyReport/list"; + + const response = await fetch(LIST_EXAMPLE_COMPANIES_URI, { method: "POST", } diff --git a/ui/src/report-generation/utils/fetch-report.ts b/ui/src/report-generation/utils/fetch-report.ts index b59b946..cf2789f 100644 --- a/ui/src/report-generation/utils/fetch-report.ts +++ b/ui/src/report-generation/utils/fetch-report.ts @@ -11,8 +11,11 @@ export const getReportData = async (company: string, apiKey?: string) => { api_key: apiKey ? apiKey : undefined, }; - const response = await fetch( - `${import.meta.env.VITE_REPORT_DATA_ENDPOINT}/companyReport`, + const COMPANY_REPORT_URI = + import.meta.env.VITE_REPORT_DATA_ENDPOINT ?? + "http://localhost:7860/companyReport"; + + const response = await fetch(COMPANY_REPORT_URI, { method: "POST", headers: {