Skip to content

[Customer Portal][FE][Web] Introduce createdByMe filters, improve UX empty states, and make charts responsive - #488

Merged
cloby99 merged 14 commits into
wso2-open-operations:mainfrom
dileepapeiris:feat-add-users-me-filter
Apr 10, 2026
Merged

cloby99 merged 14 commits into
wso2-open-operations:mainfrom
dileepapeiris:feat-add-users-me-filter

Conversation

@dileepapeiris

@dileepapeiris dileepapeiris commented Apr 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

This pull request introduces several improvements and enhancements to the customer portal webapp, focusing on API flexibility, UI responsiveness, and user experience. The most notable changes include adding filtering options to API hooks, improving the display of empty states in support components, and making usage metric charts responsive to screen size.

API Enhancements and Filtering

  • Added a createdByMe filter option and improved the enabled flag in the useGetConversationStats and useGetProjectCasesStats hooks, allowing consumers to filter statistics by the current user's created items and control query activation. The query keys and request URLs are updated accordingly. [1] [2] [3] [4] [5] [6] [7] [8] [9]
  • The useGetProducts hook now always requests only products of class product_model by default, using a new constant in commonConstants.ts. [1] [2] [3]

UI/UX Improvements

  • Added a reusable EmptyIcon and improved the empty state display for chat history and outstanding cases lists, providing a more visually engaging and consistent user experience when there is no data. [1] [2] [3] [4]
  • Fixed a bug in AnnouncementDetailsPanel where engineer initials could display incorrectly if the assigned engineer was not an object.

Usage Metrics and Chart Responsiveness

  • Usage metric charts now display date labels that adapt to screen size (showing a more compact format on small screens), improving readability on mobile devices. This includes updates to chart data processing and formatting functions, and the use of theme breakpoints. [1] [2] [3] [4] [5] [6] [7] [8]
  • Adjusted chart margins for better appearance, especially on smaller screens.

Miscellaneous

  • Bumped the application version from 1.0.0-rc.2 to 1.0.0-rc.3 in package.json.

Summary by CodeRabbit

  • New Features

    • Added "created by me" filtering option for conversations and cases
  • Bug Fixes

    • Improved null safety for engineer assignment display
    • Enhanced loading state handling in calls view
    • Improved responsive chart label formatting for smaller screens
    • Enhanced empty state layouts with visual indicators

Import PRODUCT_CLASS and add a 'class' query parameter set to PRODUCT_CLASS.PRODUCT_MODEL in useGetProducts.ts. This ensures the products API request is filtered by the correct product model class when fetching product lists.
Introduce PRODUCT_CLASS in commonConstants.ts to mirror the backend entity ProductClass. Adds PRODUCT_MODEL = "product_model" with a const assertion so the frontend uses the same literal value as the backend for product class checks.
Add an explicit type check for assignedEngineer before accessing .name to avoid runtime errors when assignedEngineer is not an object (e.g., a string or null). Keeps the existing logic of splitting the name and falling back to an empty string if no initial is available.
Only derive engineerInitials when assignedEngineer is an object with a name. The code now checks typeof data.assignedEngineer === "object" and that a name exists before splitting to get the first initial, otherwise it falls back to an empty string. This prevents unsafe property access for cases where assignedEngineer may be a non-object or missing name.
Update apps/customer-portal/webapp/package.json version from 1.0.0-rc.2 to 1.0.0-rc.3 to mark the next release candidate for the webapp. No other changes were made.
Introduce UseGetConversationStatsOptions with createdByMe and enabled flags and accept an optional options parameter in useGetConversationStats. The queryKey now includes createdByMe, and the request URL appends ?createdBy=me when createdByMe is true. The hook's enabled condition is also controllable via options.enabled (defaults to true). These changes allow fetching user-filtered stats and optionally disabling the query.
Replace the plain text message for an empty outstanding cases list with a centered empty state UI. Imports EmptyIcon and wraps the message in a Box with vertical layout, padding, and an icon (120px width) above the typography to improve visual feedback when there are no cases.
Improve the empty state for the chat history list by adding an EmptyIcon and centering it. The change imports EmptyIcon, wraps the message in a Box with column layout, centered alignment and vertical padding, and displays a responsive icon above the existing "No chat history." text to provide a clearer visual cue when there are no items.
Adjust USAGE_LINE_CHART_MARGIN.bottom from 5 to 40 to provide extra space for x-axis labels/ticks and prevent clipping in the customer portal usage charts.
When there are no chat history items, render a centered empty-state view instead of plain text. Imports EmptyIcon and wraps the message in a Box with column-centered layout and spacing; the icon is sized and placed above the "No chat history." text to improve UX. (apps/customer-portal/webapp/src/components/support/support-overview-cards/ChatHistoryList.tsx)
Add formatDateForChart to render human-friendly chart labels (e.g. "Jan 1" or "Jan 1\n2024") and make labels responsive to small screens. Replace prior date.slice(5) usage in buildTrendFromUsages and buildDailyCoreTrend with this formatter. The new function parses ISO YYYY-MM-DD, outputs month-name/day and places the year on a new line for larger screens, with a safe fallback to MM-DD on parse error.
Adjust USAGE_LINE_CHART_MARGIN in usageMetricsConstants.ts: right margin increased from 30 to 40 and bottom margin from 5 to 40. This provides extra spacing for labels/axis/legend on the usage line chart.
@coderabbitai

coderabbitai Bot commented Apr 10, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds optional createdByMe filtering to conversation and project-case stats hooks/pages, sends createdBy=me to backend; adds PRODUCT_CLASS to product requests; introduces responsive chart date formatting and larger chart margins; improves empty-state UIs and tighter guard for engineer initials; bumps package version to rc.3.

Changes

Cohort / File(s) Summary
API Hooks & Requests
apps/customer-portal/webapp/src/api/useGetConversationStats.ts, apps/customer-portal/webapp/src/api/useGetProjectCasesStats.ts, apps/customer-portal/webapp/src/api/useGetProducts.ts
Added createdByMe?: boolean option to stats hooks; appends createdBy=me when set and adds it to React Query keys; useGetProducts now includes class=PRODUCT_MODEL query param.
Pages (pass-through of filter)
apps/customer-portal/webapp/src/pages/AllCasesPage.tsx, apps/customer-portal/webapp/src/pages/AllConversationsPage.tsx, apps/customer-portal/webapp/src/pages/ServiceRequestsPage.tsx
Pass createdByMe (derived from query params) into stats hooks so UI reflects filtered counts.
UI Components & Empty States
apps/customer-portal/webapp/src/components/support/support-overview-cards/ChatHistoryList.tsx, apps/customer-portal/webapp/src/components/support/support-overview-cards/OutstandingCasesList.tsx, apps/customer-portal/webapp/src/components/support/case-details/calls-tab/CallsPanel.tsx, apps/customer-portal/webapp/src/components/support/announcements/AnnouncementDetailsPanel.tsx
Render richer empty-state layouts with an EmptyIcon; show skeleton in CallsPanel when fetching next page; stricter runtime guard for engineer initials extraction.
Usage Metrics / Charts
apps/customer-portal/webapp/src/components/project-details/usage-metrics/UsageOverviewPanel.tsx, apps/customer-portal/webapp/src/constants/usageMetricsConstants.ts
Added responsive chart date formatting (small vs large screens) and propagated isSmallScreen into trend builders; increased chart margin right: 30→40, bottom: 5→40.
Constants & Package
apps/customer-portal/webapp/src/constants/commonConstants.ts, apps/customer-portal/webapp/package.json
Added exported PRODUCT_CLASS (PRODUCT_MODEL: "product_model"); bumped package version from 1.0.0-rc.2 → 1.0.0-rc.3.

Sequence Diagram(s)

sequenceDiagram
    participant Page as Page (AllConversations / AllCases / ServiceRequests)
    participant Hook as Hook (useGetConversationStats / useGetProjectCasesStats)
    participant Fetch as Fetch layer
    participant API as Backend API

    Page->>Hook: call hook(projectId, { createdByMe })
    Hook->>Hook: build queryKey [..., createdByMe] and build URL (append ?createdBy=me if true)
    Hook->>Fetch: fetch(URL)
    Fetch->>API: HTTP GET /...stats?createdBy=me
    API-->>Fetch: 200 OK (stats payload)
    Fetch-->>Hook: response JSON
    Hook-->>Page: supply stats data (react-query cache keyed by createdByMe)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • Rashmika998
  • v15a1

Poem

🐇 I hopped through hooks and charts today,

I tagged the stats that I made my way.
Empty icons smile, margins grow wide,
Product classes tucked safe inside.
Version bumped—rc.3—hop, hop, hooray!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The PR description comprehensively addresses the main changes including API enhancements, UI/UX improvements, and chart responsiveness updates, with specific examples and references. However, several required template sections are missing or incomplete: Purpose (no explicit issue links), Goals, Approach (no GIF/screenshot or documentation link despite UI changes), User stories, Release note, Documentation, Training, Certification, Marketing, detailed Automation tests, Security checks, Samples, Migrations, Test environment, and Learning sections.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title accurately summarizes the three main change categories: createdByMe filters for API hooks, empty state UX improvements, and responsive chart adaptations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dileepapeiris dileepapeiris self-assigned this Apr 10, 2026
@dileepapeiris dileepapeiris added Type/New Feature Represents a request or task for a new feature Type/Improvement Marks enhancements or improvements to existing features Type/Task General task that does not fit into other categories Type/UX Refers to user experience-related tasks or issues App/Customer Portal Area/Frontend Platform/Web labels Apr 10, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/customer-portal/webapp/src/components/support/support-overview-cards/OutstandingCasesList.tsx (1)

75-89: Consider extracting a shared overview empty-state component.

This layout is now duplicated across support overview cards (ChatHistoryList and OutstandingCasesList). A small shared component would reduce repetition and keep spacing/icon behavior consistent.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/customer-portal/webapp/src/components/support/support-overview-cards/OutstandingCasesList.tsx`
around lines 75 - 89, Extract the duplicated empty-state Box into a reusable
component (e.g., OverviewEmptyState) and replace the inline JSX in
OutstandingCasesList and ChatHistoryList with that component; the new component
should accept props for the icon (pass EmptyIcon), message text ("No outstanding
cases." / whatever ChatHistoryList uses) and optional styling overrides, and
preserve the existing layout (flex column, centered, py:2 and icon
sizing/margin). Update OutstandingCasesList to render <OverviewEmptyState
icon={EmptyIcon} message="No outstanding cases." /> and do the analogous
replacement in ChatHistoryList.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@apps/customer-portal/webapp/src/components/project-details/usage-metrics/UsageOverviewPanel.tsx`:
- Around line 64-82: The function formatDateForChart currently relies on
try/catch but new Date(...) can produce an "Invalid Date" without throwing, so
you must validate the date after construction and before calling
getUTCMonth/getUTCDate/getUTCFullYear; update formatDateForChart to create the
Date, check Number.isNaN(date.getTime()) (or date.getTime() === NaN check via
Number.isNaN), and if invalid return the fallback (isoDate.slice(5))
immediately; otherwise compute month/day/year and return the small-screen or
large-screen formatted string as before (preserve the isSmallScreen behavior and
the existing monthNames array) so chart labels never receive NaN values.

---

Nitpick comments:
In
`@apps/customer-portal/webapp/src/components/support/support-overview-cards/OutstandingCasesList.tsx`:
- Around line 75-89: Extract the duplicated empty-state Box into a reusable
component (e.g., OverviewEmptyState) and replace the inline JSX in
OutstandingCasesList and ChatHistoryList with that component; the new component
should accept props for the icon (pass EmptyIcon), message text ("No outstanding
cases." / whatever ChatHistoryList uses) and optional styling overrides, and
preserve the existing layout (flex column, centered, py:2 and icon
sizing/margin). Update OutstandingCasesList to render <OverviewEmptyState
icon={EmptyIcon} message="No outstanding cases." /> and do the analogous
replacement in ChatHistoryList.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e2317b88-26c8-4901-9278-0ec0aa8f74b4

📥 Commits

Reviewing files that changed from the base of the PR and between a38264a and 3f991ee.

📒 Files selected for processing (13)
  • apps/customer-portal/webapp/package.json
  • apps/customer-portal/webapp/src/api/useGetConversationStats.ts
  • apps/customer-portal/webapp/src/api/useGetProducts.ts
  • apps/customer-portal/webapp/src/api/useGetProjectCasesStats.ts
  • apps/customer-portal/webapp/src/components/project-details/usage-metrics/UsageOverviewPanel.tsx
  • apps/customer-portal/webapp/src/components/support/announcements/AnnouncementDetailsPanel.tsx
  • apps/customer-portal/webapp/src/components/support/support-overview-cards/ChatHistoryList.tsx
  • apps/customer-portal/webapp/src/components/support/support-overview-cards/OutstandingCasesList.tsx
  • apps/customer-portal/webapp/src/constants/commonConstants.ts
  • apps/customer-portal/webapp/src/constants/usageMetricsConstants.ts
  • apps/customer-portal/webapp/src/pages/AllCasesPage.tsx
  • apps/customer-portal/webapp/src/pages/AllConversationsPage.tsx
  • apps/customer-portal/webapp/src/pages/ServiceRequestsPage.tsx

Render a CallsListSkeleton when isFetchingNextPage is true instead of immediately showing CallRequestList. The change conditionally wraps CallRequestList with an isFetchingNextPage check so the skeleton displays during pagination loads; pagination UI remains unchanged.
@dileepapeiris dileepapeiris changed the title Feat add users me filter [Customer Portal][FE][Web] Introduce createdByMe filters, improve UX empty states, and make charts responsive Apr 10, 2026
@cloby99
cloby99 merged commit 83a4960 into wso2-open-operations:main Apr 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

App/Customer Portal Area/Frontend Platform/Web Type/Improvement Marks enhancements or improvements to existing features Type/New Feature Represents a request or task for a new feature Type/Task General task that does not fit into other categories Type/UX Refers to user experience-related tasks or issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants