Skip to content

Commit

Permalink
feat(next/web): increase ticket timeline page size
Browse files Browse the repository at this point in the history
  • Loading branch information
sdjdd committed Jul 19, 2023
1 parent 2a05f93 commit 84899ae
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
8 changes: 7 additions & 1 deletion next/web/src/App/Admin/Tickets/Ticket/timeline-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function useTicketReplies(ticketId?: string) {
return fetchTicketReplies(ticketId || '', {
cursor: pageParam,
deleted: true,
pageSize: 1000,
});
},
enabled: !!ticketId,
Expand Down Expand Up @@ -74,7 +75,12 @@ export function useTicketReplies(ticketId?: string) {
export function useTicketOpsLogs(ticketId?: string) {
const { data, fetchNextPage, refetch } = useInfiniteQuery({
queryKey: ['TicketOpsLogs', ticketId],
queryFn: ({ pageParam }) => fetchTicketOpsLogs(ticketId || '', pageParam),
queryFn: ({ pageParam }) => {
return fetchTicketOpsLogs(ticketId || '', {
cursor: pageParam,
pageSize: 1000,
});
},
enabled: !!ticketId,
getNextPageParam: (lastPage) => last(lastPage)?.createdAt,
});
Expand Down
15 changes: 13 additions & 2 deletions next/web/src/api/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,18 @@ async function fetchTicket(
interface FetchTicketRepliesOptions {
cursor?: string;
deleted?: boolean;
pageSize?: number;
}

export async function fetchTicketReplies(
id: string,
{ cursor, deleted }: FetchTicketRepliesOptions = {}
{ cursor, deleted, pageSize }: FetchTicketRepliesOptions = {}
): Promise<ReplySchema[]> {
const { data } = await http.get(`/api/2/tickets/${id}/replies`, {
params: {
cursor,
deleted: deleted ? 1 : undefined,
pageSize,
},
});
return data;
Expand Down Expand Up @@ -463,10 +465,19 @@ export type OpsLog = BaseOpsLog &
}
);

export async function fetchTicketOpsLogs(ticketId: string, cursor?: string) {
interface FetchOpsLogsOptions {
cursor?: string;
pageSize?: number;
}

export async function fetchTicketOpsLogs(
ticketId: string,
{ cursor, pageSize }: FetchOpsLogsOptions = {}
) {
const res = await http.get<OpsLog[]>(`/api/2/tickets/${ticketId}/ops-logs`, {
params: {
cursor,
pageSize,
},
});
return res.data;
Expand Down

0 comments on commit 84899ae

Please sign in to comment.