Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK-881] Fetch API data for project history log #5181

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jsapp/js/api.endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
};
21 changes: 19 additions & 2 deletions jsapp/js/query/queries/activityLogs.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -47,8 +49,22 @@ const mockData: ActivityLogsItem[] = Array.from({length: 150}, (_, index) => {
* @param {number} offset Pagination parameter: offset of the page
* @returns {Promise<PaginatedResponse<ActivityLogsItem>>} The paginated response
*/
const getActivityLogs = async (limit: number, offset: number) =>
new Promise<PaginatedResponse<ActivityLogsItem>>((resolve) => {
const getActivityLogs = async (limit: number, offset: number) => {

// const params = new URLSearchParams({
// limit: limit.toString(),
// offset: offset.toString(),
// });
// const response = fetchGet<PaginatedResponse<ActivityLogsItem>>(
// endpoints.AUDIT_LOGS_URL + '?' + params,
// {
// errorMessageDisplay: t('There was an error getting the list.'),
// }
// );

// console.log(response);

return new Promise<PaginatedResponse<ActivityLogsItem>>((resolve) => {
setTimeout(
() =>
resolve({
Expand All @@ -60,6 +76,7 @@ const getActivityLogs = async (limit: number, offset: number) =>
1000
);
});
}

/**
* Fetches the filter options for the activity logs.
Expand Down
Loading