getCategoryById (category.ts)

pwa-pos-terminal · src/common/assets/category.ts · typescript · Apache-2.0
unclassified, database, pos, tag:entity-fetch, tag:id-lookup

Fetches category records by unique identifier, mapping/caching retrieval for backend persistence layer.

// Source: https://github.com/Asatelit/pwa-pos-terminal | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import { Category } from 'common/types';
import { Entities } from 'common/enums';
import { getTimestamp, generateId } from 'common/utils';

export const categoryRootEntity: Category = {
  id: Entities.RootCategoryId,
  name: 'Home Screen',
  parentId: null,
  color: null,
  picture: null,
  isHidden: false,
  isDeleted: false,
  sortOrder: 0,
  lastModifiedTime: 0,
};

export const getCategoryEntity = (data?: Partial<Category>): Category => ({
  id: data?.id || generateId(),
  name: data?.name || '',
  parentId: data?.parentId || Entities.RootCategoryId,
  color: data?.color || 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key