mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-16 02:36:19 +00:00
Merge pull request #216 from SyncrowIOT/SP-1085-be-get-the-user-agreement-data
Add Terms and Conditions Module
This commit is contained in:
@ -404,6 +404,15 @@ export class ControllerRoute {
|
||||
'This endpoint adds a new user role to the system based on the provided role data.';
|
||||
};
|
||||
};
|
||||
static TERMS_AND_CONDITIONS = class {
|
||||
public static readonly ROUTE = 'terms';
|
||||
|
||||
static ACTIONS = class {
|
||||
public static readonly FETCH_TERMS_SUMMARY = 'Fetch Terms and Conditions';
|
||||
public static readonly FETCH_TERMS_DESCRIPTION =
|
||||
'This endpoint retrieves the terms and conditions for the application.';
|
||||
};
|
||||
};
|
||||
static GROUP = class {
|
||||
public static readonly ROUTE = 'group';
|
||||
|
||||
|
44
libs/common/src/constants/terms-and-conditions.html
Normal file
44
libs/common/src/constants/terms-and-conditions.html
Normal file
@ -0,0 +1,44 @@
|
||||
<div>
|
||||
<p>User Agreement</p>
|
||||
<p>Terms and Conditions</p>
|
||||
<p><span>Last updated:</span> {{lastUpdated}}</p>
|
||||
<p>
|
||||
Please read these Terms and Conditions ("Terms", "Terms and Conditions")
|
||||
carefully before using the
|
||||
<a href="{{websiteUrl}}">{{websiteUrl}}</a> website and the {{mobileApp}}
|
||||
mobile application (the "Service") operated by {{companyName}}.
|
||||
</p>
|
||||
<p>
|
||||
Your access to and use of the Service is conditioned on your acceptance of
|
||||
and compliance with these Terms. These Terms apply to all visitors, users,
|
||||
and others who access or use the Service.
|
||||
</p>
|
||||
<p>Content</p>
|
||||
<p>
|
||||
Our Service allows you to post, link, store, share and otherwise make
|
||||
available certain information, text, graphics, videos, or other material
|
||||
("Content"). You are responsible for the Content you post.
|
||||
</p>
|
||||
<p>Links To Other Websites</p>
|
||||
<p>
|
||||
Our Service may contain links to third-party websites or services that are
|
||||
not owned or controlled by {{companyName}}.
|
||||
</p>
|
||||
<p>
|
||||
{{companyName}} has no control over, and assumes no responsibility for, the
|
||||
content, privacy policies, or practices of any third-party websites or
|
||||
services.
|
||||
</p>
|
||||
<p>Changes</p>
|
||||
<p>
|
||||
We reserve the right, at our sole discretion, to modify or replace these
|
||||
Terms at any time. If a revision is material, we will try to provide at
|
||||
least 30 days' notice prior to any new terms taking effect. What constitutes
|
||||
a material change will be determined at our sole discretion.
|
||||
</p>
|
||||
<p>Contact Us</p>
|
||||
<p>
|
||||
If you have any questions about these Terms, please
|
||||
<a href="mailto:{{contactEmail}}">contact us</a>.
|
||||
</p>
|
||||
</div>
|
7
libs/common/src/constants/terms-condtions.ts
Normal file
7
libs/common/src/constants/terms-condtions.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export const termsAndConditionsData = {
|
||||
lastUpdated: '25/01/2025',
|
||||
websiteUrl: 'https://www.Syncrow.ae',
|
||||
mobileApp: 'Syncrow Mobile App',
|
||||
companyName: 'Syncrow',
|
||||
contactEmail: 'contact@Syncrow.ae',
|
||||
};
|
@ -26,6 +26,7 @@ import { SpaceModelModule } from './space-model';
|
||||
import { InviteUserModule } from './invite-user/invite-user.module';
|
||||
import { PermissionModule } from './permission/permission.module';
|
||||
import { RoleModule } from './role/role.module';
|
||||
import { TermsConditionsModule } from './terms-conditions/terms-conditions.module';
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
@ -55,6 +56,7 @@ import { RoleModule } from './role/role.module';
|
||||
ProjectModule,
|
||||
PermissionModule,
|
||||
RoleModule,
|
||||
TermsConditionsModule,
|
||||
],
|
||||
providers: [
|
||||
{
|
||||
|
1
src/terms-conditions/controllers/index.ts
Normal file
1
src/terms-conditions/controllers/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './terms-conditions.controller';
|
@ -0,0 +1,32 @@
|
||||
import { Controller, Get, HttpStatus } from '@nestjs/common';
|
||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
|
||||
import { ControllerRoute } from '@app/common/constants/controller-route'; // Assuming this is where the routes are defined
|
||||
import { TermsAndConditionsService } from '../services';
|
||||
|
||||
@ApiTags('Terms & Conditions Module')
|
||||
@Controller({
|
||||
version: EnableDisableStatusEnum.ENABLED,
|
||||
path: ControllerRoute.TERMS_AND_CONDITIONS.ROUTE, // use the static route constant
|
||||
})
|
||||
export class TermsConditionsController {
|
||||
constructor(
|
||||
private readonly termsAndConditionsService: TermsAndConditionsService,
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({
|
||||
summary: ControllerRoute.TERMS_AND_CONDITIONS.ACTIONS.FETCH_TERMS_SUMMARY,
|
||||
description:
|
||||
ControllerRoute.TERMS_AND_CONDITIONS.ACTIONS.FETCH_TERMS_DESCRIPTION,
|
||||
})
|
||||
async fetchTermsAndConditions() {
|
||||
const htmlContent =
|
||||
await this.termsAndConditionsService.fetchTermsAndConditions();
|
||||
return {
|
||||
statusCode: HttpStatus.OK,
|
||||
message: 'Terms and conditions fetched successfully',
|
||||
data: htmlContent,
|
||||
};
|
||||
}
|
||||
}
|
1
src/terms-conditions/services/index.ts
Normal file
1
src/terms-conditions/services/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './terms-conditions.service';
|
38
src/terms-conditions/services/terms-conditions.service.ts
Normal file
38
src/terms-conditions/services/terms-conditions.service.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import { termsAndConditionsData } from '@app/common/constants/terms-condtions';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
@Injectable()
|
||||
export class TermsAndConditionsService {
|
||||
async fetchTermsAndConditions(): Promise<string> {
|
||||
const projectRoot = process.cwd();
|
||||
|
||||
const filePath = path.join(
|
||||
projectRoot,
|
||||
'libs',
|
||||
'common',
|
||||
'src',
|
||||
'constants',
|
||||
'terms-and-conditions.html',
|
||||
);
|
||||
|
||||
// Ensure the file exists
|
||||
if (!fs.existsSync(filePath)) {
|
||||
throw new Error(`File not found: ${filePath}`);
|
||||
}
|
||||
|
||||
let htmlContent = fs.readFileSync(filePath, 'utf-8');
|
||||
|
||||
htmlContent = htmlContent.replace(/(\r\n|\n|\r)/gm, ''); // Removes newlines
|
||||
|
||||
htmlContent = htmlContent
|
||||
.replace(/{{lastUpdated}}/g, termsAndConditionsData.lastUpdated)
|
||||
.replace(/{{websiteUrl}}/g, termsAndConditionsData.websiteUrl)
|
||||
.replace(/{{mobileApp}}/g, termsAndConditionsData.mobileApp)
|
||||
.replace(/{{companyName}}/g, termsAndConditionsData.companyName)
|
||||
.replace(/{{contactEmail}}/g, termsAndConditionsData.contactEmail);
|
||||
|
||||
return htmlContent;
|
||||
}
|
||||
}
|
12
src/terms-conditions/terms-conditions.module.ts
Normal file
12
src/terms-conditions/terms-conditions.module.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { DeviceRepositoryModule } from '@app/common/modules/device';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { TermsConditionsController } from './controllers';
|
||||
import { TermsAndConditionsService } from './services';
|
||||
|
||||
@Module({
|
||||
imports: [ConfigModule, DeviceRepositoryModule],
|
||||
controllers: [TermsConditionsController],
|
||||
providers: [TermsAndConditionsService],
|
||||
})
|
||||
export class TermsConditionsModule {}
|
Reference in New Issue
Block a user