From daeeb3eb524b2a2afaf574ef197b70af87c3deac Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Mon, 31 Aug 2026 15:37:18 +0700 Subject: [PATCH] feat: refactor feedback service methods and enhance feedback user details in UI --- app/Services/Admin/FeedbackService.php | 24 +++++++++---------- resources/js/pages/admin/feedback/columns.tsx | 14 +++++------ resources/js/pages/admin/feedback/index.tsx | 11 +++++++-- resources/js/types/feedback.ts | 7 ++++++ 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/app/Services/Admin/FeedbackService.php b/app/Services/Admin/FeedbackService.php index 2f5e33e..1a9de84 100644 --- a/app/Services/Admin/FeedbackService.php +++ b/app/Services/Admin/FeedbackService.php @@ -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([ diff --git a/resources/js/pages/admin/feedback/columns.tsx b/resources/js/pages/admin/feedback/columns.tsx index 112887a..1e8408b 100644 --- a/resources/js/pages/admin/feedback/columns.tsx +++ b/resources/js/pages/admin/feedback/columns.tsx @@ -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[] { @@ -55,7 +48,7 @@ export function createFeedbackColumns( return [ { accessorKey: 'subject', - header: () => Subjek + header: () => Subjek, }, { accessorKey: 'type', @@ -93,6 +86,11 @@ export function createFeedbackColumns( ), }, + { + accessorKey: 'user.profile.full_name', + header: () => Dibuat Oleh, + cell: ({ row }) => row.original.user?.profile?.full_name ?? '-', + }, { accessorKey: 'handler.profile.full_name', header: () => Ditindaklanjuti Oleh, diff --git a/resources/js/pages/admin/feedback/index.tsx b/resources/js/pages/admin/feedback/index.tsx index da0f8e0..b01e61d 100644 --- a/resources/js/pages/admin/feedback/index.tsx +++ b/resources/js/pages/admin/feedback/index.tsx @@ -358,12 +358,12 @@ function ViewDetailDialog({ return ( - + Detail Kritik dan Saran {feedback && ( -
+
{FeedbackTypeLabels[feedback.type]} @@ -391,6 +391,13 @@ function ViewDetailDialog({

{feedback.subject}

+
+ +

{feedback.user?.profile?.full_name ?? '-'}

+
+