Skip to content

refactor(admin): centralize date formatting, fix null-timestamp rendering, and correct table filter attribute#1746

Open
Shreyag02 wants to merge 6 commits into
mainfrom
chore/unify-date-format-filter-fixes
Open

refactor(admin): centralize date formatting, fix null-timestamp rendering, and correct table filter attribute#1746
Shreyag02 wants to merge 6 commits into
mainfrom
chore/unify-date-format-filter-fixes

Conversation

@Shreyag02

@Shreyag02 Shreyag02 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Standardizes date display across the Admin console, centralizes formatting into a shared helper, fixes a null-timestamp rendering bug, and re-enables table column filters that were silently broken. All changes align the admin UI with the Apsara design system.

Changes

  • Shared helper: added DATE_FORMAT and formatTimestamp to connect-timestamp.ts as the single source of truth for the format string and null-timestamp guard; migrated 32 call sites to it (removing 11 YYYY-MM-DD columns, 6 toLocaleString usages, and 15 dayjs imports).
  • Unified format: all admin dates now use the Apsara default DD MMM YYYY (e.g. 10 Jul 2026); preferences kept its time part (DD MMM YYYY hh:mm:ss A).
  • Bug fix (01 Jan 1970): prior code guarded only missing timestamps, not zero/null-time ({ seconds: 0 }), which rendered as 01 Jan 1970 (or Invalid Date). formatTimestamp centralizes the isNullTimestamp guard so these show - — across columns, side panels, PAT, audit logs, and API details.
  • Filter fix: replaced the invalid filterVariant prop with Apsara's filterType in 20 places, restoring column filtering.
  • Review feedback: import the shared helper via the ~/admin path alias (not relative paths); call formatTimestamp(getValue()) inline in column defs rather than through a wrapper helper.
  • Cleanup: wired plan-card to the client SDK's DEFAULT_DATE_SHORT_FORMAT; removed the dead getFormattedDateString helper and its non-canonical DEFAULT_DATE_FORMAT in apps/admin.

Technical Details

  • DD MMM YYYY is Apsara's built-in default (DatePicker/RangePicker) and matches the client SDK's DEFAULT_DATE_FORMAT — the canonical format, not an arbitrary choice.
  • filterVariant is not a valid DataTableColumnDef prop: accepted by the object literal but ignored at runtime (filters didn't work) and it threw 3 TS errors in products/columns.tsx. filterType clears the errors and restores filtering.
  • Admin and client SDK bundles keep their own format constants by design (independent entrypoints; client → admin imports are disallowed). Short (DD MMM) and time-only (hh:mm A) formats left as-is.
  • Scope: 30 files — 26 in web/sdk/admin/views/, 1 helper in web/sdk/admin/utils/, 1 in web/sdk/client/, 2 in web/apps/admin/. No API, data-fetching, or behavioral changes beyond formatting, the null-timestamp fix, and filter enablement.

Test Plan

  • Manual testing — dates render as DD MMM YYYY across org, user, product, plan, invoice, token, webhook, PAT, audit-log, and side-panel views; zero/missing timestamps now show -; affected columns are filterable again.
  • Build & type checking — full tsc clean on all changed files (no new errors vs. baseline); eslint shows only pre-existing warnings.

SQL Safety (if your PR touches *_repository.go or goqu.*)

N/A

@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment Jul 15, 2026 6:57am

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f07c2c78-1a58-48d7-8d60-fbedf91f4e32

📥 Commits

Reviewing files that changed from the base of the PR and between 3149d4b and 6b79f8c.

📒 Files selected for processing (3)
  • web/sdk/admin/views/audit-logs/sidepanel-details.tsx
  • web/sdk/admin/views/users/details/layout/side-panel-details.tsx
  • web/sdk/admin/views/users/details/layout/side-panel-membership.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • web/sdk/admin/views/users/details/layout/side-panel-details.tsx
  • web/sdk/admin/views/users/details/layout/side-panel-membership.tsx
  • web/sdk/admin/views/audit-logs/sidepanel-details.tsx

📝 Walkthrough

Summary by CodeRabbit

  • Enhancements

    • Standardized date/time formatting across admin tables, detail panels, invoices, plans, users, organizations, audit logs, billing views, and plan cards.
    • Missing or null timestamps now consistently display as “-”.
    • Trial-end dates in plan cards now respect the configured short-date format (with a default fallback).
  • Bug Fixes

    • Improved filtering behavior across admin views by updating text/date filter configuration (e.g., switching from variant-based to type-based filtering).

Walkthrough

Admin SDK views centralize timestamp formatting, update table filter configuration, remove legacy date helpers, and use a shared short-date fallback in the client plan card.

Changes

Admin SDK display updates

Layer / File(s) Summary
Shared timestamp formatting
web/sdk/admin/utils/connect-timestamp.ts
Adds the shared date format and formatTimestamp helper with missing and null timestamp fallbacks.
Timestamp rendering migration
web/sdk/admin/views/invoices/..., web/sdk/admin/views/organizations/..., web/sdk/admin/views/plans/..., web/sdk/admin/views/products/..., web/sdk/admin/views/users/..., web/sdk/admin/views/audit-logs/..., web/sdk/admin/views/webhooks/...
Admin tables and detail views delegate timestamp rendering to the shared formatter.
Filter and date configuration
web/sdk/admin/views/admins/columns.tsx, web/sdk/admin/views/preferences/columns.tsx, web/sdk/admin/views/roles/columns.tsx, web/sdk/admin/views/plans/columns.tsx, web/sdk/admin/views/products/..., web/sdk/admin/views/webhooks/..., web/sdk/admin/views/organizations/details/apis/columns.tsx
Text and date filters use filterType, and the API created-at column uses the shared date format.
Legacy helper removal and client fallback
web/apps/admin/src/utils/constants.ts, web/apps/admin/src/utils/helper.ts, web/sdk/client/views/plans/components/plan-card.tsx
Removes obsolete admin date helpers and uses DEFAULT_DATE_SHORT_FORMAT for the plan card fallback.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: rohanchkrabrty, rohilsurana, rsbh

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@Shreyag02 Shreyag02 changed the title fix(admin): unify date format with Apsara and correct table filter at… fix(admin): unify date format with Apsara and correct table filter attribute Jul 10, 2026
@Shreyag02 Shreyag02 requested a review from rohanchkrabrty July 10, 2026 06:47
@coveralls

coveralls commented Jul 10, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 29395754862

Coverage remained the same at 45.198%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 37701
Covered Lines: 17040
Line Coverage: 45.2%
Coverage Strength: 12.69 hits per line

💛 - Coveralls

@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)
web/sdk/admin/views/plans/details.tsx (1)

22-25: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider simplifying the IIFE to a concise expression.

The immediately-invoked function expression works but can be replaced with optional chaining and nullish coalescing for the same behavior.

♻️ Optional simplification
           <Text size="mini">
-            {(() => {
-              const date = timestampToDayjs(plan?.createdAt);
-              return date ? date.format("DD MMM YYYY") : "-";
-            })()}
+            {timestampToDayjs(plan?.createdAt)?.format("DD MMM YYYY") ?? "-"}
           </Text>

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 82f02392-ccc4-46d9-8b24-54445eb5043f

📥 Commits

Reviewing files that changed from the base of the PR and between ff27bf5 and eaba5d7.

📒 Files selected for processing (18)
  • web/sdk/admin/views/admins/columns.tsx
  • web/sdk/admin/views/invoices/columns.tsx
  • web/sdk/admin/views/organizations/details/apis/columns.tsx
  • web/sdk/admin/views/organizations/details/apis/details-dialog.tsx
  • web/sdk/admin/views/organizations/details/invoices/columns.tsx
  • web/sdk/admin/views/organizations/details/members/columns.tsx
  • web/sdk/admin/views/organizations/details/projects/columns.tsx
  • web/sdk/admin/views/organizations/details/tokens/columns.tsx
  • web/sdk/admin/views/organizations/list/columns.tsx
  • web/sdk/admin/views/plans/columns.tsx
  • web/sdk/admin/views/plans/details.tsx
  • web/sdk/admin/views/preferences/columns.tsx
  • web/sdk/admin/views/preferences/details.tsx
  • web/sdk/admin/views/products/columns.tsx
  • web/sdk/admin/views/products/prices/columns.tsx
  • web/sdk/admin/views/roles/columns.tsx
  • web/sdk/admin/views/users/list/columns.tsx
  • web/sdk/admin/views/webhooks/webhooks/columns.tsx

Comment thread web/sdk/admin/views/plans/columns.tsx Outdated

@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)
web/sdk/admin/views/invoices/columns.tsx (1)

27-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider using timestampCell for consistency across timestamp columns.

This file wraps formatTimestamp in <Text> manually, while other files (e.g., organizations/details/invoices/columns.tsx, products/columns.tsx) use the shared timestampCell helper directly. Standardizing on timestampCell eliminates duplicated getValue() as TimeStamp casts and wrapper boilerplate. The same pattern appears in organizations/details/members/columns.tsx and organizations/list/columns.tsx.

If <Text> provides styling that a plain string return would lose, consider updating timestampCell to wrap its output in <Text> so all consumers get consistent styling.

♻️ Proposed refactor
-      cell: ({ getValue }) => (
-        <Text>{formatTimestamp(getValue() as TimeStamp)}</Text>
-      ),
+      cell: timestampCell,

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 72dff9b0-3c07-4955-b8cb-703d3fe1b413

📥 Commits

Reviewing files that changed from the base of the PR and between eaba5d7 and bd53577.

📒 Files selected for processing (15)
  • web/sdk/admin/utils/connect-timestamp.ts
  • web/sdk/admin/views/invoices/columns.tsx
  • web/sdk/admin/views/organizations/details/apis/details-dialog.tsx
  • web/sdk/admin/views/organizations/details/invoices/columns.tsx
  • web/sdk/admin/views/organizations/details/members/columns.tsx
  • web/sdk/admin/views/organizations/details/projects/columns.tsx
  • web/sdk/admin/views/organizations/details/tokens/columns.tsx
  • web/sdk/admin/views/organizations/list/columns.tsx
  • web/sdk/admin/views/plans/columns.tsx
  • web/sdk/admin/views/plans/details.tsx
  • web/sdk/admin/views/preferences/details.tsx
  • web/sdk/admin/views/products/columns.tsx
  • web/sdk/admin/views/products/prices/columns.tsx
  • web/sdk/admin/views/users/list/columns.tsx
  • web/sdk/admin/views/webhooks/webhooks/columns.tsx
🚧 Files skipped from review as they are similar to previous changes (7)
  • web/sdk/admin/views/organizations/details/projects/columns.tsx
  • web/sdk/admin/views/organizations/details/apis/details-dialog.tsx
  • web/sdk/admin/views/preferences/details.tsx
  • web/sdk/admin/views/users/list/columns.tsx
  • web/sdk/admin/views/plans/columns.tsx
  • web/sdk/admin/views/webhooks/webhooks/columns.tsx
  • web/sdk/admin/views/organizations/details/tokens/columns.tsx

Comment on lines 56 to 60
{
header: "creation date",
accessorKey: "createdAt",
cell: ({ getValue }) => {
const timestamp = getValue() as TimeStamp | undefined;
const date = timestampToDate(timestamp);
if (!date) return "-";
return date.toLocaleString("en", {
month: "long",
day: "numeric",
year: "numeric",
});
},
cell: timestampCell,
},

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add filterType: "date" to the "creation date" column.

This column is missing filterType: "date" while every other timestamp column across the codebase (e.g., products/columns.tsx, organizations/details/invoices/columns.tsx, organizations/list/columns.tsx) sets it. Since enableColumnFilter is not explicitly disabled (unlike the "Updated date" column below), this column likely has filtering enabled with an incorrect default filter type.

🐛 Proposed fix
     {
       header: "creation date",
       accessorKey: "createdAt",
+      filterType: "date",
       cell: timestampCell,
     },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
header: "creation date",
accessorKey: "createdAt",
cell: ({ getValue }) => {
const timestamp = getValue() as TimeStamp | undefined;
const date = timestampToDate(timestamp);
if (!date) return "-";
return date.toLocaleString("en", {
month: "long",
day: "numeric",
year: "numeric",
});
},
cell: timestampCell,
},
{
header: "creation date",
accessorKey: "createdAt",
filterType: "date",
cell: timestampCell,
},

@Shreyag02 Shreyag02 changed the title fix(admin): unify date format with Apsara and correct table filter attribute refactor(admin): centralize date formatting, fix null-timestamp rendering, and correct table filter attribute Jul 10, 2026
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.

2 participants