Skip to content

Commit

Permalink
chore: refactor selector
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggling committed Oct 17, 2024
1 parent 6986673 commit ceaf643
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useFramework } from '@equinor/fusion-framework-react';
import { useQuery } from 'react-query';
import { getPimsTasks } from '../work-assigned/assignment-queries';
import { getMyMeetingsActions, getMyReviewActions } from '../queries/fusion-meetings-queries';
import { getMyMeetingsActions, getMyReviewActions, myMeetingsActionSelector } from '../queries/fusion-meetings-queries';
import { getQueryAndNCRequest } from '../queries/query-ncr-request-queries';
import { Task } from '../types/task';
import { getFusionTasks, getProCoSysAssignments } from '../queries/fusion-task-queries';
Expand Down Expand Up @@ -95,6 +95,7 @@ export function useMeetingsActionsQuery() {
return useQuery({
queryKey: ['Assignment', 'Meetings', 'Meetings-Actions'],
queryFn: async ({ signal }) => getMyMeetingsActions(await client, signal),
select: myMeetingsActionSelector,
cacheTime: 5000 * 60,
refetchInterval: 5000 * 60,
staleTime: 2000 * 60,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IHttpClient } from '@equinor/fusion-framework-module-http';
import { Task } from '../types/task';

import { verifyDate } from '../utils/time';
import { ActionState, MeetingAction } from '../types/meetings-task';
import { ActionState, MeetingAction, MeetingType } from '../types/meetings-task';
import { isTaskOverdue } from './query-ncr-request-queries';

function stripHtml(html?: string) {
Expand All @@ -11,11 +11,14 @@ function stripHtml(html?: string) {
return tmp.textContent || tmp.innerText || '';
}

export async function getMyMeetingsActions(client: IHttpClient, signal?: AbortSignal): Promise<Task[]> {
export async function getMyMeetingsActions(client: IHttpClient, signal?: AbortSignal): Promise<MeetingAction[]> {
const response = await client.fetch('/persons/me/actions?api-version=4.0', { signal });

const tasks: MeetingAction[] = await response.json();
return tasks;
}

export function myMeetingsActionSelector(tasks: MeetingAction[]): Task[] {
return tasks
.filter((a) => a.state !== ActionState.Completed && a.state !== ActionState.NotCompleted)
.map((task) => ({
Expand Down

0 comments on commit ceaf643

Please sign in to comment.