mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 11:31:57 +03:00
a85db1b78a
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
16 lines
743 B
TypeScript
16 lines
743 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}`
|
|
}
|
|
|
|
export async function getLeadId (client: TxOperations, ref: Ref<Lead>, doc?: Lead): Promise<string> {
|
|
const object = doc ?? (await client.findOne(lead.class.Lead, { _id: ref }))
|
|
if (object === undefined) throw new Error(`Lead not found, _id: ${ref}`)
|
|
return object.identifier
|
|
}
|