-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate support module to server preset
- Migrate Mutation.supportTicketCreate - Migrate Mutation.supportTicketReply - Migrate Organization.supportTickets and Organization.supportTickets - Migrate SupportTicket - Migrate SupportTicketPriority and SupportTicketStatus
- Loading branch information
Showing
11 changed files
with
609 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/services/api/src/modules/support/module.graphql.mappers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { SupportTicketPriority, SupportTicketStatus } from '../../shared/entities'; | ||
|
||
export type SupportTicketPriorityMapper = SupportTicketPriority; | ||
export type SupportTicketStatusMapper = SupportTicketStatus; |
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
packages/services/api/src/modules/support/resolvers/Mutation/supportTicketCreate.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { IdTranslator } from '../../../shared/providers/id-translator'; | ||
import { SupportManager } from '../../providers/support-manager'; | ||
import type { MutationResolvers } from './../../../../__generated__/types.next'; | ||
|
||
export const supportTicketCreate: NonNullable<MutationResolvers['supportTicketCreate']> = async ( | ||
_, | ||
{ input }, | ||
{ injector }, | ||
) => { | ||
const organizationId = await injector.get(IdTranslator).translateOrganizationId(input); | ||
const response = await injector.get(SupportManager).createTicket({ | ||
organizationId, | ||
...input, | ||
}); | ||
|
||
return response; | ||
}; |
17 changes: 17 additions & 0 deletions
17
packages/services/api/src/modules/support/resolvers/Mutation/supportTicketReply.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { IdTranslator } from '../../../shared/providers/id-translator'; | ||
import { SupportManager } from '../../providers/support-manager'; | ||
import type { MutationResolvers } from './../../../../__generated__/types.next'; | ||
|
||
export const supportTicketReply: NonNullable<MutationResolvers['supportTicketReply']> = async ( | ||
_, | ||
{ input }, | ||
{ injector }, | ||
) => { | ||
const organizationId = await injector.get(IdTranslator).translateOrganizationId(input); | ||
const response = await injector.get(SupportManager).replyToTicket({ | ||
organizationId, | ||
...input, | ||
}); | ||
|
||
return response; | ||
}; |
46 changes: 46 additions & 0 deletions
46
packages/services/api/src/modules/support/resolvers/Organization.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { SupportManager } from '../providers/support-manager'; | ||
import type { OrganizationResolvers } from './../../../__generated__/types.next'; | ||
|
||
export const Organization: Pick<OrganizationResolvers, 'supportTicket' | 'supportTickets'> = { | ||
supportTickets: async (org, args, { injector }) => { | ||
const response = await injector.get(SupportManager).getTickets(org.id); | ||
|
||
return { | ||
edges: response.nodes.map(ticket => ({ | ||
node: { | ||
id: String(ticket.id), | ||
status: ticket.status, | ||
priority: ticket.priority, | ||
description: ticket.description, | ||
subject: ticket.subject, | ||
createdAt: ticket.created_at, | ||
updatedAt: ticket.updated_at, | ||
}, | ||
cursor: String(ticket.id), | ||
})), | ||
pageInfo: { | ||
endCursor: String(response.nodes[response.nodes.length - 1]?.id ?? ''), | ||
hasNextPage: response.meta.has_more, | ||
hasPreviousPage: false, | ||
startCursor: String(response.nodes[0]?.id ?? ''), | ||
}, | ||
}; | ||
}, | ||
supportTicket: async (org, args, { injector }) => { | ||
const ticket = await injector.get(SupportManager).getTicket(org.id, args.id); | ||
|
||
if (!ticket) { | ||
return null; | ||
} | ||
|
||
return { | ||
id: String(ticket.id), | ||
status: ticket.status, | ||
priority: ticket.priority, | ||
description: ticket.description, | ||
subject: ticket.subject, | ||
createdAt: ticket.created_at, | ||
updatedAt: ticket.updated_at, | ||
}; | ||
}, | ||
}; |
26 changes: 26 additions & 0 deletions
26
packages/services/api/src/modules/support/resolvers/SupportTicket.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { SupportManager } from '../providers/support-manager'; | ||
import type { SupportTicketResolvers } from './../../../__generated__/types.next'; | ||
|
||
export const SupportTicket: SupportTicketResolvers = { | ||
comments: async (ticket, _args, { injector }) => { | ||
const response = await injector.get(SupportManager).getTicketComments(ticket.id); | ||
|
||
return { | ||
edges: response.nodes.map(comment => ({ | ||
node: { | ||
id: String(comment.id), | ||
body: comment.body, | ||
createdAt: comment.created_at, | ||
fromSupport: comment.fromSupport, | ||
}, | ||
cursor: String(comment.id), | ||
})), | ||
pageInfo: { | ||
endCursor: String(response.nodes[response.nodes.length - 1]?.id ?? ''), | ||
hasNextPage: response.meta.has_more, | ||
hasPreviousPage: false, | ||
startCursor: String(response.nodes[0]?.id ?? ''), | ||
}, | ||
}; | ||
}, | ||
}; |
8 changes: 8 additions & 0 deletions
8
packages/services/api/src/modules/support/resolvers/SupportTicketPriority.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { SupportTicketPriority as SupportTicketPriorityEnum } from '../../../shared/entities'; | ||
import type { SupportTicketPriorityResolvers } from './../../../__generated__/types.next'; | ||
|
||
export const SupportTicketPriority: SupportTicketPriorityResolvers = { | ||
NORMAL: SupportTicketPriorityEnum.NORMAL, | ||
HIGH: SupportTicketPriorityEnum.HIGH, | ||
URGENT: SupportTicketPriorityEnum.URGENT, | ||
}; |
7 changes: 7 additions & 0 deletions
7
packages/services/api/src/modules/support/resolvers/SupportTicketStatus.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { SupportTicketStatus as SupportTicketStatusEnum } from '../../../shared/entities'; | ||
import type { SupportTicketStatusResolvers } from './../../../__generated__/types.next'; | ||
|
||
export const SupportTicketStatus: SupportTicketStatusResolvers = { | ||
OPEN: SupportTicketStatusEnum.OPEN, | ||
SOLVED: SupportTicketStatusEnum.SOLVED, | ||
}; |
Oops, something went wrong.