feat: inbox-style ticket rows, Sheet detail slide-over, gradient New Ticket button
This commit is contained in:
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
import { useState, useEffect, useCallback } from "react";
|
import { useState, useEffect, useCallback } from "react";
|
||||||
import { useRouter, useSearchParams } from "next/navigation";
|
import { useRouter, useSearchParams } from "next/navigation";
|
||||||
import { PlusIcon, SearchIcon } from "lucide-react";
|
import { PlusIcon, SearchIcon, ArrowLeftIcon, SendIcon, PaperclipIcon } from "lucide-react";
|
||||||
import { formatDistanceToNow } from "date-fns";
|
import { formatDistanceToNow } from "date-fns";
|
||||||
import { getTickets, getQueues, createTicket } from "@/lib/api";
|
import { getTickets, getTicket, getTicketTransactions, getQueues, createTicket } from "@/lib/api";
|
||||||
import type { Ticket, Queue } from "@/lib/types";
|
import type { Ticket, Queue, Transaction } from "@/lib/types";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import {
|
import {
|
||||||
@@ -17,12 +17,11 @@ import {
|
|||||||
DialogFooter,
|
DialogFooter,
|
||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
import {
|
import {
|
||||||
Select,
|
Sheet,
|
||||||
SelectContent,
|
SheetContent,
|
||||||
SelectItem,
|
SheetHeader,
|
||||||
SelectTrigger,
|
SheetTitle,
|
||||||
SelectValue,
|
} from "@/components/ui/sheet";
|
||||||
} from "@/components/ui/select";
|
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
@@ -53,6 +52,20 @@ const FILTERS = [
|
|||||||
|
|
||||||
type FilterKey = (typeof FILTERS)[number]["key"];
|
type FilterKey = (typeof FILTERS)[number]["key"];
|
||||||
|
|
||||||
|
function getInitial(name: string): string {
|
||||||
|
if (!name) return "?";
|
||||||
|
return name.charAt(0).toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInitialColor(name: string): string {
|
||||||
|
const colors = ["#5e6ad2", "#7170ff", "#828fff", "#f59e0b", "#22c55e"];
|
||||||
|
let hash = 0;
|
||||||
|
for (let i = 0; i < name.length; i++) {
|
||||||
|
hash = name.charCodeAt(i) + ((hash << 5) - hash);
|
||||||
|
}
|
||||||
|
return colors[Math.abs(hash) % colors.length];
|
||||||
|
}
|
||||||
|
|
||||||
function TicketRow({ ticket, onClick }: { ticket: Ticket; onClick: () => void }) {
|
function TicketRow({ ticket, onClick }: { ticket: Ticket; onClick: () => void }) {
|
||||||
const statusColor = STATUS_COLORS[ticket.status] || STATUS_COLORS.new;
|
const statusColor = STATUS_COLORS[ticket.status] || STATUS_COLORS.new;
|
||||||
const shortId = ticket.id.slice(0, 8);
|
const shortId = ticket.id.slice(0, 8);
|
||||||
@@ -61,33 +74,33 @@ function TicketRow({ ticket, onClick }: { ticket: Ticket; onClick: () => void })
|
|||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
className="w-full flex items-center gap-3 px-4 py-2.5 text-left hover:bg-[rgba(255,255,255,0.02)] transition-colors border-b border-[rgba(255,255,255,0.04)]"
|
className="w-full flex items-center gap-3 py-3 px-4 text-left hover:bg-accent transition-all duration-150 border-l-2 border-transparent hover:border-primary border-b border-border"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
className="w-2 h-2 rounded-full flex-shrink-0"
|
className="w-2 h-2 rounded-full flex-shrink-0"
|
||||||
style={{ backgroundColor: statusColor }}
|
style={{ backgroundColor: statusColor }}
|
||||||
/>
|
/>
|
||||||
<span className="font-mono text-xs text-[#8a8f98] w-16 flex-shrink-0">
|
<span className="font-mono text-xs text-muted-foreground w-16 flex-shrink-0">
|
||||||
{shortId}
|
{shortId}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-sm text-[#f7f8f8] flex-1 truncate font-medium">
|
<span className="text-sm text-foreground flex-1 truncate font-medium">
|
||||||
{ticket.subject}
|
{ticket.subject}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-xs text-[#8a8f98] bg-[#191a1b] px-1.5 py-0.5 rounded font-medium flex-shrink-0">
|
<span className="text-xs text-muted-foreground bg-muted px-1.5 py-0.5 rounded font-medium flex-shrink-0">
|
||||||
{ticket.queue_id.slice(0, 8)}
|
{ticket.queue_id.slice(0, 8)}
|
||||||
</span>
|
</span>
|
||||||
{ticket.owner_id ? (
|
{ticket.owner_id ? (
|
||||||
<span className="w-5 h-5 rounded-full bg-[#5e6ad2] flex items-center justify-center flex-shrink-0">
|
<span className="w-5 h-5 rounded-full bg-primary flex items-center justify-center flex-shrink-0">
|
||||||
<span className="text-[#f7f8f8] text-[10px] font-semibold leading-none">
|
<span className="text-primary-foreground text-[10px] font-semibold leading-none">
|
||||||
{ticket.owner_id.charAt(0).toUpperCase()}
|
{ticket.owner_id.charAt(0).toUpperCase()}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
<span className="w-5 h-5 rounded-full border border-[rgba(255,255,255,0.08)] flex items-center justify-center flex-shrink-0">
|
<span className="w-5 h-5 rounded-full border border-border flex items-center justify-center flex-shrink-0">
|
||||||
<span className="text-[#8a8f98] text-[10px]">?</span>
|
<span className="text-muted-foreground text-[10px]">?</span>
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
<span className="text-xs text-[#8a8f98] w-24 text-right flex-shrink-0 tabular-nums">
|
<span className="text-xs text-muted-foreground w-24 text-right flex-shrink-0 tabular-nums">
|
||||||
{timeAgo}
|
{timeAgo}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
@@ -96,17 +109,250 @@ function TicketRow({ ticket, onClick }: { ticket: Ticket; onClick: () => void })
|
|||||||
|
|
||||||
function SkeletonRow() {
|
function SkeletonRow() {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-3 px-4 py-2.5 border-b border-[rgba(255,255,255,0.04)]">
|
<div className="flex items-center gap-3 py-3 px-4 border-b border-border">
|
||||||
<div className="w-2 h-2 rounded-full bg-[#191a1b] animate-pulse" />
|
<div className="w-2 h-2 rounded-full bg-muted animate-pulse" />
|
||||||
<div className="w-16 h-3 bg-[#191a1b] rounded animate-pulse" />
|
<div className="w-16 h-3 bg-muted rounded animate-pulse" />
|
||||||
<div className="flex-1 h-3 bg-[#191a1b] rounded animate-pulse" />
|
<div className="flex-1 h-3 bg-muted rounded animate-pulse" />
|
||||||
<div className="w-12 h-4 bg-[#191a1b] rounded animate-pulse" />
|
<div className="w-12 h-4 bg-muted rounded animate-pulse" />
|
||||||
<div className="w-5 h-5 rounded-full bg-[#191a1b] animate-pulse" />
|
<div className="w-5 h-5 rounded-full bg-muted animate-pulse" />
|
||||||
<div className="w-20 h-3 bg-[#191a1b] rounded animate-pulse" />
|
<div className="w-20 h-3 bg-muted rounded animate-pulse" />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function TicketDetailSheet({
|
||||||
|
ticketId,
|
||||||
|
open,
|
||||||
|
onOpenChange,
|
||||||
|
}: {
|
||||||
|
ticketId: string | null;
|
||||||
|
open: boolean;
|
||||||
|
onOpenChange: (open: boolean) => void;
|
||||||
|
}) {
|
||||||
|
const [ticket, setTicket] = useState<Ticket | null>(null);
|
||||||
|
const [transactions, setTransactions] = useState<Transaction[]>([]);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [replyText, setReplyText] = useState("");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (open && ticketId) {
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
Promise.all([
|
||||||
|
getTicket(ticketId),
|
||||||
|
getTicketTransactions(ticketId),
|
||||||
|
]).then(([ticketRes, txRes]) => {
|
||||||
|
if (ticketRes.error) {
|
||||||
|
setError(ticketRes.error);
|
||||||
|
} else {
|
||||||
|
setTicket(ticketRes.data);
|
||||||
|
}
|
||||||
|
if (txRes.data) {
|
||||||
|
setTransactions(txRes.data);
|
||||||
|
}
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [open, ticketId]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Sheet open={open} onOpenChange={onOpenChange}>
|
||||||
|
<SheetContent
|
||||||
|
side="right"
|
||||||
|
className="w-full sm:max-w-lg flex flex-col p-0"
|
||||||
|
showCloseButton={true}
|
||||||
|
>
|
||||||
|
{loading && (
|
||||||
|
<div className="flex-1 p-4 space-y-4">
|
||||||
|
{Array.from({ length: 6 }).map((_, i) => (
|
||||||
|
<div key={i} className="flex gap-3">
|
||||||
|
<div className="w-6 h-6 rounded-full bg-muted animate-pulse" />
|
||||||
|
<div className="flex-1 space-y-2">
|
||||||
|
<div className="h-3 bg-muted rounded animate-pulse w-3/4" />
|
||||||
|
<div className="h-3 bg-muted rounded animate-pulse w-1/2" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{error && (
|
||||||
|
<div className="flex flex-col items-center justify-center flex-1">
|
||||||
|
<p className="text-sm text-destructive">{error}</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{!loading && !error && ticket && (
|
||||||
|
<div className="flex flex-col h-full">
|
||||||
|
{/* Header */}
|
||||||
|
<SheetHeader className="border-b border-border shrink-0">
|
||||||
|
<SheetTitle className="text-sm font-semibold truncate">
|
||||||
|
{ticket.subject}
|
||||||
|
</SheetTitle>
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
<span className="font-mono">{ticket.id.slice(0, 8)}</span>
|
||||||
|
</p>
|
||||||
|
</SheetHeader>
|
||||||
|
|
||||||
|
{/* Conversation */}
|
||||||
|
<div className="flex-1 overflow-y-auto">
|
||||||
|
{transactions.length === 0 && (
|
||||||
|
<div className="flex flex-col items-center justify-center py-20">
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
No activity yet
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{transactions.map((tx) => {
|
||||||
|
const isSystem =
|
||||||
|
tx.transaction_type === "status_change" ||
|
||||||
|
tx.transaction_type === "assignment" ||
|
||||||
|
tx.transaction_type === "create";
|
||||||
|
const isAgent =
|
||||||
|
tx.transaction_type === "agent_reply" ||
|
||||||
|
tx.transaction_type === "internal_note";
|
||||||
|
|
||||||
|
if (isSystem) {
|
||||||
|
const txTimeAgo = formatDistanceToNow(
|
||||||
|
new Date(tx.created_at),
|
||||||
|
{ addSuffix: true }
|
||||||
|
);
|
||||||
|
let message = "";
|
||||||
|
if (tx.transaction_type === "create") {
|
||||||
|
message = "Ticket created";
|
||||||
|
} else if (tx.transaction_type === "status_change") {
|
||||||
|
const oldLabel = tx.old_value
|
||||||
|
? STATUS_LABELS[tx.old_value] || tx.old_value
|
||||||
|
: "?";
|
||||||
|
const newLabel = tx.new_value
|
||||||
|
? STATUS_LABELS[tx.new_value] || tx.new_value
|
||||||
|
: "?";
|
||||||
|
message = `${getInitial(tx.creator_id)} changed status from ${oldLabel} to ${newLabel}`;
|
||||||
|
} else if (tx.transaction_type === "assignment") {
|
||||||
|
message = tx.new_value
|
||||||
|
? `${getInitial(tx.creator_id)} assigned to ${tx.new_value}`
|
||||||
|
: `${getInitial(tx.creator_id)} unassigned`;
|
||||||
|
} else {
|
||||||
|
message = tx.transaction_type;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={tx.id}
|
||||||
|
className="flex justify-center py-2"
|
||||||
|
>
|
||||||
|
<span className="text-xs text-muted-foreground">
|
||||||
|
{message} · {txTimeAgo}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const isInternal =
|
||||||
|
tx.transaction_type === "internal_note";
|
||||||
|
const txTimeAgo = formatDistanceToNow(
|
||||||
|
new Date(tx.created_at),
|
||||||
|
{ addSuffix: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={tx.id}
|
||||||
|
className={cn(
|
||||||
|
"flex gap-3 py-3 px-4",
|
||||||
|
isAgent ? "flex-row-reverse" : ""
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0"
|
||||||
|
style={{
|
||||||
|
backgroundColor: isAgent
|
||||||
|
? getInitialColor(tx.creator_id)
|
||||||
|
: "var(--muted)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="text-[11px] font-semibold"
|
||||||
|
style={{
|
||||||
|
color: isAgent
|
||||||
|
? "#f7f8f8"
|
||||||
|
: "var(--muted-foreground)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{getInitial(tx.creator_id)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"max-w-[75%] rounded-lg px-3 py-2",
|
||||||
|
isAgent
|
||||||
|
? "bg-primary/15 text-foreground"
|
||||||
|
: isInternal
|
||||||
|
? "bg-muted border border-border text-foreground"
|
||||||
|
: "bg-muted text-foreground"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{isInternal && (
|
||||||
|
<div className="text-[10px] font-semibold text-chart-3 mb-0.5 uppercase tracking-wider">
|
||||||
|
Internal note
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<p className="text-sm whitespace-pre-wrap">
|
||||||
|
{typeof tx.data === "object" &&
|
||||||
|
tx.data !== null &&
|
||||||
|
"body" in (tx.data as Record<string, unknown>)
|
||||||
|
? String(
|
||||||
|
(tx.data as Record<string, unknown>).body
|
||||||
|
)
|
||||||
|
: tx.transaction_type}
|
||||||
|
</p>
|
||||||
|
<p className="text-[10px] text-muted-foreground mt-1">
|
||||||
|
{txTimeAgo}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Reply box */}
|
||||||
|
<div className="border-t border-border bg-sidebar p-3 shrink-0">
|
||||||
|
<div className="flex items-end gap-2">
|
||||||
|
<textarea
|
||||||
|
value={replyText}
|
||||||
|
onChange={(e) => setReplyText(e.target.value)}
|
||||||
|
placeholder="Reply to this ticket..."
|
||||||
|
rows={2}
|
||||||
|
className="flex-1 px-3 py-2 rounded-lg bg-background border border-border text-sm text-foreground placeholder:text-muted-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary resize-none transition-all duration-150"
|
||||||
|
/>
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<button
|
||||||
|
className="w-8 h-8 flex items-center justify-center rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-150"
|
||||||
|
title="Attach file (coming soon)"
|
||||||
|
>
|
||||||
|
<PaperclipIcon className="w-4 h-4" />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
disabled={!replyText.trim()}
|
||||||
|
className={cn(
|
||||||
|
"w-8 h-8 flex items-center justify-center rounded-lg transition-all duration-150",
|
||||||
|
replyText.trim()
|
||||||
|
? "bg-primary text-primary-foreground hover:bg-primary/80"
|
||||||
|
: "bg-muted text-muted-foreground cursor-not-allowed"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<SendIcon className="w-4 h-4" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</SheetContent>
|
||||||
|
</Sheet>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default function TicketListPage() {
|
export default function TicketListPage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
@@ -127,6 +373,10 @@ export default function TicketListPage() {
|
|||||||
const [submitting, setSubmitting] = useState(false);
|
const [submitting, setSubmitting] = useState(false);
|
||||||
const [createError, setCreateError] = useState<string | null>(null);
|
const [createError, setCreateError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
// Sheet
|
||||||
|
const [sheetTicketId, setSheetTicketId] = useState<string | null>(null);
|
||||||
|
const [sheetOpen, setSheetOpen] = useState(false);
|
||||||
|
|
||||||
const initialQueueId = searchParams.get("queue") || "";
|
const initialQueueId = searchParams.get("queue") || "";
|
||||||
|
|
||||||
const fetchData = useCallback(async () => {
|
const fetchData = useCallback(async () => {
|
||||||
@@ -206,26 +456,28 @@ export default function TicketListPage() {
|
|||||||
setNewSubject("");
|
setNewSubject("");
|
||||||
setNewQueueId("");
|
setNewQueueId("");
|
||||||
setNewDescription("");
|
setNewDescription("");
|
||||||
router.push(`/tickets/${data.id}`);
|
// Open in sheet
|
||||||
|
setSheetTicketId(data.id);
|
||||||
|
setSheetOpen(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-full">
|
<div className="flex flex-col h-full">
|
||||||
{/* Top bar */}
|
{/* Top bar */}
|
||||||
<div className="flex items-center gap-3 px-4 py-3 border-b border-[rgba(255,255,255,0.05)]">
|
<div className="flex items-center gap-3 px-4 py-3 border-b border-border">
|
||||||
<div className="relative flex-1">
|
<div className="relative flex-1">
|
||||||
<SearchIcon className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[#8a8f98]" />
|
<SearchIcon className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground" />
|
||||||
<input
|
<input
|
||||||
value={searchQuery}
|
value={searchQuery}
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
placeholder="Search tickets..."
|
placeholder="Search tickets..."
|
||||||
className="w-full h-8 pl-9 pr-3 rounded-lg bg-[#0f1011] border border-[rgba(255,255,255,0.08)] text-sm text-[#f7f8f8] placeholder:text-[#8a8f98] outline-none focus:border-[#5e6ad2] focus:ring-1 focus:ring-[#5e6ad2] transition-colors"
|
className="w-full h-8 pl-9 pr-3 rounded-lg bg-background border border-border text-sm text-foreground placeholder:text-muted-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary transition-all duration-150"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => setDialogOpen(true)}
|
onClick={() => setDialogOpen(true)}
|
||||||
className="h-8 px-3 rounded-lg text-sm font-medium bg-[#5e6ad2] hover:bg-[#7170ff] text-[#f7f8f8] border-0 transition-colors"
|
className="h-8 px-3 rounded-lg text-sm font-medium bg-gradient-to-r from-primary to-primary/80 hover:from-primary/90 hover:to-primary/70 text-primary-foreground border-0 transition-all duration-150"
|
||||||
>
|
>
|
||||||
<PlusIcon className="w-4 h-4 mr-1.5" />
|
<PlusIcon className="w-4 h-4 mr-1.5" />
|
||||||
New ticket
|
New ticket
|
||||||
@@ -233,16 +485,16 @@ export default function TicketListPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Filter chips */}
|
{/* Filter chips */}
|
||||||
<div className="flex items-center gap-1.5 px-4 py-2 border-b border-[rgba(255,255,255,0.04)]">
|
<div className="flex items-center gap-1.5 px-4 py-2 border-b border-border">
|
||||||
{FILTERS.map((filter) => (
|
{FILTERS.map((filter) => (
|
||||||
<button
|
<button
|
||||||
key={filter.key ?? "all"}
|
key={filter.key ?? "all"}
|
||||||
onClick={() => setActiveFilter(filter.key)}
|
onClick={() => setActiveFilter(filter.key)}
|
||||||
className={cn(
|
className={cn(
|
||||||
"px-2.5 py-1 rounded-md text-xs font-medium transition-colors",
|
"px-2.5 py-1 rounded-md text-xs font-medium transition-all duration-150",
|
||||||
activeFilter === filter.key
|
activeFilter === filter.key
|
||||||
? "bg-[#5e6ad2] text-[#f7f8f8]"
|
? "bg-primary text-primary-foreground"
|
||||||
: "text-[#8a8f98] hover:text-[#d0d6e0] hover:bg-[rgba(255,255,255,0.04)]"
|
: "text-muted-foreground hover:text-foreground hover:bg-accent"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{filter.label}
|
{filter.label}
|
||||||
@@ -253,11 +505,11 @@ export default function TicketListPage() {
|
|||||||
{/* Ticket list */}
|
{/* Ticket list */}
|
||||||
<div className="flex-1 overflow-y-auto">
|
<div className="flex-1 overflow-y-auto">
|
||||||
{error && (
|
{error && (
|
||||||
<div className="px-4 py-3 text-sm text-red-400 bg-red-400/5 border-b border-red-400/10">
|
<div className="px-4 py-3 text-sm text-destructive bg-destructive/5 border-b border-destructive/10">
|
||||||
{error}{" "}
|
{error}{" "}
|
||||||
<button
|
<button
|
||||||
onClick={fetchData}
|
onClick={fetchData}
|
||||||
className="underline hover:text-red-300"
|
className="underline hover:text-destructive/80"
|
||||||
>
|
>
|
||||||
Retry
|
Retry
|
||||||
</button>
|
</button>
|
||||||
@@ -271,18 +523,18 @@ export default function TicketListPage() {
|
|||||||
!error &&
|
!error &&
|
||||||
tickets.length === 0 && (
|
tickets.length === 0 && (
|
||||||
<div className="flex flex-col items-center justify-center py-20 px-4">
|
<div className="flex flex-col items-center justify-center py-20 px-4">
|
||||||
<div className="w-12 h-12 rounded-full bg-[#191a1b] flex items-center justify-center mb-4">
|
<div className="w-12 h-12 rounded-full bg-muted flex items-center justify-center mb-4">
|
||||||
<SearchIcon className="w-5 h-5 text-[#8a8f98]" />
|
<SearchIcon className="w-5 h-5 text-muted-foreground" />
|
||||||
</div>
|
</div>
|
||||||
<p className="text-sm text-[#d0d6e0] font-medium">
|
<p className="text-sm text-foreground font-medium">
|
||||||
No tickets match your filters
|
No tickets match your filters
|
||||||
</p>
|
</p>
|
||||||
<p className="text-xs text-[#8a8f98] mt-1">
|
<p className="text-xs text-muted-foreground mt-1">
|
||||||
Try adjusting your search or filter criteria
|
Try adjusting your search or filter criteria
|
||||||
</p>
|
</p>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => setDialogOpen(true)}
|
onClick={() => setDialogOpen(true)}
|
||||||
className="mt-4 h-8 px-3 rounded-lg text-sm font-medium bg-[#5e6ad2] hover:bg-[#7170ff] text-[#f7f8f8] border-0"
|
className="mt-4 h-8 px-3 rounded-lg text-sm font-medium bg-gradient-to-r from-primary to-primary/80 hover:from-primary/90 hover:to-primary/70 text-primary-foreground border-0 transition-all duration-150"
|
||||||
>
|
>
|
||||||
<PlusIcon className="w-4 h-4 mr-1.5" />
|
<PlusIcon className="w-4 h-4 mr-1.5" />
|
||||||
Create a ticket
|
Create a ticket
|
||||||
@@ -296,7 +548,10 @@ export default function TicketListPage() {
|
|||||||
<TicketRow
|
<TicketRow
|
||||||
key={ticket.id}
|
key={ticket.id}
|
||||||
ticket={ticket}
|
ticket={ticket}
|
||||||
onClick={() => router.push(`/tickets/${ticket.id}`)}
|
onClick={() => {
|
||||||
|
setSheetTicketId(ticket.id);
|
||||||
|
setSheetOpen(true);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -305,43 +560,38 @@ export default function TicketListPage() {
|
|||||||
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
|
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
|
||||||
<DialogContent
|
<DialogContent
|
||||||
className="sm:max-w-md"
|
className="sm:max-w-md"
|
||||||
style={{
|
|
||||||
backgroundColor: "#191a1b",
|
|
||||||
borderColor: "rgba(255,255,255,0.08)",
|
|
||||||
color: "#f7f8f8",
|
|
||||||
}}
|
|
||||||
showCloseButton={true}
|
showCloseButton={true}
|
||||||
>
|
>
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle className="text-[#f7f8f8]">New ticket</DialogTitle>
|
<DialogTitle>New ticket</DialogTitle>
|
||||||
<DialogDescription className="text-[#8a8f98]">
|
<DialogDescription>
|
||||||
Create a new ticket to track an issue or request.
|
Create a new ticket to track an issue or request.
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-xs font-medium text-[#d0d6e0] mb-1">
|
<label className="block text-xs font-medium text-foreground mb-1">
|
||||||
Subject
|
Subject
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
value={newSubject}
|
value={newSubject}
|
||||||
onChange={(e) => setNewSubject(e.target.value)}
|
onChange={(e) => setNewSubject(e.target.value)}
|
||||||
placeholder="Ticket subject"
|
placeholder="Ticket subject"
|
||||||
className="w-full h-8 px-2.5 rounded-lg bg-[#0f1011] border border-[rgba(255,255,255,0.08)] text-sm text-[#f7f8f8] placeholder:text-[#8a8f98] outline-none focus:border-[#5e6ad2] focus:ring-1 focus:ring-[#5e6ad2]"
|
className="w-full h-8 px-2.5 rounded-lg bg-background border border-border text-sm text-foreground placeholder:text-muted-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary transition-all duration-150"
|
||||||
autoFocus
|
autoFocus
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-xs font-medium text-[#d0d6e0] mb-1">
|
<label className="block text-xs font-medium text-foreground mb-1">
|
||||||
Queue
|
Queue
|
||||||
</label>
|
</label>
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<select
|
<select
|
||||||
value={newQueueId}
|
value={newQueueId}
|
||||||
onChange={(e) => setNewQueueId(e.target.value)}
|
onChange={(e) => setNewQueueId(e.target.value)}
|
||||||
className="w-full h-8 px-2.5 rounded-lg bg-[#0f1011] border border-[rgba(255,255,255,0.08)] text-sm text-[#f7f8f8] outline-none focus:border-[#5e6ad2] focus:ring-1 focus:ring-[#5e6ad2] appearance-none"
|
className="w-full h-8 px-2.5 rounded-lg bg-background border border-border text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary appearance-none transition-all duration-150"
|
||||||
>
|
>
|
||||||
<option value="" disabled>
|
<option value="" disabled>
|
||||||
Select a queue...
|
Select a queue...
|
||||||
@@ -353,7 +603,7 @@ export default function TicketListPage() {
|
|||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
<svg
|
<svg
|
||||||
className="absolute right-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-[#8a8f98] pointer-events-none"
|
className="absolute right-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground pointer-events-none"
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
@@ -369,22 +619,24 @@ export default function TicketListPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-xs font-medium text-[#d0d6e0] mb-1">
|
<label className="block text-xs font-medium text-foreground mb-1">
|
||||||
Description{" "}
|
Description{" "}
|
||||||
<span className="text-[#8a8f98] font-normal">(optional)</span>
|
<span className="text-muted-foreground font-normal">
|
||||||
|
(optional)
|
||||||
|
</span>
|
||||||
</label>
|
</label>
|
||||||
<textarea
|
<textarea
|
||||||
value={newDescription}
|
value={newDescription}
|
||||||
onChange={(e) => setNewDescription(e.target.value)}
|
onChange={(e) => setNewDescription(e.target.value)}
|
||||||
placeholder="Add a description..."
|
placeholder="Add a description..."
|
||||||
rows={3}
|
rows={3}
|
||||||
className="w-full px-2.5 py-2 rounded-lg bg-[#0f1011] border border-[rgba(255,255,255,0.08)] text-sm text-[#f7f8f8] placeholder:text-[#8a8f98] outline-none focus:border-[#5e6ad2] focus:ring-1 focus:ring-[#5e6ad2] resize-none"
|
className="w-full px-2.5 py-2 rounded-lg bg-background border border-border text-sm text-foreground placeholder:text-muted-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary resize-none transition-all duration-150"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{createError && (
|
{createError && (
|
||||||
<p className="text-xs text-red-400">{createError}</p>
|
<p className="text-xs text-destructive">{createError}</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<DialogFooter showCloseButton={false}>
|
<DialogFooter showCloseButton={false}>
|
||||||
@@ -392,8 +644,8 @@ export default function TicketListPage() {
|
|||||||
onClick={handleCreate}
|
onClick={handleCreate}
|
||||||
disabled={!newSubject.trim() || !newQueueId || submitting}
|
disabled={!newSubject.trim() || !newQueueId || submitting}
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-8 px-4 rounded-lg text-sm font-medium transition-colors",
|
"h-8 px-4 rounded-lg text-sm font-medium transition-all duration-150",
|
||||||
"bg-[#5e6ad2] hover:bg-[#7170ff] text-[#f7f8f8]",
|
"bg-primary hover:bg-primary/80 text-primary-foreground",
|
||||||
"disabled:opacity-40 disabled:cursor-not-allowed"
|
"disabled:opacity-40 disabled:cursor-not-allowed"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@@ -402,6 +654,13 @@ export default function TicketListPage() {
|
|||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
|
{/* Ticket detail sheet */}
|
||||||
|
<TicketDetailSheet
|
||||||
|
ticketId={sheetTicketId}
|
||||||
|
open={sheetOpen}
|
||||||
|
onOpenChange={setSheetOpen}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user