Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
feat: show last ticket id
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidRouyer committed Oct 3, 2023
1 parent f8095a9 commit a5ce5de
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { FC } from 'react';
import Link from 'next/link';
import { usePathname, useSearchParams } from 'next/navigation';
import { useSession } from 'next-auth/react';
import { FormattedMessage } from 'react-intl';

import { RouterOutputs } from '@cs/api';

Expand All @@ -15,6 +17,7 @@ export type TicketListItemProps = {
export const TicketListItem: FC<TicketListItemProps> = ({ ticket }) => {
const pathname = usePathname();
const searchParams = useSearchParams();
const session = useSession();

return (
<section
Expand Down Expand Up @@ -46,7 +49,13 @@ export const TicketListItem: FC<TicketListItemProps> = ({ ticket }) => {
</p>
</div>
<p className="mt-1 line-clamp-2 text-sm leading-6 text-muted-foreground">
{ticket.content}
{session.data?.user?.contactId ===
ticket.messages?.[0]?.senderId ? (
<>
<FormattedMessage id="you" />{' '}
</>
) : null}
{ticket.messages?.[0]?.content}
</p>
</div>
</Link>
Expand Down
3 changes: 2 additions & 1 deletion apps/customer-service/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"try_again": "Try again",
"user.email": "Email address",
"user.phone": "Phone",
"user.platform": "Platform"
"user.platform": "Platform",
"you": "You:"
}
3 changes: 2 additions & 1 deletion apps/customer-service/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@
"try_again": "Réessayer",
"user.email": "Adresse e-mail",
"user.phone": "Téléphone",
"user.platform": "Plateforme"
"user.platform": "Plateforme",
"you": "Vous :"
}
8 changes: 7 additions & 1 deletion packages/api/src/router/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ export const ticketRouter = createTRPCRouter({
unassigned: isNull(schema.tickets.assignedToId),
}[input.filter]
),
with: { author: true },
with: {
author: true,
messages: {
orderBy: desc(schema.messages.createdAt),
limit: 1,
},
},
limit: PAGE_SIZE,
});

Expand Down
1 change: 0 additions & 1 deletion packages/database/schema/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const tickets = pgTable('Ticket', {
.notNull(),
updatedAt: timestamp('updatedAt', { precision: 3, mode: 'date' }),
resolvedAt: timestamp('resolvedAt', { precision: 3, mode: 'date' }),
content: text('content'),
status: ticketStatus('status').notNull(),
assignedToId: integer('assignedToId').references(() => contacts.id, {
onDelete: 'restrict',
Expand Down
7 changes: 0 additions & 7 deletions packages/database/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ async function main() {
.insert(schema.tickets)
.values({
status: TicketStatus.Open,
content: "My order hasn't arrived yet.",
createdAt: new Date('2023-05-04T20:54:41.389Z'),
authorId: leslie.id,
assignedToId: tom.id,
Expand Down Expand Up @@ -146,7 +145,6 @@ async function main() {
.insert(schema.tickets)
.values({
status: TicketStatus.Open,
content: 'Could not purchase.',
createdAt: new Date('2023-05-06T11:23:45.389Z'),
authorId: leslie.id,
})
Expand All @@ -166,7 +164,6 @@ async function main() {
.insert(schema.tickets)
.values({
status: TicketStatus.Resolved,
content: "Impossible d'acheter",
createdAt: new Date('2023-05-06T11:23:45.389Z'),
resolvedAt: new Date('2023-06-12T06:10:45.389Z'),
authorId: leslie.id,
Expand Down Expand Up @@ -211,7 +208,6 @@ async function main() {
.insert(schema.tickets)
.values({
status: TicketStatus.Open,
content: 'I received a damaged product.',
createdAt: new Date('2023-03-03T14:02Z'),
authorId: michael.id,
})
Expand Down Expand Up @@ -269,7 +265,6 @@ async function main() {
.insert(schema.tickets)
.values({
status: TicketStatus.Open,
content: 'I need to return an item.',
createdAt: new Date('2023-03-03T13:23Z'),
authorId: dries.id,
})
Expand Down Expand Up @@ -330,8 +325,6 @@ async function main() {
.insert(schema.tickets)
.values({
status: TicketStatus.Open,
content:
'Unde dolore exercitationem nobis reprehenderit rerum corporis accusamus. Nemo suscipit temporibus quidem dolorum. Nobis optio quae atque blanditiis aspernatur doloribus sit accusamus. Sunt reiciendis ut corrupti ab debitis dolorem dolorem nam sit. Ducimus nisi qui earum aliquam. Est nam doloribus culpa illum.',
createdAt: new Date('2023-03-02T21:13Z'),
authorId: lindsay.id,
})
Expand Down

0 comments on commit a5ce5de

Please sign in to comment.