diff --git a/apps/customer-service/src/app/tickets/[id]/error.tsx b/apps/customer-service/src/app/tickets/[id]/error.tsx
new file mode 100644
index 000000000..78c007ed4
--- /dev/null
+++ b/apps/customer-service/src/app/tickets/[id]/error.tsx
@@ -0,0 +1,54 @@
+'use client';
+
+import { TRPCClientError } from '@trpc/client';
+import { XIcon } from 'lucide-react';
+import { FormattedMessage } from 'react-intl';
+
+import { Button } from '~/components/ui/button';
+
+export default function Error({
+ error,
+ reset,
+}: {
+ error: Error;
+ reset: () => void;
+}) {
+ const getError = (error: Error) => {
+ if (error instanceof TRPCClientError) {
+ if (error.message === 'ticket_not_found') {
+ return ;
+ }
+ }
+
+ return ;
+ };
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {getError(error)}
+
+
+
+
+
+
+
+
+
+
+ );
+}
diff --git a/apps/customer-service/src/locales/en.json b/apps/customer-service/src/locales/en.json
index f6d291953..e81eb2bb6 100644
--- a/apps/customer-service/src/locales/en.json
+++ b/apps/customer-service/src/locales/en.json
@@ -1,4 +1,7 @@
{
+ "error.an_error_occured": "An error occurred",
+ "errors.ticket_not_found": "Ticket not found",
+ "errors.unhandled_error": "An unhandled error occurred. Please try again later",
"info_panel.activity": "Activity",
"info_panel.contact_information": "Contact information",
"info_panel.recent_conversations": "Recent conversations",
@@ -38,6 +41,7 @@
"ticket.statuses.resolved": "Resolved",
"tickets.all_tickets_processed": "All tickets processed!",
"tickets.no_tickets": "No tickets",
+ "try_again": "Try again",
"user.email": "Email address",
"user.phone": "Phone",
"user.platform": "Platform"
diff --git a/apps/customer-service/src/locales/fr.json b/apps/customer-service/src/locales/fr.json
index 176a8379b..b799a8968 100644
--- a/apps/customer-service/src/locales/fr.json
+++ b/apps/customer-service/src/locales/fr.json
@@ -1,4 +1,7 @@
{
+ "error.an_error_occured": "Une erreur s'est produite",
+ "errors.ticket_not_found": "Le ticket n'existe pas",
+ "errors.unhandled_error": "Une erreur inattendue s'est produite. Veuillez réessayer plus tard",
"info_panel.activity": "Activité",
"info_panel.contact_information": "Informations de contact",
"info_panel.recent_conversations": "Conversations récentes",
@@ -39,6 +42,7 @@
"ticket.statuses.resolved": "Résolu",
"tickets.all_tickets_processed": "Tous les tickets ont été traités !",
"tickets.no_tickets": "Aucun ticket",
+ "try_again": "Réessayer",
"user.email": "Adresse e-mail",
"user.phone": "Téléphone",
"user.platform": "Plateforme"
diff --git a/packages/api/src/router/ticket.ts b/packages/api/src/router/ticket.ts
index b5d894ef1..ca277f454 100644
--- a/packages/api/src/router/ticket.ts
+++ b/packages/api/src/router/ticket.ts
@@ -135,7 +135,7 @@ export const ticketRouter = createTRPCRouter({
if (!ticket)
throw new TRPCError({
code: 'BAD_REQUEST',
- message: 'Ticket not found',
+ message: 'ticket_not_found',
});
return ticket;
@@ -163,13 +163,13 @@ export const ticketRouter = createTRPCRouter({
if (!ticket)
throw new TRPCError({
code: 'BAD_REQUEST',
- message: 'Ticket not found',
+ message: 'ticket_not_found',
});
if (ticket.assignedToId)
throw new TRPCError({
code: 'BAD_REQUEST',
- message: 'Ticket is already assigned',
+ message: 'ticket_already_assigned',
});
return await ctx.db.transaction(async (tx) => {
@@ -213,19 +213,19 @@ export const ticketRouter = createTRPCRouter({
if (!ticket)
throw new TRPCError({
code: 'BAD_REQUEST',
- message: 'Ticket not found',
+ message: 'ticket_not_found',
});
if (!ticket.assignedToId)
throw new TRPCError({
code: 'BAD_REQUEST',
- message: 'Ticket is not assigned to anybody',
+ message: 'ticket_not_assigned',
});
if (ticket.assignedToId === input.contactId)
throw new TRPCError({
code: 'BAD_REQUEST',
- message: 'Ticket is already assigned to the contact',
+ message: 'ticket_already_assigned_to_contact',
});
return await ctx.db.transaction(async (tx) => {
@@ -270,13 +270,13 @@ export const ticketRouter = createTRPCRouter({
if (!ticket)
throw new TRPCError({
code: 'BAD_REQUEST',
- message: 'Ticket not found',
+ message: 'ticket_not_found',
});
- if (ticket.assignedToId === null)
+ if (!ticket.assignedToId)
throw new TRPCError({
code: 'BAD_REQUEST',
- message: 'Ticket is already assigned to nobody',
+ message: 'ticket_not_assigned',
});
return await ctx.db.transaction(async (tx) => {
@@ -320,13 +320,13 @@ export const ticketRouter = createTRPCRouter({
if (!ticket)
throw new TRPCError({
code: 'BAD_REQUEST',
- message: 'Ticket not found',
+ message: 'ticket_not_found',
});
if (ticket.status === TicketStatus.Resolved)
throw new TRPCError({
code: 'BAD_REQUEST',
- message: 'Ticket is already resolved',
+ message: 'ticket_already_resolved',
});
return await ctx.db.transaction(async (tx) => {
@@ -368,13 +368,13 @@ export const ticketRouter = createTRPCRouter({
if (!ticket)
throw new TRPCError({
code: 'BAD_REQUEST',
- message: 'Ticket not found',
+ message: 'ticket_not_found',
});
if (ticket.status === TicketStatus.Open)
throw new TRPCError({
code: 'BAD_REQUEST',
- message: 'Ticket is already reopened',
+ message: 'ticket_already_opened',
});
return await ctx.db.transaction(async (tx) => {