<?php

namespace App\Livewire\Store;

use Livewire\Attributes\Layout;
use Livewire\Component;

#[Layout('layouts.store')]
class InfoPage extends Component
{
    public string $page = 'about';

    public function mount(string $page = 'about'): void
    {
        $this->page = $page;
    }

    public function render()
    {
        $storeName = \App\Models\Setting::get('store_name', config('app.name'));
        $waAdmin   = \App\Models\Setting::get('wa_admin');
        $waNumber  = $waAdmin
            ? preg_replace('/^0/', '62', preg_replace('/[^0-9]/', '', $waAdmin))
            : null;

        $titles = [
            'about'   => 'Tentang ' . $storeName,
            'contact' => 'Hubungi Kami',
            'faq'     => 'FAQ',
            'privacy' => 'Kebijakan Privasi',
            'terms'   => 'Syarat & Ketentuan',
        ];

        $title = $titles[$this->page] ?? 'Info';

        return view('livewire.store.info-page', compact('title', 'storeName', 'waNumber'))
            ->title($title);
    }
}
