package com.avitam.bankloanapplication.web.controllers.admin.contact;


import com.avitam.bankloanapplication.model.dto.CommonWsDto;
import com.avitam.bankloanapplication.model.dto.ContactDto;
import com.avitam.bankloanapplication.service.ContactService;
import com.avitam.bankloanapplication.web.controllers.BaseController;
import jakarta.mail.MessagingException;
import org.springframework.beans.factory.annotation.Autowired;
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;

@RestController
@RequestMapping("/admin/contact")
public class ContactController extends BaseController {
    @Autowired
    private ContactService contactService;


    @PostMapping("/contactUs")
    public CommonWsDto supportMail(@RequestBody ContactDto contactDto) throws MessagingException {
        CommonWsDto wsDto = new CommonWsDto();
        contactService.sendContactUsToAdmin(contactDto);
        wsDto.setMessage("Message sent to admin successfully!");
        return wsDto;

    }

}
