From 03f86740244b623d61153f1e17ed8706acfe1897 Mon Sep 17 00:00:00 2001 From: Ho Ngoc Hai Date: Mon, 20 Apr 2026 17:07:32 +0700 Subject: [PATCH] fix(ai-advice,ui): Bearer auth for proxy gateways + un-pin contact card + VN diacritics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - AI advice handler now sends both `x-api-key` and `Authorization: Bearer` so proxy gateways (e.g. chat.trollllm.xyz) accept the request. Native Anthropic ignores the extra header. - Remove `lg:sticky lg:top-20` from listing detail contact card — sidebar now scrolls with the page. - Fix missing Vietnamese diacritics on AI estimate button: "Dinh gia AI" -> "Định giá AI", "Dang dinh gia..." -> "Đang định giá...". Tests updated accordingly. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../get-listing-ai-advice.handler.ts | 4 ++++ apps/web/components/listings/listing-detail-client.tsx | 2 +- .../valuation/__tests__/ai-estimate-button.spec.tsx | 8 ++++---- apps/web/components/valuation/ai-estimate-button.tsx | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/api/src/modules/analytics/application/queries/get-listing-ai-advice/get-listing-ai-advice.handler.ts b/apps/api/src/modules/analytics/application/queries/get-listing-ai-advice/get-listing-ai-advice.handler.ts index 0d527e4..18c2ad0 100644 --- a/apps/api/src/modules/analytics/application/queries/get-listing-ai-advice/get-listing-ai-advice.handler.ts +++ b/apps/api/src/modules/analytics/application/queries/get-listing-ai-advice/get-listing-ai-advice.handler.ts @@ -207,7 +207,11 @@ export class GetListingAiAdviceHandler method: 'POST', headers: { 'Content-Type': 'application/json', + // Support both native Anthropic (x-api-key) and proxy-style gateways + // that expect Bearer auth (e.g. chat.trollllm.xyz). Anthropic ignores + // unknown headers, so sending both is safe. 'x-api-key': args.apiKey, + Authorization: `Bearer ${args.apiKey}`, 'anthropic-version': '2023-06-01', 'anthropic-beta': 'prompt-caching-2024-07-31', }, diff --git a/apps/web/components/listings/listing-detail-client.tsx b/apps/web/components/listings/listing-detail-client.tsx index ddcf17f..b456ef9 100644 --- a/apps/web/components/listings/listing-detail-client.tsx +++ b/apps/web/components/listings/listing-detail-client.tsx @@ -375,7 +375,7 @@ export function ListingDetailClient({ listing }: ListingDetailClientProps) { {/* Sidebar */}
{/* Contact card */} - + Liên hệ diff --git a/apps/web/components/valuation/__tests__/ai-estimate-button.spec.tsx b/apps/web/components/valuation/__tests__/ai-estimate-button.spec.tsx index 8e1c32d..c1f32bd 100644 --- a/apps/web/components/valuation/__tests__/ai-estimate-button.spec.tsx +++ b/apps/web/components/valuation/__tests__/ai-estimate-button.spec.tsx @@ -20,20 +20,20 @@ describe('AiEstimateButton', () => { it('renders the button', () => { render(); - expect(screen.getByText('Dinh gia AI')).toBeInTheDocument(); + expect(screen.getByText('Định giá AI')).toBeInTheDocument(); }); it('calls mutate when clicked', async () => { const user = userEvent.setup(); render(); - await user.click(screen.getByText('Dinh gia AI')); + await user.click(screen.getByText('Định giá AI')); expect(mockMutate).toHaveBeenCalledWith('listing-1', expect.any(Object)); }); it('renders as a button element', () => { render(); - expect(screen.getByRole('button', { name: /Dinh gia AI/ })).toBeInTheDocument(); + expect(screen.getByRole('button', { name: /Định giá AI/ })).toBeInTheDocument(); }); }); @@ -51,7 +51,7 @@ describe('AiEstimateButton - loading state', () => { // This test validates the loading button text exists in the component render(); - // Component shows 'Dinh gia AI' or 'Dang dinh gia...' based on isPending + // Component shows 'Định giá AI' or 'Đang định giá...' based on isPending expect(screen.getByRole('button')).toBeInTheDocument(); }); }); diff --git a/apps/web/components/valuation/ai-estimate-button.tsx b/apps/web/components/valuation/ai-estimate-button.tsx index fac49f8..a62e9c7 100644 --- a/apps/web/components/valuation/ai-estimate-button.tsx +++ b/apps/web/components/valuation/ai-estimate-button.tsx @@ -74,7 +74,7 @@ export function AiEstimateButton({ listingId }: AiEstimateButtonProps) { d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z" /> - {mutation.isPending ? 'Dang dinh gia...' : 'Dinh gia AI'} + {mutation.isPending ? 'Đang định giá...' : 'Định giá AI'} ); }