dashboard fix with open tickets
This commit is contained in:
1 parent
676283cce9
commit
2f5b17b13e
2 files changed
+1238
-225
No files matched your search
Generated
+1193
-208
File diff suppressed because it is too large.
Load diff
@@ -138,6 +138,9 @@ export default function Tickets() {
|
|||||||
|
|
||||||
// Department system enablement state
|
// Department system enablement state
|
||||||
const [departmentsEnabled, setDepartmentsEnabled] = useState<boolean>(true);
|
const [departmentsEnabled, setDepartmentsEnabled] = useState<boolean>(true);
|
||||||
|
const [configuredDepartments, setConfiguredDepartments] = useState<
|
||||||
|
{ id: string; name: string; emoji?: string }[]
|
||||||
|
>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
try {
|
try {
|
||||||
@@ -148,6 +151,18 @@ export default function Tickets() {
|
|||||||
if (typeof deptVal === "boolean") {
|
if (typeof deptVal === "boolean") {
|
||||||
setDepartmentsEnabled(deptVal);
|
setDepartmentsEnabled(deptVal);
|
||||||
}
|
}
|
||||||
|
const deptsObj = getByPath(res.data, "Ticket.DepartmentSystem.Departments");
|
||||||
|
if (deptsObj && typeof deptsObj === "object") {
|
||||||
|
const deptsList = Object.entries(deptsObj).map(([key, val]: [string, any]) => ({
|
||||||
|
id: key,
|
||||||
|
name: val && typeof val === "object" && val.Name ? (val.Name as string) : key,
|
||||||
|
emoji: val && typeof val === "object" && val.Emoji ? (val.Emoji as string) : "🎫",
|
||||||
|
}));
|
||||||
|
if (deptsList.length > 0) {
|
||||||
|
setConfiguredDepartments(deptsList);
|
||||||
|
setCreateDept(deptsList[0].id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
@@ -236,7 +251,7 @@ export default function Tickets() {
|
|||||||
setCreating(true);
|
setCreating(true);
|
||||||
try {
|
try {
|
||||||
const res = await api.createTicket({
|
const res = await api.createTicket({
|
||||||
department: createDept,
|
department: departmentsEnabled ? createDept : "general",
|
||||||
subject: createSubject.trim(),
|
subject: createSubject.trim(),
|
||||||
userId: createUserId.trim() || undefined,
|
userId: createUserId.trim() || undefined,
|
||||||
});
|
});
|
||||||
@@ -1435,7 +1450,7 @@ export default function Tickets() {
|
|||||||
<Badge variant="outline" className="font-mono text-xs shrink-0">
|
<Badge variant="outline" className="font-mono text-xs shrink-0">
|
||||||
#{activeTicket?.ticket_id}
|
#{activeTicket?.ticket_id}
|
||||||
</Badge>
|
</Badge>
|
||||||
{activeTicket?.department && (
|
{departmentsEnabled && activeTicket?.department && (
|
||||||
<Badge variant="secondary" className="text-xs capitalize shrink-0">
|
<Badge variant="secondary" className="text-xs capitalize shrink-0">
|
||||||
{activeTicket.department}
|
{activeTicket.department}
|
||||||
</Badge>
|
</Badge>
|
||||||
@@ -1609,25 +1624,38 @@ export default function Tickets() {
|
|||||||
Open Direct Ticket
|
Open Direct Ticket
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogDescription className="text-xs">
|
<DialogDescription className="text-xs">
|
||||||
Select a support department to create a new ticket channel in Discord immediately.
|
{departmentsEnabled
|
||||||
|
? "Select a support department to create a new ticket channel in Discord immediately."
|
||||||
|
: "Create a new ticket channel in Discord immediately."}
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
<div className="space-y-4 py-2">
|
<div className="space-y-4 py-2">
|
||||||
<div className="space-y-1.5">
|
{departmentsEnabled && (
|
||||||
<Label className="text-xs font-semibold">Department</Label>
|
<div className="space-y-1.5">
|
||||||
<Select value={createDept} onValueChange={setCreateDept}>
|
<Label className="text-xs font-semibold">Department</Label>
|
||||||
<SelectTrigger className="text-xs border-border bg-secondary/30">
|
<Select value={createDept} onValueChange={setCreateDept}>
|
||||||
<SelectValue />
|
<SelectTrigger className="text-xs border-border bg-secondary/30">
|
||||||
</SelectTrigger>
|
<SelectValue />
|
||||||
<SelectContent>
|
</SelectTrigger>
|
||||||
<SelectItem value="general">🎫 General Support</SelectItem>
|
<SelectContent>
|
||||||
<SelectItem value="purchase">💳 Purchase & Billing Support</SelectItem>
|
{(configuredDepartments.length > 0
|
||||||
<SelectItem value="reports">🚨 Player Report</SelectItem>
|
? configuredDepartments
|
||||||
<SelectItem value="appeals">⚖️ Ban Appeals</SelectItem>
|
: [
|
||||||
</SelectContent>
|
{ id: "general", name: "General Support", emoji: "🎫" },
|
||||||
</Select>
|
{ id: "purchase", name: "Purchase & Billing Support", emoji: "💳" },
|
||||||
</div>
|
{ id: "reports", name: "Player Report", emoji: "🚨" },
|
||||||
|
{ id: "appeals", name: "Ban Appeals", emoji: "⚖️" },
|
||||||
|
]
|
||||||
|
).map((dept) => (
|
||||||
|
<SelectItem key={dept.id} value={dept.id}>
|
||||||
|
{dept.emoji ? `${dept.emoji} ` : ""}{dept.name}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="space-y-1.5">
|
<div className="space-y-1.5">
|
||||||
<Label className="text-xs font-semibold">Ticket Subject / Reason</Label>
|
<Label className="text-xs font-semibold">Ticket Subject / Reason</Label>
|
||||||
|
|||||||
Reference in new issue
Block a user