Repository navigation
[Customer Portal][FE][Web] Add Knowledge Base Recommendations API Integration and Refactor List Layout Components #512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cloby99
merged 25 commits into
wso2-open-operations:dev-app-customer-portal
from
dileepapeiris:knowledge-based-articles
Apr 19, 2026
Merged
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
8f0aa29
Add support recommendations utilities
dileepapeiris abf1a0b
Add tests for recommendations utils
dileepapeiris f1ea490
Add knowledge base count props
dileepapeiris 18034c5
Add recommendation types for support feature
dileepapeiris c3be290
Use ConversationKnowledgeRecommendations component
dileepapeiris c0a4147
Use KB_ARTICLE_VIEW_BASE_URL constant
dileepapeiris f2b1794
Add ConversationKnowledgeRecommendations component
dileepapeiris ce3d42f
Add case knowledge base recommendations component
dileepapeiris 9945def
Add ConversationKnowledgeRecommendations test
dileepapeiris b0f11ef
Display Knowledge Base tab count
dileepapeiris 54f7cde
Render knowledge base recommendations panel
dileepapeiris 3091df4
Mock recommendations API and update KB test
dileepapeiris 65e0b0b
Eagerly fetch KB recommendations for tab count
dileepapeiris 3e4db93
Add conversation recommendations search hook
dileepapeiris 19a1431
Add conversation recommendations search key
dileepapeiris 52a8341
Replace MUI Grid with CSS Grid in ListStatGrid
dileepapeiris 4fbcab9
Use Stack for ListPageHeader layout
dileepapeiris 31badec
Use fixed epoch as default timestamp
dileepapeiris c2b20a3
Improve KB accessibility and remove unused prop
dileepapeiris c87bcb6
Limit case details width and improve query key
dileepapeiris 65d9b2d
Remove KB count callback and memoize comments
dileepapeiris 5448ee3
Show loading indicator for Knowledge Base tab
dileepapeiris 0f99652
Remove stray comment line from license header
dileepapeiris dd3e5e2
Format knowledge-base recommendation components
dileepapeiris 39d61c3
Fix license header formatting
dileepapeiris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
apps/customer-portal/webapp/src/features/support/api/useConversationRecommendationsSearch.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| // Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). | ||
| // | ||
| // WSO2 LLC. licenses this file to you under the Apache License, | ||
| // Version 2.0 (the "License"); you may not use this file except | ||
| // in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| import { useQuery, type UseQueryResult } from "@tanstack/react-query"; | ||
| import { useAsgardeo } from "@asgardeo/react"; | ||
| import { useAuthApiClient } from "@utils/useAuthApiClient"; | ||
| import { useLogger } from "@hooks/useLogger"; | ||
| import { ApiQueryKeys } from "@constants/apiConstants"; | ||
| import type { | ||
| RecommendationSearchRequest, | ||
| RecommendationSearchResponse, | ||
| } from "@features/support/types/recommendations"; | ||
|
|
||
| /** | ||
| * POST /conversations/recommendations/search — KB article recommendations for chat/case context. | ||
| * | ||
| * @param {RecommendationSearchRequest | null} payload - Request body, or null to skip. | ||
| * @param {boolean} enabled - When false, the query does not run. | ||
| * @returns {UseQueryResult<RecommendationSearchResponse, Error>} Query result. | ||
| */ | ||
| export function useConversationRecommendationsSearch( | ||
| payload: RecommendationSearchRequest | null, | ||
| enabled: boolean, | ||
| ): UseQueryResult<RecommendationSearchResponse, Error> { | ||
| const logger = useLogger(); | ||
| const { isSignedIn, isLoading: isAuthLoading } = useAsgardeo(); | ||
| const authFetch = useAuthApiClient(); | ||
|
|
||
| const msgCount = payload?.chatHistory.length ?? 0; | ||
| const firstTs = payload?.chatHistory[0]?.timestamp ?? ""; | ||
| const lastTs = payload?.chatHistory[msgCount - 1]?.timestamp ?? ""; | ||
|
|
||
| return useQuery<RecommendationSearchResponse, Error>({ | ||
| queryKey: [ | ||
| ApiQueryKeys.CONVERSATION_RECOMMENDATIONS_SEARCH, | ||
| msgCount, | ||
| firstTs, | ||
| lastTs, | ||
| ], | ||
| queryFn: async (): Promise<RecommendationSearchResponse> => { | ||
| if (!payload) { | ||
| throw new Error("Recommendation payload is required"); | ||
| } | ||
| const baseUrl = window.config?.CUSTOMER_PORTAL_BACKEND_BASE_URL; | ||
| if (!baseUrl) { | ||
| throw new Error("CUSTOMER_PORTAL_BACKEND_BASE_URL is not configured"); | ||
| } | ||
|
|
||
| const requestUrl = `${baseUrl}/conversations/recommendations/search`; | ||
| logger.debug("[useConversationRecommendationsSearch] POST", requestUrl); | ||
|
|
||
| const response = await authFetch(requestUrl, { | ||
| method: "POST", | ||
| headers: { | ||
| "Content-Type": "application/json", | ||
| }, | ||
| body: JSON.stringify(payload), | ||
| }); | ||
|
|
||
| if (!response.ok) { | ||
| throw new Error( | ||
| `Recommendations request failed: ${response.status} ${response.statusText}`, | ||
| ); | ||
| } | ||
|
|
||
| const data: RecommendationSearchResponse = await response.json(); | ||
| logger.debug("[useConversationRecommendationsSearch] Response received"); | ||
| return data; | ||
| }, | ||
| enabled: | ||
| enabled && | ||
| !!payload && | ||
| payload.chatHistory.length > 0 && | ||
| isSignedIn && | ||
| !isAuthLoading, | ||
| staleTime: 5 * 60 * 1000, | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.