From 73226c8a8a4264fbe305ee1f6e7d7afb1369c36c Mon Sep 17 00:00:00 2001 From: Paulo Amorim Date: Fri, 18 Oct 2024 15:31:26 -0300 Subject: [PATCH] partial fetching implementation --- jsapp/js/api.endpoints.ts | 1 + jsapp/js/query/queries/activityLogs.query.ts | 21 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/jsapp/js/api.endpoints.ts b/jsapp/js/api.endpoints.ts index 5a4c6e899d..f9f6e91d40 100644 --- a/jsapp/js/api.endpoints.ts +++ b/jsapp/js/api.endpoints.ts @@ -11,5 +11,6 @@ export const endpoints = { /** Expected parameters: price_id and subscription_id **/ CHANGE_PLAN_URL: '/api/v2/stripe/change-plan', ACCESS_LOGS_URL: '/api/v2/access-logs/me', + AUDIT_LOGS_URL: '/api/v2/audit-logs', LOGOUT_ALL: '/logout-all/', }; diff --git a/jsapp/js/query/queries/activityLogs.query.ts b/jsapp/js/query/queries/activityLogs.query.ts index c71561527f..56c60448b3 100644 --- a/jsapp/js/query/queries/activityLogs.query.ts +++ b/jsapp/js/query/queries/activityLogs.query.ts @@ -2,7 +2,9 @@ import {keepPreviousData, useQuery} from '@tanstack/react-query'; import type {KoboSelectOption} from 'jsapp/js/components/common/koboSelect'; import type {PaginatedResponse} from 'jsapp/js/dataInterface'; import moment from 'moment'; +import {fetchGet} from 'js/api'; import {QueryKeys} from '../queryKeys'; +import { endpoints } from 'jsapp/js/api.endpoints'; export interface ActivityLogsItem { id: number; @@ -47,8 +49,22 @@ const mockData: ActivityLogsItem[] = Array.from({length: 150}, (_, index) => { * @param {number} offset Pagination parameter: offset of the page * @returns {Promise>} The paginated response */ -const getActivityLogs = async (limit: number, offset: number) => - new Promise>((resolve) => { +const getActivityLogs = async (limit: number, offset: number) => { + + // const params = new URLSearchParams({ + // limit: limit.toString(), + // offset: offset.toString(), + // }); + // const response = fetchGet>( + // endpoints.AUDIT_LOGS_URL + '?' + params, + // { + // errorMessageDisplay: t('There was an error getting the list.'), + // } + // ); + + // console.log(response); + + return new Promise>((resolve) => { setTimeout( () => resolve({ @@ -60,6 +76,7 @@ const getActivityLogs = async (limit: number, offset: number) => 1000 ); }); +} /** * Fetches the filter options for the activity logs.