fix data
This commit is contained in:
@@ -14,14 +14,15 @@ export function useDataPage<T>(application:string, endpoint: string, params:{[ke
|
||||
|
||||
useEffect(
|
||||
()=>{
|
||||
if (data === null && needLoad){
|
||||
if (!needLoad && data !== null){
|
||||
setData(null)
|
||||
}
|
||||
else if (data === null){
|
||||
getFetch(`/${application}/${endpoint}/?${createQueryString(params)}`).then((r)=>{
|
||||
if (r.success){
|
||||
const pageData = (r as ApiResponse).body as PageResponse<T>;
|
||||
|
||||
setData(pageData.results);
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
setData([]);
|
||||
|
||||
@@ -9,7 +9,7 @@ export function DataPage() {
|
||||
const { schema, loading: loadingSchema } = useApiDocumentation(applicationName || "", endpointName || "");
|
||||
|
||||
// Получаем данные с помощью пагинации
|
||||
const dataPage = useDataPage<object>(applicationName || "", endpointName || "", {}, !loadingSchema);
|
||||
const dataPage = useDataPage(applicationName || "", endpointName || "", {}, !loadingSchema);
|
||||
|
||||
// Функция для экспорта данных в Excel (пока пустая)
|
||||
const handleExport = () => {
|
||||
@@ -55,7 +55,7 @@ export function DataPage() {
|
||||
<tr key={item.id}>
|
||||
{schema?.map((field: FieldInfo) => (
|
||||
<td key={field.name} className="data-cell">
|
||||
{item[field.name]}
|
||||
{item[field.name] || "-"}
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user