Skip to content

Conversation

@michnowak
Copy link
Collaborator

@michnowak michnowak commented Nov 5, 2025

What does this PR do?

  • Feature enhancement
  • Refactoring

Key Changes

  • Layout Configuration: Added support for vertical/horizontal layout configuration in Payments Summary Block. The layout can now be controlled via CMS configuration field, allowing cards to be displayed either stacked vertically or side-by-side horizontally.

  • Optional Fields Support: Made overdue and toBePaid fields optional in the Payments Summary Block. If a field is not configured in CMS, the corresponding card is not displayed. This allows displaying only one card when needed (e.g., only overdue or only toBePaid).

  • Chart Integration: Integrated chart functionality directly into Payments Summary Block (similar to Orders Summary Block architecture). The chart is now an optional part of the Payments Summary Block instead of being a separate Payments History Block. This provides better layout control:

    • When showChart is true: Cards and chart are displayed side-by-side (flex-col lg:flex-row)
    • When showChart is false or chart is not configured: Cards stretch to full width (flex-col md:flex-row), allowing payments-summary to take full width when payments-history block is removed

Summary by CodeRabbit

  • New Features

    • Orders Summary: chart visibility toggle and layout option (vertical/horizontal).
    • Payments Summary: stacked-bar chart support, chart visibility toggle and layout option; demo story showcasing chart.
  • Changes

    • Payments Summary: overdue and to-be-paid sections now optional.
    • Mocks/Pages: Payments Summary promoted to top slot of invoice-list mocks.
    • Safety: several detail blocks made optional and mappers now guard against missing data.

@vercel
Copy link

vercel bot commented Nov 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
o2s-docs Skipped Skipped Nov 14, 2025 10:31am

@marcinkrasowski marcinkrasowski self-requested a review November 12, 2025 07:24
@michnowak michnowak marked this pull request as ready for review November 12, 2025 10:18
@vercel vercel bot temporarily deployed to Preview – o2s-docs November 13, 2025 09:59 Inactive
@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2025

Walkthrough

Adds optional chart visibility and layout controls to orders-summary and payments-summary blocks; augments models and mappers to propagate showChart and layout; updates UI components and stories to conditionally render charts and support vertical/horizontal layouts; introduces payments chart aggregation and mock/GraphQL adjustments.

Changes

Cohort / File(s) Change Summary
Orders-summary model
packages/blocks/orders-summary/src/api-harmonization/orders-summary.model.ts, packages/framework/src/modules/cms/models/blocks/orders-summary.model.ts
Added optional showChart?: boolean on chart and top-level `layout?: 'vertical'
Orders-summary mapper & Strapi fragment
packages/blocks/orders-summary/src/api-harmonization/orders-summary.mapper.ts, packages/integrations/strapi-cms/.../OrdersSummary.graphql, packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.orders-summary.mapper.ts
Map chart.showChart from CMS; added showChart: true in Strapi mapper and hardcoded chart title/labels; GraphQL fragment now requests showChart; layout set to 'horizontal' in mapper
Orders-summary UI & story
packages/blocks/orders-summary/src/frontend/OrdersSummary.client.tsx, packages/blocks/orders-summary/src/frontend/OrdersSummary.client.stories.tsx
Component conditionally renders chart based on data.chart.showChart and uses layout to adjust arrangement; Default story now sets chart.showChart: true
Payments-summary model & framework model
packages/blocks/payments-summary/src/api-harmonization/payments-summary.model.ts, packages/framework/src/modules/cms/models/blocks/payments-summary.model.ts
Made overdue and toBePaid optional; added top-level `layout?: 'vertical'
Payments-summary mapper
packages/blocks/payments-summary/src/api-harmonization/payments-summary.mapper.ts
Added mapChartData helper to build rolling-month BarData[], conditional population of fields, chart assembly guarded by label presence, and layout assignment from CMS
Payments-summary UI & stories
packages/blocks/payments-summary/src/frontend/PaymentsSummary.client.tsx, packages/blocks/payments-summary/src/frontend/PaymentsSummary.client.stories.tsx
Added dynamic import for StackedBarChart, conditional chart rendering when chart.showChart is true, layout prop support (vertical/horizontal), updated stories (Default args include layout, accessToken, locale; new WithChart story)
Mocked CMS — orders & payments
packages/integrations/mocked/src/modules/cms/mappers/blocks/cms.orders-summary.mapper.ts, packages/integrations/mocked/src/modules/cms/mappers/blocks/cms.payments-summary.mapper.ts
Orders mock: added chart.showChart: true across locales. Payments mock: added chart config to EN mock and layout values to PL (horizontal) and DE (vertical)
Mocked pages
packages/integrations/mocked/src/modules/cms/mappers/mocks/pages/invoice-list.page.ts
Moved PaymentsSummaryBlock into top slot and removed PaymentsHistoryBlock from page mocks (EN/DE/PL)

Sequence Diagram(s)

sequenceDiagram
    participant Strapi/CMS
    participant Mapper
    participant Component
    participant UI
    Strapi/CMS->>Mapper: Return block including chart.showChart and layout
    Mapper->>Component: Supply OrdersSummaryBlock / PaymentsSummaryBlock (with chart, layout)
    alt chart.showChart == true
        Component->>UI: Render chart card + info cards (layout may affect ordering)
    else
        Component->>UI: Render info cards only (use layout to arrange)
    end
Loading
sequenceDiagram
    participant CMS
    participant PaymentsMapper
    participant mapChartData
    participant PaymentsComponent
    CMS->>PaymentsMapper: Provide invoices, chart config, layout
    PaymentsMapper->>mapChartData: Compute BarData[] with months window and segments
    mapChartData-->>PaymentsMapper: Return BarData[]
    PaymentsMapper->>PaymentsComponent: Return PaymentsSummaryBlock with chart & layout
    alt chart.showChart == true
        PaymentsComponent->>UI: Dynamically import StackedBarChart and render chart card + info cards
    else
        PaymentsComponent->>UI: Render info cards arranged by layout only
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Areas needing extra attention:
    • packages/blocks/payments-summary/src/api-harmonization/payments-summary.mapper.ts — correctness of rolling-month window, segmentation, numeric summing/formatting, edge cases with missing months
    • packages/blocks/payments-summary/src/frontend/PaymentsSummary.client.tsx — dynamic import behavior, conditional rendering paths, and responsive/layout CSS/classes
    • Public API changes in models (overdue/toBePaid optionality, new chart/layout fields) — verify consumers and typings updated
    • Strapi mapper hardcoded labels/title — confirm intentional or TODO for proper mapping

Poem

🐰 I hopped through models, mapper, and chart,
Tucked showChart in with a confident start.
Layouts now pivot, vertical or wide,
Bars roll their months like tumbling tide.
Cheers from this rabbit — data and art! 🎨📈

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description covers key changes comprehensively: layout configuration, optional fields, and chart integration. However, it omits required template sections including Related Ticket(s), How to test, and Media.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title 'feat: order summary chart visibility' specifically refers to chart visibility control, but the PR encompasses broader changes including layout configuration, optional fields, and payments summary chart integration.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/order-summary-chart-visibility

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/blocks/orders-summary/src/frontend/OrdersSummary.client.tsx (1)

128-209: Guard against missing chart data before reading showChart.
Line 129 dereferences data.chart.showChart without confirming data.chart exists. When CMS disables the chart entirely (which this PR is supposed to support), data.chart can be undefined, causing a runtime crash on render. Please derive showChart via optional chaining and only render the chart block once the chart object is present.

@@
-    return (
+    const chart = data.chart;
+    const showChart = chart?.showChart ?? false;
+
+    return (
@@
-                    <div
-                        className={cn('w-full flex gap-6', data.chart.showChart ? 'flex-col lg:flex-row' : 'flex-col')}
-                    >
-                        {data.chart.showChart ? (
+                    <div className={cn('w-full flex gap-6', showChart ? 'flex-col lg:flex-row' : 'flex-col')}>
+                        {showChart && chart ? (
@@
-                                    <InfoCard
+                                    <InfoCard
@@
-                                <Card className="h-full w-full">
+                                <Card className="h-full w-full">
@@
-                                        <Typography variant="subtitle">{data.chart.title}</Typography>
+                                        <Typography variant="subtitle">{chart.title}</Typography>
@@
-                                        <DoubleLineChart
-                                            chartData={data.chart.data}
-                                            legend={data.chart.legend}
+                                        <DoubleLineChart
+                                            chartData={chart.data}
+                                            legend={chart.legend}
🧹 Nitpick comments (1)
packages/blocks/payments-summary/src/frontend/PaymentsSummary.client.stories.tsx (1)

70-164: Consider reducing story duplication.

The WithChart story duplicates most of the Default story configuration (overdue, toBePaid, routing, accessToken, locale). To improve maintainability, consider extracting common configuration into a shared base object.

Example refactor:

+const basePaymentsConfig = {
+    routing: baseRouting,
+    __typename: 'PaymentsSummaryBlock' as const,
+    currency: 'EUR',
+    layout: 'vertical' as const,
+    overdue: {
+        title: 'Overdue',
+        link: {
+            label: 'Pay online',
+            icon: 'ArrowUpRight',
+            url: '',
+        },
+        description: '599 days overdue',
+        value: {
+            value: 5544.828051951577,
+            currency: 'EUR',
+        },
+        isOverdue: true,
+        icon: 'ThumbsUp',
+    },
+    toBePaid: {
+        title: 'To be paid',
+        link: {
+            label: 'Pay online',
+            icon: 'ArrowUpRight',
+            url: '',
+        },
+        description: 'New and overdue',
+        value: {
+            value: 1234.56,
+            currency: 'EUR',
+        },
+        icon: 'CreditCard',
+    },
+    accessToken: baseAccessToken,
+    locale: 'en',
+};

 export const Default: Story = {
-    args: {
-        routing: baseRouting,
-        __typename: 'PaymentsSummaryBlock',
-        id: 'payments-summary-1',
-        currency: 'EUR',
-        layout: 'vertical',
-        overdue: { ... },
-        toBePaid: { ... },
-        accessToken: baseAccessToken,
-        locale: 'en',
+    args: {
+        ...basePaymentsConfig,
+        id: 'payments-summary-1',
     },
 };

 export const WithChart: Story = {
     args: {
-        routing: baseRouting,
-        __typename: 'PaymentsSummaryBlock',
-        id: 'payments-summary-7',
-        currency: 'EUR',
-        layout: 'vertical',
-        overdue: { ... },
-        toBePaid: { ... },
+        ...basePaymentsConfig,
+        id: 'payments-summary-7',
         chart: {
             title: '6-months history',
             // ... chart config
         },
-        accessToken: baseAccessToken,
-        locale: 'en',
     },
 };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 485731c and 47ba11e.

⛔ Files ignored due to path filters (1)
  • packages/integrations/strapi-cms/generated/strapi.ts is excluded by !**/generated/**
📒 Files selected for processing (17)
  • packages/blocks/orders-summary/src/api-harmonization/orders-summary.mapper.ts (1 hunks)
  • packages/blocks/orders-summary/src/api-harmonization/orders-summary.model.ts (1 hunks)
  • packages/blocks/orders-summary/src/frontend/OrdersSummary.client.stories.tsx (1 hunks)
  • packages/blocks/orders-summary/src/frontend/OrdersSummary.client.tsx (2 hunks)
  • packages/blocks/payments-summary/src/api-harmonization/payments-summary.mapper.ts (3 hunks)
  • packages/blocks/payments-summary/src/api-harmonization/payments-summary.model.ts (3 hunks)
  • packages/blocks/payments-summary/src/frontend/PaymentsSummary.client.stories.tsx (2 hunks)
  • packages/blocks/payments-summary/src/frontend/PaymentsSummary.client.tsx (2 hunks)
  • packages/framework/src/modules/cms/models/blocks/orders-summary.model.ts (1 hunks)
  • packages/framework/src/modules/cms/models/blocks/payments-summary.model.ts (1 hunks)
  • packages/integrations/mocked/src/modules/cms/mappers/blocks/cms.orders-summary.mapper.ts (3 hunks)
  • packages/integrations/mocked/src/modules/cms/mappers/blocks/cms.payments-summary.mapper.ts (2 hunks)
  • packages/integrations/mocked/src/modules/cms/mappers/mocks/pages/invoice-list.page.ts (3 hunks)
  • packages/integrations/strapi-cms/src/modules/cms/graphql/fragments/blocks/OrdersSummary.graphql (1 hunks)
  • packages/integrations/strapi-cms/src/modules/cms/graphql/fragments/blocks/PaymentsSummary.graphql (1 hunks)
  • packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.orders-summary.mapper.ts (1 hunks)
  • packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.payments-summary.mapper.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (6)
packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.payments-summary.mapper.ts (1)
packages/integrations/strapi-cms/src/modules/cms/mappers/cms.information-card.mapper.ts (1)
  • mapInfoCard (5-17)
packages/blocks/orders-summary/src/frontend/OrdersSummary.client.tsx (3)
packages/ui/src/lib/utils.ts (1)
  • cn (5-7)
packages/framework/src/utils/models/info-card.ts (1)
  • InfoCard (3-9)
packages/framework/src/utils/models/price.ts (1)
  • Price (3-7)
packages/integrations/mocked/src/modules/cms/mappers/blocks/cms.payments-summary.mapper.ts (2)
packages/framework/src/modules/cms/models/blocks/payments-summary.model.ts (1)
  • PaymentsSummaryBlock (13-18)
packages/blocks/payments-summary/src/api-harmonization/payments-summary.model.ts (1)
  • PaymentsSummaryBlock (5-44)
packages/framework/src/modules/cms/models/blocks/payments-summary.model.ts (2)
packages/blocks/payments-summary/src/api-harmonization/payments-summary.model.ts (1)
  • PaymentsSummaryBlock (5-44)
packages/framework/src/utils/models/info-card.ts (1)
  • InfoCard (3-9)
packages/blocks/payments-summary/src/api-harmonization/payments-summary.mapper.ts (3)
packages/framework/src/modules/cms/models/blocks/payments-summary.model.ts (1)
  • PaymentsSummaryBlock (13-18)
packages/blocks/payments-summary/src/api-harmonization/payments-summary.model.ts (2)
  • PaymentsSummaryBlock (5-44)
  • BarData (46-52)
packages/framework/src/modules/invoices/invoices.model.ts (2)
  • Invoices (24-24)
  • Invoice (7-22)
packages/blocks/payments-summary/src/frontend/PaymentsSummary.client.tsx (4)
packages/ui/src/lib/utils.ts (1)
  • cn (5-7)
packages/framework/src/utils/models/info-card.ts (1)
  • InfoCard (3-9)
packages/framework/src/utils/models/price.ts (1)
  • Price (3-7)
packages/ui/src/components/DynamicIcon/DynamicIcon.tsx (1)
  • DynamicIcon (8-38)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: deploy-preview
🔇 Additional comments (15)
packages/integrations/mocked/src/modules/cms/mappers/mocks/pages/invoice-list.page.ts (3)

71-78: Consistent structural change across locales.

The DE locale configuration mirrors the EN locale changes correctly—PaymentsSummaryBlock moved to the top slot with empty left/right slots.


117-124: Consistent structural change across all locales.

The PL locale configuration correctly maintains the same structure as EN and DE locales—PaymentsSummaryBlock in the top slot with empty left/right slots. This consistency ensures uniform behavior across all supported locales.


25-32: The mock data properly demonstrates the new chart configuration—no changes needed.

The new optional fields (showChart, layout) are correctly configured in the mapper file (cms.payments-summary.mapper.ts). The invoice-list.page.ts file appropriately defines only the page structure (slots and block references), while the mapper file handles block-level configuration with the new fields properly set (showChart: true for EN, layout: 'horizontal' for PL, layout: 'vertical' for DE). The structural reorganization is correct and aligns with the PR objectives.

packages/integrations/mocked/src/modules/cms/mappers/blocks/cms.payments-summary.mapper.ts (1)

27-35: Verify intentional locale configuration differences.

The EN block includes chart configuration while PL and DE blocks don't. Similarly, PL and DE blocks have layout configuration while EN doesn't. If this is intentional to test different configurations, consider adding comments to clarify the test scenarios.

packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.orders-summary.mapper.ts (1)

38-38: LGTM!

The mapping of showChart from the component to the chart object is straightforward and aligns with the GraphQL fragment changes.

packages/blocks/orders-summary/src/frontend/OrdersSummary.client.stories.tsx (1)

85-85: LGTM!

Adding showChart: true to the story provides appropriate test data for the new chart visibility feature.

packages/integrations/strapi-cms/src/modules/cms/graphql/fragments/blocks/OrdersSummary.graphql (1)

9-9: LGTM!

The showChart field addition extends the GraphQL fragment appropriately and aligns with the corresponding mapper that nests this field within the chart object.

packages/framework/src/modules/cms/models/blocks/orders-summary.model.ts (1)

20-20: LGTM!

The optional showChart field is appropriately typed and maintains backward compatibility with existing code.

packages/integrations/mocked/src/modules/cms/mappers/blocks/cms.orders-summary.mapper.ts (1)

25-25: LGTM!

The showChart: true field is consistently added across all locale blocks (EN, DE, PL), providing uniform test data.

Also applies to: 73-73, 121-121

packages/integrations/strapi-cms/src/modules/cms/graphql/fragments/blocks/PaymentsSummary.graphql (2)

4-4: LGTM!

The layout field addition enables layout configuration for the payments summary block.


11-19: LGTM!

The chart object with comprehensive configuration fields (labels, visibility, and display options) properly extends the fragment to support chart integration into the payments summary block.

packages/blocks/orders-summary/src/api-harmonization/orders-summary.model.ts (1)

36-36: LGTM!

The optional showChart field in the chart object extends the public API appropriately while maintaining backward compatibility.

packages/blocks/payments-summary/src/frontend/PaymentsSummary.client.stories.tsx (3)

14-27: LGTM! Good refactoring to centralize shared configuration.

The introduction of baseRouting and baseAccessToken constants effectively reduces duplication across stories. The JWT token is appropriately a mock token with test data (Jane Doe, example.com), which is suitable for Storybook development context.


36-50: Question: Is the 'ThumbsUp' icon intentional for overdue payments?

The overdue block uses icon: 'ThumbsUp' (line 49) while indicating a negative state with isOverdue: true and '599 days overdue'. The ThumbsUp icon typically conveys approval or positive sentiment, which seems semantically inconsistent with overdue debt.

If this is placeholder data for Storybook demonstration purposes, consider using a more contextually appropriate icon (e.g., 'AlertCircle', 'Clock', or 'AlertTriangle').


106-160: LGTM! Chart configuration is well-structured.

The chart configuration is complete and correctly structured:

  • String values for monetary amounts appropriately avoid floating-point precision issues
  • monthsToShow: 6 correctly matches the chartData array length
  • All required fields (title, labels, chartData, showChart) are present

@michnowak michnowak force-pushed the feature/order-summary-chart-visibility branch from 47ba11e to 35e2d6b Compare November 13, 2025 10:13
@vercel vercel bot temporarily deployed to Preview – o2s-docs November 13, 2025 16:54 Inactive
@vercel vercel bot temporarily deployed to Preview – o2s-docs November 13, 2025 17:00 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 47ba11e and 0f389f7.

⛔ Files ignored due to path filters (1)
  • packages/integrations/strapi-cms/generated/strapi.ts is excluded by !**/generated/**
📒 Files selected for processing (1)
  • packages/integrations/strapi-cms/src/modules/cms/mappers/blocks/cms.orders-summary.mapper.ts (1 hunks)

@vercel vercel bot temporarily deployed to Preview – o2s-docs November 14, 2025 09:40 Inactive
@vercel vercel bot temporarily deployed to Preview – o2s-docs November 14, 2025 10:31 Inactive
@marcinkrasowski marcinkrasowski changed the title Feature/order summary chart visibility feat: order summary chart visibility Nov 14, 2025
@michnowak michnowak merged commit 246a450 into main Nov 21, 2025
9 checks passed
@michnowak michnowak deleted the feature/order-summary-chart-visibility branch November 21, 2025 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants