Управление заявками (#7)
Co-authored-by: gorbenko.pavel <gorbenko.pavel@tansu.kz> Reviewed-on: http://git.tnsu.kz/gorbenko.pavel/tnsu-approval-route/pulls/7
This commit was merged in pull request #7.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable @rushstack/no-new-null -- поля "сырых" IPortal*-интерфейсов 1:1 зеркалят nullable JSON-контракт портала api.tnsu.kz */
|
||||
import { AadHttpClient, HttpClientResponse } from '@microsoft/sp-http';
|
||||
import { Company, Department, Employee, Project } from '../models';
|
||||
import { ApiClientError } from './httpClient';
|
||||
@@ -51,6 +52,7 @@ export interface IProjectSearchResult {
|
||||
interface IPortalEmployee {
|
||||
fio: string;
|
||||
email: string | null;
|
||||
position: string | null;
|
||||
}
|
||||
|
||||
async function getJson<T>(client: AadHttpClient, baseUrl: string, path: string): Promise<T> {
|
||||
@@ -107,7 +109,15 @@ export class PortalDictionaryClient {
|
||||
|
||||
const byEmail = new Map<string, Employee>();
|
||||
(raw ?? []).forEach(x => {
|
||||
if (x.email && !byEmail.has(x.email)) byEmail.set(x.email, { fio: x.fio, email: x.email });
|
||||
if (!x.email) return;
|
||||
const existing = byEmail.get(x.email);
|
||||
if (!existing) {
|
||||
byEmail.set(x.email, { fio: x.fio, email: x.email, position: x.position || '' });
|
||||
} else if (!existing.position && x.position) {
|
||||
// Один сотрудник — строка на каждый его отдел; должность могла найтись
|
||||
// не в первой из них.
|
||||
existing.position = x.position;
|
||||
}
|
||||
});
|
||||
return Array.from(byEmail.values());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user