feat(users): implement advanced user actions (notifications, moderation, support, audit)
This commit is contained in:
@@ -5,22 +5,7 @@ import type { User } from '@/lib/types/user';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from '@/components/ui/dialog';
|
||||
import { EscalationForm } from '../dialogs/EscalationForm';
|
||||
import {
|
||||
MessageSquare,
|
||||
Mail,
|
||||
@@ -29,7 +14,6 @@ import {
|
||||
Headphones,
|
||||
Loader2
|
||||
} from 'lucide-react';
|
||||
import { createSupportTicket } from '@/lib/actions/user-tabs';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
interface SupportTabProps {
|
||||
@@ -37,87 +21,22 @@ interface SupportTabProps {
|
||||
}
|
||||
|
||||
export function SupportTab({ user }: SupportTabProps) {
|
||||
const [isPending, startTransition] = useTransition();
|
||||
const [createDialogOpen, setCreateDialogOpen] = useState(false);
|
||||
|
||||
// Form State
|
||||
const [subject, setSubject] = useState('');
|
||||
const [priority, setPriority] = useState('Normal');
|
||||
const [type, setType] = useState('Inquiry');
|
||||
|
||||
const handleCreateTicket = () => {
|
||||
startTransition(async () => {
|
||||
const result = await createSupportTicket(user.id, { subject, priority, type });
|
||||
if (result.success) {
|
||||
toast.success(result.message);
|
||||
setCreateDialogOpen(false);
|
||||
setSubject('');
|
||||
} else {
|
||||
toast.error(result.message);
|
||||
}
|
||||
});
|
||||
};
|
||||
// Filter state could go here in future
|
||||
// const [filter, setFilter] = useState('all');
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="text-sm font-semibold">Communication Timeline</h3>
|
||||
|
||||
<Dialog open={createDialogOpen} onOpenChange={setCreateDialogOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<Button size="sm" className="h-8 gap-2">
|
||||
<Plus className="h-3.5 w-3.5" /> Create Ticket
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>New Support Ticket</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="grid gap-4 py-4">
|
||||
<div className="grid gap-2">
|
||||
<Label>Subject</Label>
|
||||
<Input
|
||||
value={subject}
|
||||
onChange={e => setSubject(e.target.value)}
|
||||
placeholder="Brief summary of the issue"
|
||||
/>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="grid gap-2">
|
||||
<Label>Type</Label>
|
||||
<Select value={type} onValueChange={setType}>
|
||||
<SelectTrigger><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="Inquiry">Inquiry</SelectItem>
|
||||
<SelectItem value="Refund">Refund Request</SelectItem>
|
||||
<SelectItem value="Technical">Technical Issue</SelectItem>
|
||||
<SelectItem value="Complaint">Complaint</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label>Priority</Label>
|
||||
<Select value={priority} onValueChange={setPriority}>
|
||||
<SelectTrigger><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="Low">Low</SelectItem>
|
||||
<SelectItem value="Normal">Normal</SelectItem>
|
||||
<SelectItem value="High">High</SelectItem>
|
||||
<SelectItem value="Urgent">Urgent</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={() => setCreateDialogOpen(false)}>Cancel</Button>
|
||||
<Button onClick={handleCreateTicket} disabled={!subject || isPending}>
|
||||
{isPending && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
||||
Create Ticket
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
<EscalationForm
|
||||
userId={user.id}
|
||||
userName={user.name}
|
||||
open={createDialogOpen}
|
||||
onOpenChange={setCreateDialogOpen}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Timeline Stream */}
|
||||
|
||||
Reference in New Issue
Block a user