Commit ae97dfb 1 parent 7cee5e8 commit ae97dfb Copy full SHA for ae97dfb
File tree 4 files changed +100
-0
lines changed
packages/cli/commands/user-comms
4 files changed +100
-0
lines changed Original file line number Diff line number Diff line change
1
+ import fs from "fs"
2
+ import path from "path"
3
+ import { input , confirm } from "@inquirer/prompts"
4
+ import nunjucks from "nunjucks"
5
+ import { parse , format , isValid } from "date-fns"
6
+
7
+ export const pncMaintenance = async ( ) => {
8
+ const templateFile = "pnc-maintenance.txt"
9
+ const templatePath = path . join ( "./commands/user-comms/templates" , templateFile )
10
+ const templateContent = fs . readFileSync ( templatePath , "utf-8" )
11
+
12
+ const dateInput = await input ( { message : "Enter the date (dd/MM/yyyy)" } )
13
+ const startTime = await input ( { message : "Enter start time (HH:mm)" } )
14
+ const endTime = await input ( { message : "Enter end time (HH:mm)" } )
15
+
16
+ const parsedDate = parse ( dateInput , "dd/MM/yyyy" , new Date ( ) )
17
+
18
+ if ( ! isValid ( parsedDate ) ) {
19
+ console . error ( "Invalid date format. Please use 'dd/MM/yyyy' (e.g., '17/03/2025')." )
20
+ return
21
+ }
22
+
23
+ const formattedDate = format ( parsedDate , "EEEE d MMMM yyyy" )
24
+
25
+ const renderedEmail = nunjucks . renderString ( templateContent , {
26
+ date : formattedDate ,
27
+ startTime : startTime ,
28
+ endTime : endTime
29
+ } )
30
+
31
+ console . log ( "\n=== Preview Email ===\n" )
32
+ console . log ( renderedEmail )
33
+
34
+ const answer = await confirm ( { message : "Do you want to use this template?" } )
35
+
36
+ if ( ! answer ) {
37
+ process . exit ( 1 )
38
+ }
39
+ }
Original file line number Diff line number Diff line change
1
+ import fs from "fs"
2
+ import path from "path"
3
+ import { confirm , select } from "@inquirer/prompts"
4
+ import nunjucks from "nunjucks"
5
+
6
+ export const pncMaintenanceExtended = async ( ) => {
7
+ const templateFile = "pnc-maintenance-extended.txt"
8
+ const templatePath = path . join ( "./commands/user-comms/templates" , templateFile )
9
+ const templateContent = fs . readFileSync ( templatePath , "utf-8" )
10
+
11
+ const extendedTimeFrameInput = await select ( {
12
+ message : "Select a time frame" ,
13
+ choices : [
14
+ {
15
+ name : "1 hour" ,
16
+ value : "1 hour" ,
17
+ description : "The extended time frame is estimated at 1 hour"
18
+ } ,
19
+ {
20
+ name : "2 hour" ,
21
+ value : "2 hour" ,
22
+ description : "The extended time frame is estimated at 2 hour"
23
+ }
24
+ ]
25
+ } )
26
+
27
+ const renderedEmail = nunjucks . renderString ( templateContent , {
28
+ extendedTimeFrame : extendedTimeFrameInput
29
+ } )
30
+
31
+ console . log ( "\n=== Preview Email ===\n" )
32
+ console . log ( renderedEmail )
33
+
34
+ const answer = await confirm ( { message : "Do you want to use this template?" } )
35
+
36
+ if ( ! answer ) {
37
+ process . exit ( 1 )
38
+ }
39
+ }
Original file line number Diff line number Diff line change
1
+ Hello {{ firstName | default("first-name") }},
2
+
3
+ We regret to inform you that the PNC planned maintenance has be unexpectedly extended.
4
+ We have been informed that the on going work should be resolved in {{ extendedTimeFrame }}
5
+
6
+ This is an estimated time, so we apologise for the inconvenience and appreciate your patience.
7
+ We will keep you informed on any changes
8
+
9
+ Thank you,
10
+ The Bichard 7 Support team
Original file line number Diff line number Diff line change
1
+ Hello {{ firstName | default("first-name") }},
2
+
3
+ As a part of ongoing work to maintain and improve Bichard 7 and the PNC, there will be an impact on service during the following window:
4
+
5
+ {{ day }} {{ date }} {{ startTime }} - {{ endTime }}
6
+
7
+ During this window, the PNC will be unavailable. Any messages submitted will cause an error message to be displayed and will need to be resubmitted after the change window.
8
+
9
+ We apologise for the inconvenience and appreciate your patience.
10
+
11
+ Thank you,
12
+ The Bichard 7 Support team
You can’t perform that action at this time.
0 commit comments