Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
import { FoundCompanyImageInfo } from './found-company-logo.ro.js';
import { SubscriptionLevelEnum } from '../../../../enums/subscription-level.enum.js';

export class FoundCompanyWhiteLabelPropertiesRO {
@ApiProperty({ type: FoundCompanyImageInfo, required: false })
Expand All @@ -10,4 +11,7 @@ export class FoundCompanyWhiteLabelPropertiesRO {

@ApiProperty({ type: String, required: false })
tab_title: string;

@ApiProperty({ enum: SubscriptionLevelEnum })
subscriptionLevel: SubscriptionLevelEnum;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { IGetCompanyWhiteLabelProperties } from './company-info-use-cases.interf
import { BaseType } from '../../../common/data-injection.tokens.js';
import { IGlobalDatabaseContext } from '../../../common/application/global-database-context.interface.js';
import { Messages } from '../../../exceptions/text/messages.js';
import { isSaaS } from '../../../helpers/app/is-saas.js';
import { SaasCompanyGatewayService } from '../../../microservices/gateways/saas-gateway.ts/saas-company-gateway.service.js';

@Injectable()
export class FindCompanyWhiteLabelPropertiesUseCase
Expand All @@ -14,6 +16,7 @@ export class FindCompanyWhiteLabelPropertiesUseCase
constructor(
@Inject(BaseType.GLOBAL_DB_CONTEXT)
protected _dbContext: IGlobalDatabaseContext,
private readonly saasCompanyGatewayService: SaasCompanyGatewayService,
) {
super();
}
Expand All @@ -24,6 +27,15 @@ export class FindCompanyWhiteLabelPropertiesUseCase
throw new NotFoundException(Messages.COMPANY_NOT_FOUND);
}

let companySubscriptionLevel = null;
if (isSaaS()) {
const companyInfoFromSaas = await this.saasCompanyGatewayService.getCompanyInfo(companyId);
if (!companyInfoFromSaas) {
throw new NotFoundException(Messages.COMPANY_NOT_FOUND);
}
companySubscriptionLevel = companyInfoFromSaas.subscriptionLevel;
}

return {
logo: company.logo
? {
Expand All @@ -38,6 +50,7 @@ export class FindCompanyWhiteLabelPropertiesUseCase
}
: null,
tab_title: company.tab_title?.text ?? null,
subscriptionLevel: companySubscriptionLevel,
};
}
}