Skip to content

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

Open
Shreyag02 wants to merge 3 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 3 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, formatTimestamp, and timestampCell 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.
  • 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 10, 2026 8:56am

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 22e46624-3bdc-439a-90d3-db944edf9530

📥 Commits

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

📒 Files selected for processing (12)
  • web/apps/admin/src/utils/constants.ts
  • web/apps/admin/src/utils/helper.ts
  • web/sdk/admin/views/audit-logs/columns.tsx
  • web/sdk/admin/views/audit-logs/sidepanel-details.tsx
  • web/sdk/admin/views/organizations/details/apis/columns.tsx
  • web/sdk/admin/views/organizations/details/pat/columns.tsx
  • web/sdk/admin/views/organizations/details/side-panel/billing-details-section.tsx
  • web/sdk/admin/views/organizations/details/side-panel/org-details-section.tsx
  • web/sdk/admin/views/organizations/details/side-panel/plan-details-section.tsx
  • web/sdk/admin/views/users/details/layout/side-panel-details.tsx
  • web/sdk/admin/views/users/details/layout/side-panel-membership.tsx
  • web/sdk/client/views/plans/components/plan-card.tsx
📝 Walkthrough

Walkthrough

Admin SDK tables now use shared timestamp formatting utilities, standardized string and date filter configuration, and an updated organization API date display format.

Changes

Admin SDK display updates

Layer / File(s) Summary
Shared timestamp formatting
web/sdk/admin/utils/connect-timestamp.ts
Adds shared timestamp formatting and table-cell helpers with fallback handling for missing or null timestamps.
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/webhooks/...
Admin date cells and detail views delegate timestamp formatting to the shared utilities.
Filter and date display 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/prices/columns.tsx, web/sdk/admin/views/products/columns.tsx, web/sdk/admin/views/webhooks/webhooks/columns.tsx, web/sdk/admin/views/organizations/details/apis/columns.tsx
Text and date filters use filterType, and the organization API created-at column uses DD MMM YYYY.

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

Suggested reviewers: rsbh, rohilsurana, paanSinghCoder

🚥 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 29081334524

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage remained the same at 44.876%

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: 37644
Covered Lines: 16893
Line Coverage: 44.88%
Coverage Strength: 12.54 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