fix : create restuarant
This commit is contained in:
@@ -1,24 +1,12 @@
|
|||||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
import { IsString, IsOptional, IsNumber } from 'class-validator';
|
import { IsString } from 'class-validator';
|
||||||
|
|
||||||
export class SetupRestaurantDto {
|
export class SetupRestaurantDto {
|
||||||
@ApiProperty({ example: 'کافه ژیوان', description: 'نام رستوران' })
|
|
||||||
@IsString()
|
|
||||||
name!: string;
|
|
||||||
|
|
||||||
@ApiProperty({ example: 'zhivan', description: 'شناسه (slug) رستوران، لاتین و بدون فاصله' })
|
@ApiProperty({ example: 'zhivan', description: 'شناسه (slug) رستوران، لاتین و بدون فاصله' })
|
||||||
@IsString()
|
@IsString()
|
||||||
slug!: string;
|
slug!: string;
|
||||||
|
|
||||||
@ApiPropertyOptional({ example: 2020, description: 'سال تأسیس' })
|
|
||||||
@IsOptional()
|
|
||||||
@IsNumber()
|
|
||||||
establishedYear: number;
|
|
||||||
|
|
||||||
@ApiPropertyOptional({ example: '09123456789', description: 'شماره تلفن' })
|
|
||||||
@IsOptional()
|
|
||||||
@IsString()
|
|
||||||
phone: string;
|
|
||||||
|
|
||||||
@ApiProperty({ example: 'sub_1234567890', description: 'شناسه اشتراک' })
|
@ApiProperty({ example: 'sub_1234567890', description: 'شناسه اشتراک' })
|
||||||
@IsString()
|
@IsString()
|
||||||
|
|||||||
@@ -124,11 +124,17 @@ export class RestaurantService {
|
|||||||
}
|
}
|
||||||
const plan = userSubscription.plan.name.includes("دلیوری") ? PlanEnum.Premium : PlanEnum.Base;
|
const plan = userSubscription.plan.name.includes("دلیوری") ? PlanEnum.Premium : PlanEnum.Base;
|
||||||
|
|
||||||
|
const user = await this.usersService.findOneById(userSubscription.user.id)
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
throw new BadRequestException("User Not found");
|
||||||
|
}
|
||||||
|
|
||||||
const setupRestaurantDto: ISetupRestaurant = {
|
const setupRestaurantDto: ISetupRestaurant = {
|
||||||
name: dto.name,
|
name: userSubscription.businessName,
|
||||||
slug: dto.slug,
|
slug: dto.slug,
|
||||||
establishedYear: dto.establishedYear,
|
establishedYear: 1400,
|
||||||
phone: dto.phone,
|
phone: user.user.phone,
|
||||||
plan,
|
plan,
|
||||||
subscriptionId: dto.userSubscriptionId,
|
subscriptionId: dto.userSubscriptionId,
|
||||||
subscriptionEndDate: userSubscription.endDate.toISOString(),
|
subscriptionEndDate: userSubscription.endDate.toISOString(),
|
||||||
|
|||||||
Reference in New Issue
Block a user