mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-24 16:50:26 +01:00
Update to v5
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||
import FormValidator from "App/Validators/FormValidator";
|
||||
import Form from "App/Models/Form";
|
||||
import FormConfirmation from "App/Mailers/FormConfirmation";
|
||||
|
||||
export default class FormsController {
|
||||
|
||||
@@ -8,6 +9,8 @@ export default class FormsController {
|
||||
const data = await request.validate(FormValidator)
|
||||
|
||||
await Form.create(data)
|
||||
|
||||
await new FormConfirmation(data.name, data.email).sendLater()
|
||||
//todo send confirmation email + email to me
|
||||
return response.status(200).send({
|
||||
status: 200
|
||||
|
||||
@@ -5,7 +5,7 @@ import ProjectValidator from "App/Validators/project/ProjectValidator";
|
||||
export default class ProjectsController {
|
||||
|
||||
public async get ({ response }: HttpContextContract) {
|
||||
const projects = await Project.query().orderBy('progress', 'desc')
|
||||
const projects = await Project.query().orderBy('id', 'asc')
|
||||
return response.status(200).send({
|
||||
projects
|
||||
})
|
||||
|
||||
22
app/Mailers/FormConfirmation.ts
Normal file
22
app/Mailers/FormConfirmation.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import mjml from 'mjml'
|
||||
import { BaseMailer, MessageContract } from '@ioc:Adonis/Addons/Mail'
|
||||
import View from "@ioc:Adonis/Core/View";
|
||||
|
||||
export default class FormConfirmation extends BaseMailer {
|
||||
|
||||
constructor (private name: string, private email: string) {
|
||||
super()
|
||||
}
|
||||
|
||||
public html = mjml(View.render('emails/confirmation_form', {
|
||||
name: this.name
|
||||
})).html
|
||||
|
||||
public prepare(message: MessageContract) {
|
||||
message
|
||||
.from('contact@arthurdanjou.fr')
|
||||
.to(this.email)
|
||||
.subject('Confirmation Form')
|
||||
.html(this.html)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user