Compare commits
3 Commits
ddbbf1cc7f
...
daeeb3eb52
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
daeeb3eb52 | ||
|
|
fdfa0bf6c7 | ||
|
|
89454c3cc4 |
@ -41,18 +41,6 @@ public function __construct()
|
||||
$this->sanitizer = new HtmlSanitizer($config);
|
||||
}
|
||||
|
||||
public function paginated(User $user, int $perPage = 25, string $search = '', ?string $type = null, ?string $status = null): LengthAwarePaginator
|
||||
{
|
||||
return Feedback::query()
|
||||
->where('user_id', $user->id)
|
||||
->with('handler.profile')
|
||||
->when($search, fn($q) => $q->where('subject', 'like', "%{$search}%"))
|
||||
->when($type, fn($q) => $q->where('type', $type))
|
||||
->when($status, fn($q) => $q->where('status', $status))
|
||||
->latest()
|
||||
->paginate($perPage);
|
||||
}
|
||||
|
||||
public function pendingCount(User $user): int
|
||||
{
|
||||
return Feedback::query()
|
||||
@ -61,6 +49,18 @@ public function pendingCount(User $user): int
|
||||
->count();
|
||||
}
|
||||
|
||||
public function paginated(User $user, int $perPage = 25, string $search = '', ?string $type = null, ?string $status = null): LengthAwarePaginator
|
||||
{
|
||||
return Feedback::query()
|
||||
->where('user_id', $user->id)
|
||||
->with(['user.profile', 'handler.profile'])
|
||||
->when($search, fn ($q) => $q->where('subject', 'like', "%{$search}%"))
|
||||
->when($type, fn ($q) => $q->where('type', $type))
|
||||
->when($status, fn ($q) => $q->where('status', $status))
|
||||
->latest()
|
||||
->paginate($perPage);
|
||||
}
|
||||
|
||||
public function create(User $user, array $data): Feedback
|
||||
{
|
||||
return Feedback::create([
|
||||
|
||||
@ -9,6 +9,7 @@ import {
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
type FormDialogProps = {
|
||||
open: boolean;
|
||||
@ -44,23 +45,29 @@ export function FormDialog({
|
||||
}: FormDialogProps) {
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className={contentClassName}>
|
||||
<DialogContent
|
||||
className={cn(
|
||||
'flex max-h-[85vh] flex-col overflow-hidden',
|
||||
contentClassName,
|
||||
)}
|
||||
>
|
||||
<Form
|
||||
action={action}
|
||||
resetOnSuccess={resetOnSuccess}
|
||||
onSuccess={onSuccess}
|
||||
className="flex min-h-0 flex-1 flex-col"
|
||||
>
|
||||
{({ errors, processing }) => (
|
||||
<>
|
||||
<DialogHeader>
|
||||
<DialogHeader className="shrink-0">
|
||||
<DialogTitle>{title}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="grid gap-4 py-4">
|
||||
<div className="grid flex-1 gap-4 overflow-y-auto py-4">
|
||||
{typeof children === 'function'
|
||||
? children({ errors, processing })
|
||||
: children}
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<DialogFooter className="shrink-0">
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
|
||||
@ -31,13 +31,6 @@ export const FeedbackStatusVariants: Record<
|
||||
resolved: 'default',
|
||||
};
|
||||
|
||||
function stripHtml(html: string): string {
|
||||
return html
|
||||
.replace(/<[^>]+>/g, ' ')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
}
|
||||
|
||||
export function createFeedbackColumns(
|
||||
params: CreateColumnsParams,
|
||||
): ColumnDef<Feedback>[] {
|
||||
@ -56,18 +49,6 @@ export function createFeedbackColumns(
|
||||
{
|
||||
accessorKey: 'subject',
|
||||
header: () => <span>Subjek</span>,
|
||||
cell: ({ row }) => {
|
||||
const feedback = row.original;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<p className="font-medium">{feedback.subject}</p>
|
||||
<p className="line-clamp-1 text-xs text-muted-foreground">
|
||||
{stripHtml(feedback.message)}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: 'type',
|
||||
@ -105,6 +86,11 @@ export function createFeedbackColumns(
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: 'user.profile.full_name',
|
||||
header: () => <span>Dibuat Oleh</span>,
|
||||
cell: ({ row }) => row.original.user?.profile?.full_name ?? '-',
|
||||
},
|
||||
{
|
||||
accessorKey: 'handler.profile.full_name',
|
||||
header: () => <span>Ditindaklanjuti Oleh</span>,
|
||||
|
||||
@ -358,12 +358,12 @@ function ViewDetailDialog({
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="flex max-h-[85vh] flex-col overflow-hidden sm:max-w-3xl">
|
||||
<DialogHeader>
|
||||
<DialogHeader className="shrink-0">
|
||||
<DialogTitle>Detail Kritik dan Saran</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
{feedback && (
|
||||
<div className="grid gap-4 overflow-y-auto">
|
||||
<div className="grid min-h-0 flex-1 gap-4 overflow-y-auto">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Badge variant="outline">
|
||||
{FeedbackTypeLabels[feedback.type]}
|
||||
@ -391,6 +391,13 @@ function ViewDetailDialog({
|
||||
<p className="font-medium">{feedback.subject}</p>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-1">
|
||||
<Label className="text-muted-foreground">
|
||||
Dibuat Oleh
|
||||
</Label>
|
||||
<p>{feedback.user?.profile?.full_name ?? '-'}</p>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-1">
|
||||
<Label className="text-muted-foreground">
|
||||
Ditindaklanjuti Oleh
|
||||
|
||||
@ -23,8 +23,15 @@ export type FeedbackHandler = {
|
||||
profile: { full_name: string } | null;
|
||||
};
|
||||
|
||||
export type FeedbackUser = {
|
||||
id: number;
|
||||
profile: { full_name: string } | null;
|
||||
};
|
||||
|
||||
export type Feedback = {
|
||||
id: number;
|
||||
user_id: number;
|
||||
user: FeedbackUser | null;
|
||||
type: FeedbackTypeValue;
|
||||
subject: string;
|
||||
message: string;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user