<?php

namespace App\Http\Controllers;

use App\Services\MetaService;
use Illuminate\Http\Request;

class PageController extends Controller
{
    protected $metaService;

    public function __construct(MetaService $metaService)
    {
        $this->metaService = $metaService;
    }

    public function home()
    {
        $meta = $this->metaService
            ->setTitle('Home')
            ->setDescription('AI Mental Wellness Platform for your daily peace')
            ->render();

        return view('pages.home', compact('meta'));
    }

    public function about()
    {
        $meta = $this->metaService
            ->setTitle('About Us')
            ->setDescription('Learn about MindEase mission')
            ->render();

        return view('pages.about', compact('meta'));
    }

    public function contact()
    {
        $meta = $this->metaService
            ->setTitle('Contact')
            ->setDescription('Get in touch with MindEase team')
            ->render();

        return view('pages.contact', compact('meta'));
    }

    public function privacy()
    {
        $meta = $this->metaService
            ->setTitle('Privacy Policy')
            ->render();

        return view('pages.privacy', compact('meta'));
    }

    public function terms()
    {
        $meta = $this->metaService
            ->setTitle('Terms of Service')
            ->render();

        return view('pages.terms', compact('meta'));
    }

    public function disclaimer()
    {
        $meta = $this->metaService
            ->setTitle('Disclaimer')
            ->render();

        return view('pages.disclaimer', compact('meta'));
    }

    public function sitemap()
    {
        $urls = [
            route('home'),
            route('about'),
            route('contact'),
            route('privacy'),
            route('terms'),
            route('disclaimer'),
            route('login'),
            route('register'),
        ];

        return response()->view('pages.sitemap', compact('urls'))->header('Content-Type', 'application/xml');
    }
}
