<?php

namespace App\Http\Controllers\Api\Inbox;

use App\Domains\Conversations\Models\QuickReply;
use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;

class QuickReplyIndexController extends Controller
{
    public function __invoke(): JsonResponse
    {
        $replies = QuickReply::query()
            ->where('tenant_id', request()->user()->tenant_id)
            ->orderBy('title')
            ->get()
            ->map(fn (QuickReply $reply) => [
                'id' => $reply->id,
                'title' => $reply->title,
                'shortcut' => $reply->shortcut,
                'category' => $reply->category,
                'content' => $reply->content,
            ]);

        return response()->json([
            'data' => $replies,
        ]);
    }
}
