Skip to content

Commit ce5a4c3

Browse files
ZabilsyaZabilsya
andauthored
[DOP-20067] run list and run detail (#41)
* [DOP-20067] run list and run detail * [DOP-20067] move RunStatus enum from types to constants --------- Co-authored-by: Zabilsya <[email protected]>
1 parent d5139a2 commit ce5a4c3

File tree

44 files changed

+439
-24
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+439
-24
lines changed

src/app/config/router/instance.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { AuthProvider } from '@entities/auth';
88
import { CreateQueuePage, QueueDetailPage, QueueListPage, UpdateQueuePage } from '@pages/queue';
99
import { ConnectionDetailPage, ConnectionListPage } from '@pages/connection';
1010
import { TransferDetailPage, TransferListPage } from '@pages/transfer';
11+
import { RunDetailPage } from '@pages/run';
1112

1213
import { ErrorBoundary, NotFoundError } from '../errorBoundary';
1314

@@ -95,6 +96,10 @@ export const router = createBrowserRouter([
9596
path: '/transfers/:id',
9697
element: <TransferDetailPage />,
9798
},
99+
{
100+
path: '/transfers/runs/:id',
101+
element: <RunDetailPage />,
102+
},
98103
],
99104
},
100105
{

src/entities/group/api/groupService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
GetGroupsRequest,
1010
GetGroupUsersRequest,
1111
Group,
12+
GroupData,
1213
GroupUser,
1314
UpdateGroupRequest,
1415
UpdateGroupUserRequest,
@@ -23,11 +24,11 @@ export const groupService = {
2324
return axiosInstance.get(`groups/${id}`);
2425
},
2526

26-
createGroup: (data: CreateGroupRequest): Promise<Group> => {
27+
createGroup: (data: CreateGroupRequest): Promise<GroupData> => {
2728
return axiosInstance.post(`groups`, data);
2829
},
2930

30-
updateGroup: ({ id, ...data }: UpdateGroupRequest): Promise<Group> => {
31+
updateGroup: ({ id, ...data }: UpdateGroupRequest): Promise<GroupData> => {
3132
return axiosInstance.patch(`groups/${id}`, data);
3233
},
3334

src/entities/run/api/constants.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export enum RunStatus {
2+
CREATED = 'CREATED',
3+
STARTED = 'STARTED',
4+
FAILED = 'FAILED',
5+
SEND_STOP_SIGNAL = 'SEND STOP SIGNAL',
6+
STOPPED = 'STOPPED',
7+
FINISHED = 'FINISHED',
8+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './useGetRun';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { useSuspenseQuery, UseSuspenseQueryResult } from '@tanstack/react-query';
2+
3+
import { GetRunRequest, Run } from '../../types';
4+
import { RunQueryKey } from '../../keys';
5+
import { runService } from '../../runService';
6+
7+
/** Hook for getting run info from backend */
8+
export const useGetRun = ({ id }: GetRunRequest): UseSuspenseQueryResult<Run> => {
9+
return useSuspenseQuery({
10+
queryKey: [RunQueryKey.GET_RUN, id],
11+
queryFn: () => runService.getRun({ id }),
12+
});
13+
};

src/entities/run/api/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export * from './runService';
2+
export * from './types';
3+
export * from './keys';
4+
export * from './hooks';
5+
export * from './constants';

src/entities/run/api/keys/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const RunQueryKey = {
2+
GET_RUNS: 'GET_RUNS',
3+
GET_RUN: 'GET_RUN',
4+
} as const;

src/entities/run/api/runService.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { axiosInstance } from '@shared/config';
2+
import { PaginationResponse } from '@shared/types';
3+
4+
import { GetRunRequest, Run, GetRunsRequest } from './types';
5+
6+
export const runService = {
7+
getRuns: (params: GetRunsRequest): Promise<PaginationResponse<Run>> => {
8+
return axiosInstance.get('runs', { params });
9+
},
10+
11+
getRun: ({ id }: GetRunRequest): Promise<Run> => {
12+
return axiosInstance.get(`runs/${id}`);
13+
},
14+
};

src/entities/run/api/types.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { PaginationRequest } from '@shared/types';
2+
3+
import { RunStatus } from './constants';
4+
5+
export interface Run {
6+
id: number;
7+
transfer_id: number;
8+
started_at: string | null;
9+
ended_at: string | null;
10+
status: keyof typeof RunStatus;
11+
log_url: string | null;
12+
}
13+
14+
export interface GetRunsRequest extends PaginationRequest {
15+
transfer_id: number;
16+
}
17+
18+
export interface GetRunRequest {
19+
id: number;
20+
}

src/entities/run/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './api';
2+
export * from './ui';

0 commit comments

Comments
 (0)