feat: ticket system base implementation

This commit is contained in:
2026-06-19 01:19:01 +05:30
parent a18fff4d6f
commit 8c3d19a429
19 changed files with 1400 additions and 27 deletions

View File

@@ -0,0 +1,115 @@
import axiosClient from '../axios/axios';
import { API_ROUTES } from '@/constants/apiRoutes';
import type {
AssignTicketPayload,
AssignableTicketUsersResponse,
ReviewRepairPayload,
SseTokenResponse,
SubmitRepairPayload,
TicketDetail,
TicketListParams,
TicketListResponse,
} from '@/types';
export const ticketService = {
getTickets: async (
params?: TicketListParams,
): Promise<TicketListResponse> => {
const response = await axiosClient.get<TicketListResponse>(
API_ROUTES.TICKETS.BASE,
{
params: {
skip: params?.skip ?? 0,
limit: params?.limit ?? 10,
status: params?.status,
chainage_id: params?.chainage_id,
},
},
);
return response.data;
},
getTicketDetail: async (ticketId: string): Promise<TicketDetail> => {
const response = await axiosClient.get<TicketDetail>(
API_ROUTES.TICKETS.DETAIL(ticketId),
);
return response.data;
},
getAssignableUsers: async (): Promise<AssignableTicketUsersResponse> => {
const response = await axiosClient.get<AssignableTicketUsersResponse>(
API_ROUTES.TICKETS.ASSIGNABLE_USERS,
);
return response.data;
},
assignTicket: async (
ticketId: string,
payload: AssignTicketPayload,
): Promise<TicketDetail> => {
const response = await axiosClient.post<TicketDetail>(
API_ROUTES.TICKETS.ASSIGN(ticketId),
payload,
);
return response.data;
},
startTicket: async (ticketId: string): Promise<TicketDetail> => {
const response = await axiosClient.post<TicketDetail>(
API_ROUTES.TICKETS.START(ticketId),
);
return response.data;
},
submitRepair: async (
ticketId: string,
payload: SubmitRepairPayload,
): Promise<TicketDetail> => {
const response = await axiosClient.post<TicketDetail>(
API_ROUTES.TICKETS.SUBMIT_REPAIR(ticketId),
payload,
);
return response.data;
},
reviewRepair: async (
ticketId: string,
payload: ReviewRepairPayload,
): Promise<TicketDetail> => {
const response = await axiosClient.post<TicketDetail>(
API_ROUTES.TICKETS.REVIEW(ticketId),
payload,
);
return response.data;
},
closeTicket: async (ticketId: string): Promise<TicketDetail> => {
const response = await axiosClient.post<TicketDetail>(
API_ROUTES.TICKETS.CLOSE(ticketId),
);
return response.data;
},
createTicketEventsToken: async (
ticketId: string,
): Promise<SseTokenResponse> => {
const response = await axiosClient.post<SseTokenResponse>(
API_ROUTES.TICKETS.DETAIL_EVENTS_TOKEN(ticketId),
);
return response.data;
},
createTenantTicketEventsToken: async (): Promise<SseTokenResponse> => {
const response = await axiosClient.post<SseTokenResponse>(
API_ROUTES.TICKET_EVENTS.TENANT_TOKEN,
);
return response.data;
},
createUserEventsToken: async (): Promise<SseTokenResponse> => {
const response = await axiosClient.post<SseTokenResponse>(
API_ROUTES.TICKET_EVENTS.USER_TOKEN,
);
return response.data;
},
};