feat: changed get time logic to approvers

This commit is contained in:
Тимур Городецкий
2026-08-13 10:01:08 +05:00
parent 2e6e138e8d
commit 8578653c16
55 changed files with 2249 additions and 46 deletions
@@ -0,0 +1,28 @@
import { getSP } from './pnp/pnpjs';
/** Инициатор заявки — из системного поля «Автор» (Created By) элемента списка. */
export interface IInitiator {
name: string;
email: string;
}
/**
* Прочитать инициатора (создателя) элемента списка по его Id.
* Источник — системное поле Author (Created By), заполняется SharePoint
* автоматически при создании, работает для любой формы без доп. колонок.
* Возвращает undefined, если элемент/автор недоступен (не роняем шапку).
*/
export async function getCreatedBy(listTitle: string, itemId: number): Promise<IInitiator | undefined> {
try {
const item = (await getSP()
.web.lists.getByTitle(listTitle)
.items.getById(itemId)
.select('Author/Title', 'Author/EMail')
.expand('Author')()) as { Author?: { Title?: string; EMail?: string } };
const author = item.Author;
if (!author) return undefined;
return { name: author.Title || '', email: author.EMail || '' };
} catch {
return undefined;
}
}