-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* KYC save data * KYC save his data * Module to check KYC field * Module to check KYC field * Add Waiting List module * Module for waiting * fix tests * Finished Waiting list * Finished contact form --------- Co-authored-by: Abhishek Shandilya <[email protected]>
- Loading branch information
1 parent
d40b205
commit fd1b50f
Showing
9 changed files
with
531 additions
and
1 deletion.
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,25 @@ | ||
import { | ||
Body, | ||
Controller, | ||
Post | ||
} from '@nestjs/common'; | ||
import { ApiOperation, ApiTags } from '@nestjs/swagger'; | ||
import { _403, _404, _409 } from '../../common/constants/errors'; | ||
import { ContactService } from './contact.service'; | ||
import { Public } from 'src/common/decorators/public.decorator'; | ||
import { CreateContactDto } from './dto/contact.dto'; | ||
|
||
@ApiTags('Contacts') | ||
@Controller('contacts') | ||
export class ContactController { | ||
constructor(private readonly contactService: ContactService) {} | ||
|
||
@Post() | ||
@Public() | ||
@ApiOperation({ summary: 'Save contact information' }) | ||
async add(@Body() contactDto: CreateContactDto) { | ||
return await this.contactService.add(contactDto); | ||
} | ||
|
||
} | ||
|
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,17 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { Contact } from './entities/contact.entity'; | ||
import { ContactController } from './contact.controller'; | ||
import { ContactService } from './contact.service'; | ||
import { MailModule } from '../mail/mail.module'; | ||
|
||
@Module({ | ||
imports: [ | ||
TypeOrmModule.forFeature([Contact]), | ||
MailModule, | ||
], | ||
controllers: [ContactController], | ||
providers: [ContactService], | ||
exports: [ContactService], | ||
}) | ||
export class ContactModule {} |
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,39 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Repository } from 'typeorm'; | ||
import { _404 } from '../../common/constants/errors'; | ||
import { Contact } from './entities/contact.entity'; | ||
import { CreateContactDto } from './dto/contact.dto'; | ||
import { MailService } from '../mail/mail.service'; | ||
|
||
@Injectable() | ||
export class ContactService { | ||
constructor( | ||
@InjectRepository(Contact) | ||
private contactRepository: Repository<Contact>, | ||
private readonly mailService: MailService, | ||
|
||
) {} | ||
|
||
async add(contact: CreateContactDto): Promise<Contact> { | ||
|
||
const newWaiting = this.contactRepository.create({ | ||
fullname: contact.fullname, | ||
email: contact.email, | ||
object: contact.object, | ||
message: contact.message | ||
}); | ||
|
||
const contactSave = this.contactRepository.save(newWaiting); | ||
|
||
await this.mailService.receiveMailToWiiqare( | ||
contact.email, | ||
contact.fullname, | ||
contact.object, | ||
contact.message | ||
); | ||
|
||
return contactSave | ||
} | ||
|
||
} |
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,26 @@ | ||
import { Transform } from 'class-transformer'; | ||
import { | ||
IsEmail, | ||
IsNotEmpty, | ||
IsString | ||
} from 'class-validator'; | ||
|
||
export class CreateContactDto { | ||
|
||
@IsNotEmpty() | ||
@IsString() | ||
fullname: string; | ||
|
||
@IsNotEmpty() | ||
@IsString() | ||
@IsEmail() | ||
email: string; | ||
|
||
@IsNotEmpty() | ||
@IsString() | ||
object: string; | ||
|
||
@IsNotEmpty() | ||
@IsString() | ||
message: string; | ||
} |
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,19 @@ | ||
import { BaseEntity } from '../../../db/base-entity'; | ||
import { Entity, Column } from 'typeorm'; | ||
|
||
@Entity() | ||
export class Contact extends BaseEntity { | ||
|
||
@Column({nullable: false}) | ||
fullname: string; | ||
|
||
@Column({nullable: false}) | ||
email: string; | ||
|
||
@Column({nullable: false}) | ||
object: string; | ||
|
||
@Column({nullable: false}) | ||
message: string; | ||
|
||
} |
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 |
---|---|---|
|
@@ -104,4 +104,23 @@ export class MailService { | |
}, | ||
}); | ||
} | ||
|
||
async receiveMailToWiiqare( | ||
email: string, | ||
name: string, | ||
object: string, | ||
message: string | ||
): Promise<void> { | ||
await this.mailerService.sendMail({ | ||
to: "[email protected]", | ||
subject: object, | ||
template: './contact', | ||
context: { | ||
name: name.toUpperCase(), | ||
email, | ||
message, | ||
year: `© ${new Date().getFullYear()}`, | ||
}, | ||
}); | ||
} | ||
} |
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
Oops, something went wrong.