package com.example.dateplanner.controllers.web;

import com.example.dateplanner.models.entities.GalleryPost;
import com.example.dateplanner.repositories.GalleryPostRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.reactive.result.view.Rendering;
import reactor.core.publisher.Mono;

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

@Slf4j
@Controller
@RequiredArgsConstructor
public class GalleryWebController extends BaseWebController {

    private final GalleryPostRepository galleryPostRepository;

    @GetMapping("/gallery")
    public Mono<Rendering> galleryPage() {
        Map<String, Object> model = new HashMap<>();
        model.put("title", "Галерея");
        model.put("index", "gallery");
        return addAuthToModel(model).map(m ->
                Rendering.view("template").model(m).build()
        );
    }

    @GetMapping("/gallery/{id}")
    public Mono<Rendering> galleryPostPage(@PathVariable UUID id) {
        Map<String, Object> model = new HashMap<>();
        model.put("title", "Пост галереи");
        model.put("index", "gallery-post");
        model.put("postId", id.toString());
        return addAuthToModel(model).map(m ->
                Rendering.view("template").model(m).build()
        );
    }
}
