<?php

namespace Themes\Pro\modunawa\app\Http\Controllers\Auth;

use App\Services\MessageVerifyService;

class MemberSignupVerifyController
{
    private $messageVerifyService;

    public function __construct(MessageVerifyService $messageVerifyService)
    {
        $this->messageVerifyService = $messageVerifyService;
    }

    public function index()
    {
        $route = route('member-signup-verify.store');
        return view('views.auth.member-signup-verify', compact('route'));
    }

    public function store()
    {
        if (request('cert_number') != session('smsCert.number')) {
            notify()->error(_e('Action failed'), 'Error', 'bottomRight');
            return redirect()->back();
        }

        session()->forget('smsCert.number');
        session()->put('smsCert.code', 200);
        return redirect()->route('member-signup-branch');
    }

    public function sendCert()
    {
        $response = $this->messageVerifyService->send(request('mobile_no'));

        return response()->json($response);
    }
}
