fix: ticket

This commit is contained in:
sajjadtalkhabi
2026-06-05 18:43:02 +03:30
parent 1c665830b0
commit ea562aeefa
53 changed files with 2475 additions and 859 deletions
+175 -9
View File
@@ -1,9 +1,10 @@
// Shape mirrors backend Postman doc for /admin/tickets:
// ticket: { id, student_id, assigned_to_user_id, target_role, status, subject,
// created_at, student, assignee, messages: [{ id, ticket_id,
// sender_id, message, created_at, sender }] }
// Field names use camelCase here (snake_case bridge happens at the HTTP layer
// when we swap the mock for the real backend).
// ticket: { id, student_id, assigned_to_user_id, type, category, status,
// subject, created_at, media: [],
// student, assignee,
// messages: [{ id, ticket_id, sender_id, message, created_at, sender }] }
// Fixture uses camelCase — the mock adapter returns it as-is, mimicking what
// the FE sees post-camelize when wired to the real backend.
const makeUser = (overrides) => ({
id: overrides.id,
@@ -46,6 +47,26 @@ const studentAli = makeUser({
createdAt: '2026-02-10T10:00:00.000Z',
})
const studentReza = makeUser({
id: 104,
name: 'رضا حسینی',
email: 'reza@example.com',
phone: '+989124444444',
roles: ['student'],
avatarUrl: '',
createdAt: '2026-02-12T10:00:00.000Z',
})
const studentZahra = makeUser({
id: 105,
name: 'زهرا کریمی',
email: 'zahra@example.com',
phone: '+989125555555',
roles: ['student'],
avatarUrl: '',
createdAt: '2026-02-15T10:00:00.000Z',
})
const adminUser = makeUser({
id: 1,
name: 'مدیر سامانه',
@@ -54,15 +75,25 @@ const adminUser = makeUser({
createdAt: '2026-01-01T00:00:00.000Z',
})
const counselorUser = makeUser({
id: 7,
name: 'مشاور سامانه',
email: 'counselor@example.com',
roles: ['counselor'],
createdAt: '2026-01-15T00:00:00.000Z',
})
export const adminTickets = [
{
id: 401,
studentId: studentJane.id,
assignedToUserId: adminUser.id,
targetRole: 'admin',
type: 'ticket',
category: 'enrollment',
status: 'answered',
subject: 'پیگیری وضعیت ثبت‌نام',
createdAt: '2026-05-09T10:30:00.000Z',
media: [],
student: studentJane,
assignee: adminUser,
messages: [
@@ -96,10 +127,12 @@ export const adminTickets = [
id: 402,
studentId: studentMaryam.id,
assignedToUserId: null,
targetRole: 'admin',
type: 'ticket',
category: 'schedule',
status: 'open',
subject: 'سوال درباره جلسه آموزشی',
createdAt: '2026-05-08T09:15:00.000Z',
media: [],
student: studentMaryam,
assignee: null,
messages: [
@@ -117,10 +150,12 @@ export const adminTickets = [
id: 403,
studentId: studentAli.id,
assignedToUserId: adminUser.id,
targetRole: 'admin',
type: 'ticket',
category: 'billing',
status: 'closed',
subject: 'درخواست بستن تیکت',
createdAt: '2026-05-07T14:10:00.000Z',
media: [],
student: studentAli,
assignee: adminUser,
messages: [
@@ -142,7 +177,138 @@ export const adminTickets = [
},
],
},
{
id: 501,
studentId: studentReza.id,
assignedToUserId: adminUser.id,
type: 'service',
category: 'loan',
status: 'open',
subject: 'درخواست وام تحصیلی',
createdAt: '2026-05-12T13:54:00.000Z',
media: [],
student: studentReza,
assignee: adminUser,
messages: [
{
id: 1,
ticketId: 501,
senderId: studentReza.id,
message: 'برای ادامه تحصیل به وام نیاز دارم.',
createdAt: '2026-05-12T13:54:00.000Z',
sender: studentReza,
},
],
},
{
id: 502,
studentId: studentJane.id,
assignedToUserId: null,
type: 'service',
category: 'insurance',
status: 'answered',
subject: 'درخواست بیمه دانشجویی',
createdAt: '2026-05-10T08:20:00.000Z',
media: [],
student: studentJane,
assignee: null,
messages: [
{
id: 1,
ticketId: 502,
senderId: studentJane.id,
message: 'لطفا اطلاعات بیمه را ارسال کنید.',
createdAt: '2026-05-10T08:20:00.000Z',
sender: studentJane,
},
],
},
{
id: 601,
studentId: studentZahra.id,
assignedToUserId: counselorUser.id,
type: 'advise',
category: 'education',
status: 'answered',
subject: 'مشاوره انتخاب رشته',
createdAt: '2026-05-12T13:54:00.000Z',
media: [],
student: studentZahra,
assignee: counselorUser,
messages: [
{
id: 1,
ticketId: 601,
senderId: studentZahra.id,
message: 'سلام، در خصوص انتخاب رشته مشاوره می‌خواستم.',
createdAt: '2026-05-12T13:54:00.000Z',
sender: studentZahra,
},
{
id: 2,
ticketId: 601,
senderId: counselorUser.id,
message: 'سلام و وقت بخیر، لطفا رشته فعلی و علاقه‌مندی‌های خود را بفرمایید.',
createdAt: '2026-05-12T14:02:00.000Z',
sender: counselorUser,
},
],
},
{
id: 602,
studentId: studentMaryam.id,
assignedToUserId: null,
type: 'advise',
category: 'career',
status: 'open',
subject: 'مشاوره مسیر شغلی',
createdAt: '2026-05-11T09:30:00.000Z',
media: [],
student: studentMaryam,
assignee: null,
messages: [
{
id: 1,
ticketId: 602,
senderId: studentMaryam.id,
message: 'برای ادامه تحصیل در سطح ۳ راهنمایی نیاز دارم.',
createdAt: '2026-05-11T09:30:00.000Z',
sender: studentMaryam,
},
],
},
{
id: 603,
studentId: studentAli.id,
assignedToUserId: counselorUser.id,
type: 'advise',
category: 'personal',
status: 'closed',
subject: 'مشاوره فردی',
createdAt: '2026-05-09T16:10:00.000Z',
media: [],
student: studentAli,
assignee: counselorUser,
messages: [
{
id: 1,
ticketId: 603,
senderId: studentAli.id,
message: 'مشاوره دریافت شد، با تشکر.',
createdAt: '2026-05-09T16:10:00.000Z',
sender: studentAli,
},
{
id: 2,
ticketId: 603,
senderId: counselorUser.id,
message: 'موفق باشید.',
createdAt: '2026-05-09T16:12:00.000Z',
sender: counselorUser,
},
],
},
]
// The signed-in admin used as `sender` when a message is posted from the FE.
export const currentAdminUser = adminUser
export const currentCounselorUser = counselorUser