feat: extract timestamp formatting and text truncation into separate utility functions

This commit is contained in:
Abhimanyu Saharan
2026-02-09 00:02:43 +05:30
parent 5ea9719c13
commit 1340e00b61
9 changed files with 64 additions and 150 deletions

View File

@@ -34,27 +34,10 @@ import {
useDeleteGatewayApiV1GatewaysGatewayIdDelete,
useListGatewaysApiV1GatewaysGet,
} from "@/api/generated/gateways/gateways";
import { formatTimestamp, truncateText as truncate } from "@/lib/formatters";
import { useOrganizationMembership } from "@/lib/use-organization-membership";
import type { GatewayRead } from "@/api/generated/model";
const truncate = (value?: string | null, max = 24) => {
if (!value) return "—";
if (value.length <= max) return value;
return `${value.slice(0, max)}`;
};
const formatTimestamp = (value?: string | null) => {
if (!value) return "—";
const date = new Date(`${value}${value.endsWith("Z") ? "" : "Z"}`);
if (Number.isNaN(date.getTime())) return "—";
return date.toLocaleString(undefined, {
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
});
};
export default function GatewaysPage() {
const { isSignedIn } = useAuth();
const queryClient = useQueryClient();