package com.example.dateplanner.controllers.web;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.reactive.result.view.Rendering;
import reactor.core.publisher.Mono;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@Controller
@RequiredArgsConstructor
public class HomeController {
    @GetMapping("/")
    public Mono<Rendering> home() {
        Map<String, Object> model = new HashMap<>();
        model.put("title", "Home");
        model.put("index", "home");
        return Mono.just(
                Rendering.view("template")
                        .model(model)
                        .build()
        );
    }

    @GetMapping("/template")
    public Mono<Rendering> template() {
        Map<String, Object> model = new HashMap<>();
        model.put("title", "template");
        return Mono.just(
                Rendering.view("all-html")
                        .model(model)
                        .build()
        );
    }
}
