полное имя вместо email

This commit is contained in:
gorbenko.pavel
2026-07-29 17:33:05 +05:00
parent df3558b63a
commit dffbb81a20
10 changed files with 170 additions and 34 deletions
@@ -0,0 +1,34 @@
import * as React from 'react';
import { Employee } from '../models';
import { ApiClientError } from '../services/httpClient';
import { PortalDictionaryClient } from '../services/portalDictionary';
export interface PortalEmployees {
items: Employee[];
isLoading: boolean;
error?: string;
}
/**
* Справочник сотрудников api.tnsu.kz — грузим один раз на экран, чтобы искать
* исполнителя/инициатора по ФИО или email на клиенте, без запроса на каждый символ.
*/
export function usePortalEmployees(dictionary?: PortalDictionaryClient): PortalEmployees {
const [items, setItems] = React.useState<Employee[]>([]);
const [isLoading, setIsLoading] = React.useState(true);
const [error, setError] = React.useState<string | undefined>();
React.useEffect(() => {
// Клиент появляется асинхронно: SPFx сначала выдаёт AAD-токен для api.tnsu.kz.
if (!dictionary) return;
setIsLoading(true);
setError(undefined);
dictionary.employees()
.then(setItems)
.catch((e: ApiClientError) => setError(e.message))
.finally(() => setIsLoading(false));
}, [dictionary]);
return { items, isLoading, error };
}