-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dependabot/npm_and_yarn/http-proxy-middlew…
…are-2.0.7
- Loading branch information
Showing
19 changed files
with
380 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/api/src/assets/templates/create-campaign-application-organizer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"subject": "Създадена нова кампания" | ||
"subject": "Потвърждение за получаване на заявка за дарителска кампания " | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
padding-right="25px" | ||
padding-bottom="30px" | ||
padding-top="50px"> | ||
Успешно създадохте кампания в Подкрепи.бг | ||
Потвърждение за получаване на заявка за дарителска кампания | ||
</mj-text> | ||
</mj-column> | ||
</mj-section> | ||
|
@@ -25,7 +25,7 @@ | |
font-family="open Sans Helvetica, Arial, sans-serif" | ||
padding-left="25px" | ||
padding-right="25px"> | ||
<span style="color: #feeb35"> Здравейте {{firstName}}, </span> | ||
<span style="color: #feeb35"> Здравейте, {{firstName}}, </span> | ||
<br /><br /> | ||
</mj-text> | ||
<mj-text | ||
|
@@ -35,11 +35,20 @@ | |
font-family="open Sans Helvetica, Arial, sans-serif" | ||
padding-left="25px" | ||
padding-right="25px"> | ||
Вашата кампания е създадена успешно! Вижте я | ||
Благодарим Ви, че подадохте заявка за кампания на платформата Подкрепи.бг!<br />Можете да | ||
я прегледате | ||
<a style="color: #feeb35" href="{{campaignApplicationLink}}" target="_blank">ТУК</a | ||
>!<br /><br /> | ||
>.<br /><br /> | ||
|
||
Пожелаваме успешно набиране на средствата! | ||
Искаме да Ви уверим, че заявката Ви е успешно получена и ще бъде разгледана от екипа ни в | ||
най-кратък срок. Ако има нужда от допълнителна информация или уточнения, член на екип | ||
„Кампании“ ще се свърже с Вас.<br /><br /> | ||
|
||
Междувременно, ако имате въпроси или желаете да предоставите допълнителни детайли за | ||
кампанията, можете да се свържете с нас на следния имейл: | ||
<a style="color: #feeb35" href="mailto:[email protected]" target="_blank" | ||
>[email protected]</a | ||
>. Благодарим Ви, че заедно правим добро!<br /><br /> | ||
</mj-text> | ||
<mj-text | ||
align="left" | ||
|
@@ -48,7 +57,7 @@ | |
font-family="open Sans Helvetica, Arial, sans-serif" | ||
padding-left="25px" | ||
padding-right="25px"> | ||
Поздрави, <br /> | ||
С уважение, <br /> | ||
Екипът на Подкрепи.бг | ||
</mj-text> | ||
</mj-column> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Email Template Service | ||
|
||
It gets the templates based on the name and the templates in the src/assets/templates. | ||
|
||
## Testing with adapter | ||
|
||
Why do we need the `template.service.spec-adapter.ts` when we have the `template.service.ts`? | ||
It's looking in a hardcoded path which is correct when the app is built and deployed but incorrect when running the tests. Hence we extend the base class with this for the tests. | ||
|
||
## Visualize the template before you ship the code | ||
|
||
- temporarily add a line like `writeFileSync('./rendered-template.html', rendered.html)` to your test (careful to not ) | ||
- then open that with the browser i.e. `file:///C:/Users/gparl/Downloads/projects/podkrepi-bg-api/rendered-template.html` or on ubuntu under wsl `file://wsl.localhost/Ubuntu/home/gparlakov/projects/podkrepi-bg-api/rendered-template.html` | ||
- remember to delete that `writeFileSync` line and the `rendered-template.html` before you ship | ||
|
||
```ts | ||
const t = new CreateCampaignApplicationOrganizerEmailDto({ | ||
firstName: 'test', | ||
email: 'test@email', | ||
campaignApplicationLink: 'link', | ||
campaignApplicationName: 'campaignApplicationName', | ||
}) | ||
|
||
const rendered = await s.getTemplate(t) | ||
|
||
writeFileSync('./rendered-template.html', rendered.html) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Logger } from '@nestjs/common' | ||
import { readFile } from 'fs/promises' | ||
import mjml from 'mjml' | ||
import path from 'path' | ||
|
||
import { EmailMetadata, TemplateType } from './template.interface' | ||
import { TemplateService } from './template.service' | ||
|
||
export class TemplateServiceSpecAdapter extends TemplateService { | ||
/** | ||
* Why do we need this when we have the template.service.ts? | ||
* It's looking in a hardcoded path which is correct when the app is built and deployed but incorrect when running the tests. | ||
* Hence we extend the base class with this for the tests. | ||
* | ||
* @param basePath where to look for the assets/templates/*.mjml files | ||
*/ | ||
constructor(private basePath: string) { | ||
super() | ||
} | ||
|
||
protected async getEmailTemplate(templateName: TemplateType): Promise<ReturnType<typeof mjml>> { | ||
try { | ||
const file = await readFile( | ||
path.resolve(this.basePath, `./assets/templates/${templateName}.mjml`), | ||
{ encoding: 'utf-8' }, | ||
) | ||
return mjml(file) | ||
} catch (error) { | ||
Logger.error(`getEmailTemplate`, error) | ||
throw error | ||
} | ||
} | ||
|
||
protected async getEmailData(templateName: string): Promise<EmailMetadata> { | ||
try { | ||
const contents = await readFile( | ||
path.resolve(this.basePath, `./assets/templates/${templateName}.json`), | ||
{ encoding: 'utf-8' }, | ||
) | ||
return JSON.parse(contents) | ||
} catch (error) { | ||
Logger.error(`getEmailData`, error) | ||
throw error | ||
} | ||
} | ||
} |
Oops, something went wrong.