<?php

namespace App\Http\Controllers\Admin\Manage\Stock;

use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\Manage\RetailStockTransferRequest;
use App\Services\Manage\RetailStockService;
use Illuminate\Http\JsonResponse;

class RetailStockController extends Controller
{
    public function __construct(
        private readonly RetailStockService $retailStockService,
    ) {}

    public function transfer(RetailStockTransferRequest $request): JsonResponse
    {
        $validated = $request->validated();

        $this->retailStockService->transfer(
            $validated['product_variant_id'],
            $validated['quantity'],
            $request->user(),
            $validated['notes'] ?? null,
        );

        return response()->json([
            'success' => true,
            'message' => 'Pengajuan transfer stok ecer berhasil dikirim dan menunggu verifikasi owner.',
        ]);
    }
}
