Add terms and conditions data constants and update service

This commit is contained in:
faris Aljohari
2025-01-15 23:24:37 -06:00
parent c7bcb177e1
commit 12ddb95f19
2 changed files with 13 additions and 19 deletions

View 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',
};

View File

@ -1,3 +1,4 @@
import { termsAndConditionsData } from '@app/common/constants/terms-condtions';
import { Injectable } from '@nestjs/common';
import * as fs from 'fs';
import * as path from 'path';
@ -5,10 +6,8 @@ import * as path from 'path';
@Injectable()
export class TermsAndConditionsService {
async fetchTermsAndConditions(): Promise<string> {
// Use process.cwd() to get the current working directory (project root)
const projectRoot = process.cwd();
// Dynamically build the path to the terms-and-conditions.html file from the root
const filePath = path.join(
projectRoot,
'libs',
@ -23,28 +22,16 @@ export class TermsAndConditionsService {
throw new Error(`File not found: ${filePath}`);
}
// Read the HTML content from the file
let htmlContent = fs.readFileSync(filePath, 'utf-8');
// Optionally, remove newlines or excess white spaces using a regular expression
htmlContent = htmlContent.replace(/(\r\n|\n|\r)/gm, ''); // Removes newlines
// Define dynamic values
const dynamicValues = {
lastUpdated: '25/01/2025',
websiteUrl: 'http://www.mywebsite.com',
mobileApp: 'My Mobile App',
companyName: 'My Company',
contactEmail: 'contact@mycompany.com',
};
// Replace placeholders in the HTML with dynamic values
htmlContent = htmlContent
.replace(/{{lastUpdated}}/g, dynamicValues.lastUpdated)
.replace(/{{websiteUrl}}/g, dynamicValues.websiteUrl)
.replace(/{{mobileApp}}/g, dynamicValues.mobileApp)
.replace(/{{companyName}}/g, dynamicValues.companyName)
.replace(/{{contactEmail}}/g, dynamicValues.contactEmail);
.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;
}