feat: Implement frontend for business owners' support ticket system
This commit is contained in:
36
frontend/src/api/tickets.ts
Normal file
36
frontend/src/api/tickets.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { apiClient } from './client';
|
||||
import { Ticket, TicketComment } from '../types'; // Assuming types.ts will define these
|
||||
|
||||
export const getTickets = async (): Promise<Ticket[]> => {
|
||||
const response = await apiClient.get('/api/tickets/');
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const getTicket = async (id: string): Promise<Ticket> => {
|
||||
const response = await apiClient.get(`/api/tickets/${id}/`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const createTicket = async (data: Partial<Ticket>): Promise<Ticket> => {
|
||||
const response = await apiClient.post('/api/tickets/', data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const updateTicket = async (id: string, data: Partial<Ticket>): Promise<Ticket> => {
|
||||
const response = await apiClient.patch(`/api/tickets/${id}/`, data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const deleteTicket = async (id: string): Promise<void> => {
|
||||
await apiClient.delete(`/api/tickets/${id}/`);
|
||||
};
|
||||
|
||||
export const getTicketComments = async (ticketId: string): Promise<TicketComment[]> => {
|
||||
const response = await apiClient.get(`/api/tickets/${ticketId}/comments/`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const createTicketComment = async (ticketId: string, data: Partial<TicketComment>): Promise<TicketComment> => {
|
||||
const response = await apiClient.post(`/api/tickets/${ticketId}/comments/`, data);
|
||||
return response.data;
|
||||
};
|
||||
Reference in New Issue
Block a user