mattrguerra/meridian-ops-boardmainPrivate on GitHub, published here in full

assignment-values.ts

Language TypeScript750 B26 lines

packages/plinth-client/src/assignment-values.ts

  1. /**
  2. * Placeholders Plinth writes for "no one is assigned".
  3. *
  4. * The live API sends `--`; the vendor's own example showed `---`. Keep the
  5. * whole family: a plain truthiness check would turn `--` into a designer named
  6. * "--" holding dozens of order lines. "Nobody holds this" and "somebody called -- holds this" lead to
  7. * opposite actions.
  8. */
  9. export const UNASSIGNED_VALUES = new Set([
  10. '',
  11. '-',
  12. '--',
  13. '---',
  14. 'n/a',
  15. 'na',
  16. 'none',
  17. 'null',
  18. 'unassigned',
  19. ])
  20. /** Sentinel-aware read of an assignment value: `--` and friends become null. */
  21. export function assignedPerson(raw: string | null): string | null {
  22. if (raw === null) return null
  23. const v = raw.trim()
  24. return UNASSIGNED_VALUES.has(v.toLowerCase()) ? null : v || null
  25. }