diff --git a/libs/common/src/constants/terms-condtions.ts b/libs/common/src/constants/terms-condtions.ts new file mode 100644 index 0000000..b0ba0af --- /dev/null +++ b/libs/common/src/constants/terms-condtions.ts @@ -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', +}; diff --git a/src/terms-conditions/services/terms-conditions.service.ts b/src/terms-conditions/services/terms-conditions.service.ts index 14d98d6..c8adf0f 100644 --- a/src/terms-conditions/services/terms-conditions.service.ts +++ b/src/terms-conditions/services/terms-conditions.service.ts @@ -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 { - // 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; }