package dev.rheinsw.server.contact.controller;

import dev.rheinsw.server.contact.model.ContactRequestDto;
import dev.rheinsw.server.contact.usecase.SubmitContactUseCase;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * REST controller to handle contact form submissions.
 *
 * @author Thatsaphorn Atchariyaphap
 * @since 21.04.25
 */
@RestController
@AllArgsConstructor
@RequestMapping("/contact")
public class ContactController {

    private static final Logger log = LoggerFactory.getLogger(ContactController.class);

    private final SubmitContactUseCase submitContactUseCase;

    @PostMapping
    public ResponseEntity<String> submitContact(@RequestBody ContactRequestDto request) {
        log.info("Received contact form from: {}", request.name());
        return submitContactUseCase.submitContact(request);
    }
}
