dashpresshq/dashpress

View on GitHub
src/frontend/views/data/Details/utils.ts

Summary

Maintainability
A
0 mins
Test Coverage
F
23%
import type { DataStateKeys } from "@/frontend/lib/data/types";
import type { IEntityRelation } from "@/shared/types/db";

export const getEntitiesRelationsCount = (
  type: IEntityRelation["type"],
  countData: DataStateKeys<{
    count: number;
  }>
): string => {
  if (type === "toOne") {
    return "";
  }
  const countResult = countData?.isLoading
    ? "Loading..."
    : countData?.data?.count;
  return `(${countResult})`;
};