Files
huly-platform/plugins/lead-resources/src/utils.ts
T
ea3eb4af83 New Activity - squashed (#4032)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
Co-authored-by: Andrey Sobolev <haiodo@gmail.com>
2023-12-11 18:54:36 +07:00

10 lines
458 B
TypeScript

import { type Doc, type Ref, type TxOperations } from '@hcengineering/core'
import { type Lead } from '@hcengineering/lead'
import lead from './plugin'
export async function getLeadTitle (client: TxOperations, ref: Ref<Doc>, doc?: Lead): Promise<string> {
const object = doc ?? (await client.findOne(lead.class.Lead, { _id: ref as Ref<Lead> }))
if (object === undefined) throw new Error(`Lead not found, _id: ${ref}`)
return `LEAD-${object.number}`
}