Change ticket IDs from UUID to sequential integers
Backend: - tickets.id: uuid → integer GENERATED ALWAYS AS IDENTITY - transactions.ticket_id, custom_field_values.ticket_id: uuid → integer - Routes convert string params to Number() for DB queries - ScripEngine.prepare takes ticketId: number - ActionPayload.ticketId: string → number Frontend: - Ticket.id: string → number, Transaction.ticket_id: string → number - API functions accept number params - formatTicketId() helper returns TKT-0001 format - Ticket rows display TKT-XXXX, detail page uses formatTicketId Migration: drops FKs, clears data, alters column types, re-adds FKs
This commit is contained in:
@@ -15,7 +15,7 @@ import {
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
} from "@/components/ui/dialog";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { cn, formatTicketId } from "@/lib/utils";
|
||||
|
||||
const STATUS_COLORS: Record<string, string> = {
|
||||
new: "#8a8f98",
|
||||
@@ -38,7 +38,7 @@ type FilterKey = (typeof FILTERS)[number]["key"];
|
||||
|
||||
function TicketRow({ ticket, onClick }: { ticket: Ticket; onClick: () => void }) {
|
||||
const statusColor = STATUS_COLORS[ticket.status] || STATUS_COLORS.new;
|
||||
const shortId = ticket.id.slice(0, 8);
|
||||
const shortId = formatTicketId(ticket.id);
|
||||
const timeAgo = formatDistanceToNow(new Date(ticket.updated_at), { addSuffix: true });
|
||||
|
||||
return (
|
||||
|
||||
@@ -20,7 +20,7 @@ import type {
|
||||
UpdateResult,
|
||||
} from "@/lib/types";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { cn, formatTicketId } from "@/lib/utils";
|
||||
|
||||
const STATUS_COLORS: Record<string, string> = {
|
||||
new: "#8a8f98",
|
||||
@@ -151,7 +151,8 @@ export default function TicketDetailPage({
|
||||
}: {
|
||||
params: Promise<{ id: string }>;
|
||||
}) {
|
||||
const { id } = use(params);
|
||||
const { id: idParam } = use(params);
|
||||
const id = Number(idParam);
|
||||
const router = useRouter();
|
||||
|
||||
const [ticket, setTicket] = useState<Ticket | null>(null);
|
||||
@@ -328,7 +329,7 @@ export default function TicketDetailPage({
|
||||
{ticket.subject}
|
||||
</h1>
|
||||
<p className="text-xs text-muted-foreground mt-0.5">
|
||||
<span className="font-mono">{ticket.id.slice(0, 8)}</span> · {queue?.name || ticket.queue_id}
|
||||
<span className="font-mono">{formatTicketId(ticket.id)}</span> · {queue?.name || ticket.queue_id}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ export async function getTickets(params?: { queue_id?: string; status?: string }
|
||||
return request<Ticket[]>(`/tickets${qs ? `?${qs}` : ""}`);
|
||||
}
|
||||
|
||||
export async function getTicket(id: string): Promise<{ data: Ticket | null; error: string | null }> {
|
||||
export async function getTicket(id: number): Promise<{ data: Ticket | null; error: string | null }> {
|
||||
return request<Ticket>(`/tickets/${id}`);
|
||||
}
|
||||
|
||||
@@ -44,15 +44,15 @@ export async function createTicket(data: { subject: string; queue_id: string }):
|
||||
return request<Ticket>("/tickets", { method: "POST", body: JSON.stringify(data) });
|
||||
}
|
||||
|
||||
export async function updateTicket(id: string, data: { subject?: string; status?: string }): Promise<{ data: UpdateResult | null; error: string | null }> {
|
||||
export async function updateTicket(id: number, data: { subject?: string; status?: string }): Promise<{ data: UpdateResult | null; error: string | null }> {
|
||||
return request<UpdateResult>(`/tickets/${id}`, { method: "PATCH", body: JSON.stringify(data) });
|
||||
}
|
||||
|
||||
export async function previewTicket(id: string, data: { status?: string }): Promise<{ data: PreviewResult | null; error: string | null }> {
|
||||
export async function previewTicket(id: number, data: { status?: string }): Promise<{ data: PreviewResult | null; error: string | null }> {
|
||||
return request<PreviewResult>(`/tickets/${id}/preview`, { method: "POST", body: JSON.stringify(data) });
|
||||
}
|
||||
|
||||
export async function getTicketTransactions(id: string): Promise<{ data: Transaction[] | null; error: string | null }> {
|
||||
export async function getTicketTransactions(id: number): Promise<{ data: Transaction[] | null; error: string | null }> {
|
||||
return request<Transaction[]>(`/tickets/${id}/transactions`);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export interface Ticket {
|
||||
id: string;
|
||||
id: number;
|
||||
subject: string;
|
||||
queue_id: string;
|
||||
status: string;
|
||||
@@ -21,7 +21,7 @@ export interface Queue {
|
||||
|
||||
export interface Transaction {
|
||||
id: string;
|
||||
ticket_id: string;
|
||||
ticket_id: number;
|
||||
transaction_type: string;
|
||||
field: string | null;
|
||||
old_value: string | null;
|
||||
|
||||
@@ -4,3 +4,7 @@ import { twMerge } from "tailwind-merge"
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
|
||||
export function formatTicketId(id: number): string {
|
||||
return `TKT-${String(id).padStart(4, "0")}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user