fix: ticket detail api fallback handle
This commit is contained in:
@@ -90,8 +90,8 @@ export function TicketOverviewCard({ ticket }: { ticket: TicketDetail }) {
|
||||
</MetaValue>
|
||||
</OverviewField>
|
||||
|
||||
<OverviewField label="Chainage">
|
||||
<MetaValue>{ticket.chainage_id || '-'}</MetaValue>
|
||||
<OverviewField label="Chainage" >
|
||||
<MetaValue>{ticket.chainage_name}</MetaValue>
|
||||
</OverviewField>
|
||||
|
||||
<OverviewField label="Uploaded By">
|
||||
|
||||
@@ -88,7 +88,6 @@ function buildTicketListItem(
|
||||
!event.id ||
|
||||
!event.ticket_name ||
|
||||
!event.status ||
|
||||
!event.default_defect_class ||
|
||||
event.detection_count === undefined ||
|
||||
!event.updated_at
|
||||
) {
|
||||
@@ -101,7 +100,7 @@ function buildTicketListItem(
|
||||
chainage_id: event.chainage_id ?? null,
|
||||
chainage_name: event.chainage_name ?? null,
|
||||
status: event.status,
|
||||
default_defect_class: event.default_defect_class,
|
||||
default_defect_class: event.default_defect_class ?? null,
|
||||
assigned_to_name: event.assigned_to_name ?? null,
|
||||
detection_count: event.detection_count,
|
||||
created_by_name: event.created_by_name ?? null,
|
||||
|
||||
@@ -63,8 +63,8 @@ export function useTicketDetailQuery(
|
||||
return useQuery({
|
||||
queryKey: ticketKeys.detail(ticketId ?? '', defectClass),
|
||||
queryFn: () =>
|
||||
ticketService.getTicketDetail(ticketId as string, defectClass as string),
|
||||
enabled: Boolean(ticketId && defectClass),
|
||||
ticketService.getTicketDetail(ticketId as string, defectClass),
|
||||
enabled: Boolean(ticketId),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -44,9 +44,11 @@ export default function TicketPage() {
|
||||
|
||||
const handleView = useCallback(
|
||||
(ticket: TicketListItem) => {
|
||||
router.push(
|
||||
`/ticket/${ticket.id}?defect_class=${encodeURIComponent(ticket.default_defect_class)}`,
|
||||
);
|
||||
const defectClassQuery = ticket.default_defect_class
|
||||
? `?defect_class=${encodeURIComponent(ticket.default_defect_class)}`
|
||||
: '';
|
||||
|
||||
router.push(`/ticket/${ticket.id}${defectClassQuery}`);
|
||||
},
|
||||
[router],
|
||||
);
|
||||
|
||||
@@ -54,7 +54,8 @@ export const API_ROUTES = {
|
||||
},
|
||||
TICKETS: {
|
||||
BASE: '/biz/api/v1/tickets',
|
||||
DETAIL: (id: string, defectClass: string) =>
|
||||
DETAIL: (id: string) => `/biz/api/v1/tickets/${id}`,
|
||||
CLASS_DETAIL: (id: string, defectClass: string) =>
|
||||
`/biz/api/v1/tickets/${id}/class-detail?defect_class=${defectClass}`,
|
||||
DEFECT_CLASSES: (id: string) => `/biz/api/v1/tickets/${id}/defect-classes`,
|
||||
ASSIGN: (id: string) => `/biz/api/v1/tickets/${id}/assign`,
|
||||
|
||||
@@ -35,11 +35,13 @@ export const ticketService = {
|
||||
|
||||
getTicketDetail: async (
|
||||
ticketId: string,
|
||||
defectClass: string,
|
||||
defectClass?: string,
|
||||
): Promise<TicketDetail> => {
|
||||
const response = await axiosClient.get<TicketDetail>(
|
||||
API_ROUTES.TICKETS.DETAIL(ticketId, defectClass),
|
||||
);
|
||||
const path = defectClass
|
||||
? API_ROUTES.TICKETS.CLASS_DETAIL(ticketId, defectClass)
|
||||
: API_ROUTES.TICKETS.DETAIL(ticketId);
|
||||
|
||||
const response = await axiosClient.get<TicketDetail>(path);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ export interface TicketDetail {
|
||||
ticket_name?: string;
|
||||
video_id: string;
|
||||
chainage_id: string | null;
|
||||
chainage_name: string | null;
|
||||
status: TicketStatus;
|
||||
defect_class: string;
|
||||
defect_display_name: string;
|
||||
|
||||
@@ -14,7 +14,7 @@ export type TicketTableStatusEvent = {
|
||||
chainage_id?: string | null;
|
||||
chainage_name?: string | null;
|
||||
status?: TicketStatus;
|
||||
default_defect_class?: string;
|
||||
default_defect_class?: string | null;
|
||||
assigned_to_name?: string | null;
|
||||
detection_count?: number;
|
||||
created_by_name?: string | null;
|
||||
|
||||
@@ -12,7 +12,7 @@ export interface TicketListItem {
|
||||
chainage_id: string | null;
|
||||
chainage_name: string | null;
|
||||
status: TicketStatus;
|
||||
default_defect_class: string;
|
||||
default_defect_class: string | null;
|
||||
assigned_to_name: string | null;
|
||||
detection_count: number;
|
||||
created_by_name: string | null;
|
||||
|
||||
Reference in New Issue
Block a user