generated from polijrorg/template-node-ts-prisma
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from polijrorg/feat/appointment
Feat/appointment
- Loading branch information
Showing
5 changed files
with
26 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
declare namespace Express { | ||
export interface Request { | ||
token: { | ||
id: string, | ||
}, | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import { Users } from '@prisma/client'; | |
import AppError from '@shared/errors/AppError'; | ||
|
||
import IUsersRepository from '../repositories/IUsersRepository'; | ||
import moment from 'moment'; | ||
|
||
interface IRequest { | ||
id: string; | ||
|
@@ -24,17 +25,18 @@ export default class CreateAppointmentService { | |
const user = await this.usersRepository.findById(id); | ||
if (!user) throw new AppError('This user does not exist'); | ||
|
||
const date = new Date(); | ||
const formattedDate = moment().locale('pt-br').format('DD/MM/YYYY'); | ||
const formattedTime = moment().locale('pt-br').format('HH:mm'); | ||
const formattedBirthdate = moment(user.birthdate, 'DD/MM/YYYY').locale('pt-br').format('DD/MM/YYYY'); | ||
|
||
sgMail.setApiKey(process.env.SENDGRID_API_KEY as string); | ||
const formatDate = (date: number) => date.toString().padStart(2, '0'); | ||
|
||
const msg = { | ||
to: "lucas.aguiar@polijunior.com.br", | ||
to: "tatitassyla@gmail.com", | ||
from: '[email protected]', | ||
subject: 'Apogeo | Solicitação de consulta médica', | ||
text: `João, o usuário ${user.name} solicitou uma consulta médica. <br><br>Pedido realizado em <strong>${formatDate(date.getDate())}/${formatDate(date.getMonth()+1)}/${date.getFullYear()}</strong> às <strong>${formatDate(date.getHours())}:${formatDate(date.getMinutes())}</strong>.<br><br><strong>Informações do usuário</strong><br>Email: ${user.email}<br>Telefone: ${user.phone}<br>Idioma: ${user.language}<br>${user.gender != null ? "Gênero: "+ user.gender + "<br>": ""}${user.birthdate ? "Data de Nascimento: " + user.birthdate + "<br>" : ""}`, | ||
html: `João, o usuário ${user.name} solicitou uma consulta médica. <br><br>Pedido realizado em <strong>${formatDate(date.getDate())}/${formatDate(date.getMonth()+1)}/${date.getFullYear()}</strong> às <strong>${formatDate(date.getHours())}:${formatDate(date.getMinutes())}</strong>.<br><br><strong>Informações do usuário</strong><br>Email: ${user.email}<br>Telefone: ${user.phone}<br>Idioma: ${user.language}<br>${user.gender != null ? "Gênero: "+ user.gender + "<br>": ""}${user.birthdate ? "Data de Nascimento: " + user.birthdate + "<br>" : ""}`, | ||
text: `João, o usuário ${user.name} solicitou uma consulta médica. <br><br>Pedido realizado em <strong>${formattedDate}</strong> às <strong>${formattedTime}</strong>.<br><br><strong>Informações do usuário</strong><br>Nome: ${user.name}<br>Email: ${user.email}<br>Telefone: ${user.phone}<br>Idioma: ${user.language}<br>${user.gender != null ? "Gênero: "+ user.gender + "<br>": ""}${user.birthdate ? "Data de Nascimento: " + formattedBirthdate + "<br>" : ""}`, | ||
html: `João, o usuário ${user.name} solicitou uma consulta médica. <br><br>Pedido realizado em <strong>${formattedDate}</strong> às <strong>${formattedTime}</strong>.<br><br><strong>Informações do usuário</strong><br>Nome: ${user.name}<br>Email: ${user.email}<br>Telefone: ${user.phone}<br>Idioma: ${user.language}<br>${user.gender != null ? "Gênero: "+ user.gender + "<br>": ""}${user.birthdate ? "Data de Nascimento: " + formattedBirthdate + "<br>" : ""}`, | ||
}; | ||
|
||
try { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4195,6 +4195,11 @@ mkdirp@^1.0.3, mkdirp@^1.0.4: | |
resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz" | ||
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== | ||
|
||
moment@^2.30.1: | ||
version "2.30.1" | ||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae" | ||
integrity sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how== | ||
|
||
[email protected]: | ||
version "2.0.0" | ||
resolved "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz" | ||
|
@@ -5955,10 +5960,10 @@ tsutils@^3.17.1: | |
dependencies: | ||
tslib "^1.8.1" | ||
|
||
tsyringe@^4.4.0: | ||
version "4.4.0" | ||
resolved "https://registry.npmjs.org/tsyringe/-/tsyringe-4.4.0.tgz" | ||
integrity sha512-SlMApe1lhIq546CDp7bF+IdF4RB6d+9C5T7B0AS0P/Bm+Qpizj/gEmZzvw9J/KlXPEt4qHTbi1TRvX3rCPSdTg== | ||
tsyringe@^4.8.0: | ||
version "4.8.0" | ||
resolved "https://registry.yarnpkg.com/tsyringe/-/tsyringe-4.8.0.tgz#d599651b36793ba872870fee4f845bd484a5cac1" | ||
integrity sha512-YB1FG+axdxADa3ncEtRnQCFq/M0lALGLxSZeVNbTU8NqhOVc51nnv2CISTcvc1kyv6EGPtXVr0v6lWeDxiijOA== | ||
dependencies: | ||
tslib "^1.9.3" | ||
|
||
|