fix: tickets
Deploy banu-front / deploy (push) Failing after 16s

This commit is contained in:
sajjadtalkhabi
2026-06-05 19:42:09 +03:30
parent ea562aeefa
commit b8ccbcc030
24 changed files with 447 additions and 222 deletions
+1
View File
@@ -38,6 +38,7 @@ export const endpoints = {
// Unified student tickets — handles services (type=service), consultants
// (type=advise) and inbox (type=ticket) via the same endpoint with a filter.
getStudentTickets: '/student/tickets',
getStudentTicketStats: '/student/tickets/stats',
createStudentTicket: '/student/tickets',
showStudentTicket: '/student/tickets/:id',
sendStudentTicketMessage: '/student/tickets/:id/messages',
+3
View File
@@ -3,6 +3,9 @@ import { buildUrl, endpoints } from '@/services/api/endpoints'
export const apiGetStudentTickets = (params) => http.get(endpoints.getStudentTickets, { params })
export const apiGetStudentTicketStats = (params) =>
http.get(endpoints.getStudentTicketStats, { params })
export const apiShowStudentTicket = (id) => http.get(buildUrl(endpoints.showStudentTicket, { id }))
export const apiCreateStudentTicket = (payload) => http.post(endpoints.createStudentTicket, payload)
@@ -18,6 +18,21 @@ register('GET', endpoints.getStudentTickets, ({ query }) => {
return { success: true, message: 'OK', data: items, meta }
})
register('GET', endpoints.getStudentTicketStats, ({ query }) => {
const scoped = query.type ? myPool().filter((t) => t.type === query.type) : myPool()
const countBy = (status) => scoped.filter((t) => t.status === status).length
return {
success: true,
message: 'OK',
data: {
openTickets: countBy('open'),
answeredTickets: countBy('answered'),
closedTickets: countBy('closed'),
all: scoped.length,
},
}
})
register('GET', endpoints.showStudentTicket, ({ params }) => ({
success: true,
message: 'OK',
@@ -32,6 +47,7 @@ register('POST', endpoints.createStudentTicket, ({ data }) => {
assignedToUserId: null,
type: data.type || 'ticket',
category: data.category || null,
priority: data.priority || null,
status: 'open',
subject: data.subject || '',
createdAt: isoNow(),
@@ -60,6 +76,7 @@ register('POST', endpoints.createStudentTicket, ({ data }) => {
assignedToUserId: ticket.assignedToUserId,
type: ticket.type,
category: ticket.category,
priority: ticket.priority,
status: ticket.status,
subject: ticket.subject,
createdAt: ticket.createdAt,
+13
View File
@@ -3,6 +3,7 @@ import { useMutation, useQuery } from '@tanstack/vue-query'
import {
apiCreateStudentTicket,
apiGetStudentTickets,
apiGetStudentTicketStats,
apiSendStudentTicketMessage,
apiShowStudentTicket,
} from '@/services/api/student-tickets'
@@ -12,6 +13,7 @@ export const studentTicketsKeys = {
byType: (type) => ['student', 'tickets', 'type', type],
list: (filters, pagination) => ['student', 'tickets', 'list', filters, pagination],
detail: (id) => ['student', 'tickets', 'detail', id],
stats: (params) => ['student', 'tickets', 'stats', params],
}
export const useStudentTicketsQuery = (filtersRef, paginationRef, options = {}) =>
@@ -34,6 +36,17 @@ export const useStudentTicketQuery = (idRef, options = {}) =>
...options,
})
// Backend returns `{ open_tickets, answered_tickets, closed_tickets, all }` —
// camelized on the wire to `{ openTickets, answeredTickets, closedTickets, all }`.
// Pass `{ type: 'ticket' | 'service' | 'advise' }` to scope the counts.
export const useStudentTicketStatsQuery = (params = {}, options = {}) =>
useQuery({
queryKey: studentTicketsKeys.stats(params),
queryFn: () => apiGetStudentTicketStats(params),
select: (response) => response?.data ?? response,
...options,
})
export const useCreateStudentTicketMutation = () =>
useMutation({ mutationFn: (payload) => apiCreateStudentTicket(payload) })