Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions apps/web/src/features/platform-admin/platform-admin-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -762,14 +762,16 @@ function RegistrationChart({
readonly number: Intl.NumberFormat;
readonly label: string;
}) {
const firstRegistrationIndex = series.findIndex((point) => point.count > 0);
const displaySeries = firstRegistrationIndex > 0 ? series.slice(firstRegistrationIndex) : series;
const width = 460;
const height = 292;
const left = 44;
const right = 448;
const top = 20;
const bottom = 250;
const maximum = Math.max(1, ...series.map((point) => point.count));
const slot = (right - left) / Math.max(1, series.length);
const maximum = Math.max(1, ...displaySeries.map((point) => point.count));
const slot = (right - left) / Math.max(1, displaySeries.length);
const barWidth = Math.max(10, slot * 0.58);
const ticks = [0, 0.5, 1];
return (
Expand All @@ -786,7 +788,7 @@ function RegistrationChart({
</g>
);
})}
{series.map((point, index) => {
{displaySeries.map((point, index) => {
const barHeight = (point.count / maximum) * (bottom - top);
const barX = left + index * slot + (slot - barWidth) / 2;
return (
Expand All @@ -807,7 +809,7 @@ function RegistrationChart({
x={barX + barWidth / 2}
y={bottom + 25}
>
{index % 2 === 0 || series.length <= 7 ? point.month : ''}
{index % 2 === 0 || displaySeries.length <= 7 ? point.month : ''}
</text>
</g>
);
Expand Down
23 changes: 23 additions & 0 deletions apps/web/test/platform-admin-feedbacks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,29 @@ describe('platform admin feedbacks & reviews [WEB-025, WEB-027, IAM-026]', () =>
expect(await screen.findAllByText('3.129.000 ₫')).toHaveLength(2);
});

it('starts the registration chart at the first month with users', async () => {
const overview = {
...validOverview,
registrationSeries: [
{ month: '2026-02', count: 0 },
{ month: '2026-03', count: 0 },
{ month: '2026-04', count: 0 },
{ month: '2026-05', count: 0 },
{ month: '2026-06', count: 8 },
{ month: '2026-07', count: 39 },
{ month: '2026-08', count: 26 },
],
};
stubPlatformAdminServer(serverFeedbacks, overview);
renderPlatformAdmin('/vi-VN/platform-admin');

const chart = await screen.findByRole('img', { name: 'Người dùng mới' });
expect(chart.textContent).not.toContain('2026-03');
expect(chart.textContent).toContain('2026-06');
expect(chart.textContent).toContain('2026-07');
expect(chart.textContent).toContain('2026-08');
});

it('renders navigation links with the server-authoritative feedback count badge', async () => {
stubPlatformAdminServer();
renderPlatformAdmin('/vi-VN/platform-admin');
Expand Down
Loading