@@ -1,6 +1,7 @@
|
||||
import { Controller, Delete, Inject, Param, Post, UploadedFile, UseInterceptors } from '@nestjs/common';
|
||||
import { Controller, Delete, Inject, Param, Post, UploadedFile, UseGuards, UseInterceptors } from '@nestjs/common';
|
||||
import { FileInterceptor } from '@nestjs/platform-express';
|
||||
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
|
||||
import { JwtAuthGuard } from 'src/jwt-auth/jwt-auth.guard';
|
||||
import { Logger } from 'winston';
|
||||
import { FileService } from '../file/file.service';
|
||||
import { CommercialPropertyService } from '../listings/commercial-property.service';
|
||||
@@ -17,12 +18,14 @@ export class ImageController {
|
||||
// ############
|
||||
// Property
|
||||
// ############
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('uploadPropertyPicture/:imagePath/:serial')
|
||||
@UseInterceptors(FileInterceptor('file'))
|
||||
async uploadPropertyPicture(@UploadedFile() file: Express.Multer.File, @Param('imagePath') imagePath: string, @Param('serial') serial: string) {
|
||||
const imagename = await this.fileService.storePropertyPicture(file, imagePath, serial);
|
||||
await this.listingService.addImage(imagePath, serial, imagename);
|
||||
}
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Delete('propertyPicture/:imagePath/:serial/:imagename')
|
||||
async deletePropertyImagesById(@Param('imagePath') imagePath: string, @Param('serial') serial: string, @Param('imagename') imagename: string): Promise<any> {
|
||||
this.fileService.deleteImage(`pictures/property/${imagePath}/${serial}/${imagename}`);
|
||||
@@ -31,11 +34,13 @@ export class ImageController {
|
||||
// ############
|
||||
// Profile
|
||||
// ############
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('uploadProfile/:email')
|
||||
@UseInterceptors(FileInterceptor('file'))
|
||||
async uploadProfile(@UploadedFile() file: Express.Multer.File, @Param('email') adjustedEmail: string) {
|
||||
await this.fileService.storeProfilePicture(file, adjustedEmail);
|
||||
}
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Delete('profile/:email/')
|
||||
async deleteProfileImagesById(@Param('email') email: string): Promise<any> {
|
||||
this.fileService.deleteImage(`pictures/profile/${email}.avif`);
|
||||
@@ -43,11 +48,13 @@ export class ImageController {
|
||||
// ############
|
||||
// Logo
|
||||
// ############
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('uploadCompanyLogo/:email')
|
||||
@UseInterceptors(FileInterceptor('file'))
|
||||
async uploadCompanyLogo(@UploadedFile() file: Express.Multer.File, @Param('email') adjustedEmail: string) {
|
||||
await this.fileService.storeCompanyLogo(file, adjustedEmail);
|
||||
}
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Delete('logo/:email/')
|
||||
async deleteLogoImagesById(@Param('email') adjustedEmail: string): Promise<any> {
|
||||
this.fileService.deleteImage(`pictures/logo/${adjustedEmail}.avif`);
|
||||
|
||||
@@ -103,9 +103,6 @@ export class BusinessListingService {
|
||||
whereConditions.push(and(ilike(schema.users.firstname, `%${firstname}%`), ilike(schema.users.lastname, `%${lastname}%`)));
|
||||
}
|
||||
}
|
||||
// if (criteria.brokerName) {
|
||||
// whereConditions.push(or(ilike(schema.users.firstname, `%${criteria.brokerName}%`), ilike(schema.users.lastname, `%${criteria.brokerName}%`)));
|
||||
// }
|
||||
if (!user?.roles?.includes('ADMIN') ?? false) {
|
||||
whereConditions.push(or(eq(businesses.email, user?.username), ne(businesses.draft, true)));
|
||||
}
|
||||
|
||||
@@ -51,16 +51,12 @@ export class BusinessListingsController {
|
||||
this.logger.info(`Save Listing`);
|
||||
return this.listingsService.updateBusinessListing(listing.id, listing);
|
||||
}
|
||||
@Delete(':id')
|
||||
@Delete('listing/:id')
|
||||
deleteById(@Param('id') id: string) {
|
||||
this.listingsService.deleteListing(id);
|
||||
}
|
||||
// @Get('states/all')
|
||||
// getStates(): any {
|
||||
// return this.listingsService.getStates();
|
||||
// }
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Delete('favorites/:id')
|
||||
@Delete('favorite/:id')
|
||||
deleteFavorite(@Request() req, @Param('id') id: string) {
|
||||
this.listingsService.deleteFavorite(id, req.user as JwtUser);
|
||||
}
|
||||
|
||||
@@ -41,10 +41,6 @@ export class CommercialPropertyListingsController {
|
||||
findTotal(@Request() req, @Body() criteria: CommercialPropertyListingCriteria): Promise<number> {
|
||||
return this.listingsService.getCommercialPropertiesCount(criteria, req.user as JwtUser);
|
||||
}
|
||||
// @Get('states/all')
|
||||
// getStates(): any {
|
||||
// return this.listingsService.getStates();
|
||||
// }
|
||||
@Post()
|
||||
async create(@Body() listing: any) {
|
||||
this.logger.info(`Save Listing`);
|
||||
@@ -55,13 +51,13 @@ export class CommercialPropertyListingsController {
|
||||
this.logger.info(`Save Listing`);
|
||||
return await this.listingsService.updateCommercialPropertyListing(listing.id, listing);
|
||||
}
|
||||
@Delete(':id/:imagePath')
|
||||
@Delete('listing/:id/:imagePath')
|
||||
deleteById(@Param('id') id: string, @Param('imagePath') imagePath: string) {
|
||||
this.listingsService.deleteListing(id);
|
||||
this.fileService.deleteDirectoryIfExists(imagePath);
|
||||
}
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Delete('favorites/:id')
|
||||
@Delete('favorite/:id')
|
||||
deleteFavorite(@Request() req, @Param('id') id: string) {
|
||||
this.listingsService.deleteFavorite(id, req.user as JwtUser);
|
||||
}
|
||||
|
||||
@@ -115,8 +115,8 @@ export class MailService {
|
||||
//template: './inquiry', // `.hbs` extension is appended automatically
|
||||
template: join(__dirname, '../..', 'mail/templates/send2Friend.hbs'),
|
||||
context: {
|
||||
name: shareByEMail.name,
|
||||
email: shareByEMail.email,
|
||||
name: shareByEMail.yourName,
|
||||
email: shareByEMail.yourEmail,
|
||||
listingTitle: shareByEMail.listingTitle,
|
||||
url: shareByEMail.url,
|
||||
id: shareByEMail.id,
|
||||
|
||||
@@ -307,9 +307,9 @@ export const SenderSchema = z.object({
|
||||
});
|
||||
export type Sender = z.infer<typeof SenderSchema>;
|
||||
export const ShareByEMailSchema = z.object({
|
||||
name: z.string().min(6, { message: 'Name must be at least 6 characters long' }),
|
||||
yourName: z.string().min(6, { message: 'Name must be at least 6 characters long' }),
|
||||
recipientEmail: z.string().email({ message: 'Invalid email address' }),
|
||||
email: z.string().email({ message: 'Invalid email address' }),
|
||||
yourEmail: z.string().email({ message: 'Invalid email address' }),
|
||||
listingTitle: z.string().optional().nullable(),
|
||||
url: z.string().url({ message: 'Invalid URL format' }).optional().nullable(),
|
||||
id: z.string().optional().nullable(),
|
||||
|
||||
Reference in New Issue
Block a user