Skip to content

Commit b7e29b5

Browse files
committed
edit templates for attendance and mailing list
1 parent a3639c8 commit b7e29b5

File tree

7 files changed

+319
-141
lines changed

7 files changed

+319
-141
lines changed

packages/backend/src/db/storage/attendance-taking.ts

Lines changed: 73 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const ATTENDANCE_TAKING_TEMPLATE: ITemplate = {
1717
'Track attendance for your event using a form and a pre-populated table of event participants',
1818
iconName: 'BiCheckDouble',
1919
tags: ['empty'],
20-
// Steps: formsg --> find tile row --> update tile row
20+
// Steps: formsg --> find tile row --> if-then condition --> create or update tile row
2121
steps: [
2222
{
2323
position: 1,
@@ -37,7 +37,7 @@ export const ATTENDANCE_TAKING_TEMPLATE: ITemplate = {
3737
filters: [
3838
{
3939
columnId: TILE_COL_DATA_PLACEHOLDER('Email'),
40-
value: 'jane@email.com',
40+
value: CREATE_TEMPLATE_STEP_VARIABLE('Replace with email response'),
4141
operator: 'equals',
4242
},
4343
],
@@ -47,14 +47,78 @@ export const ATTENDANCE_TAKING_TEMPLATE: ITemplate = {
4747
},
4848
{
4949
position: 3,
50+
appKey: 'toolbox',
51+
eventKey: 'ifThen',
52+
parameters: {
53+
depth: 0,
54+
branchName: 'Registering attendance for the first time',
55+
conditions: [
56+
{
57+
is: 'is',
58+
text: '0',
59+
field: CREATE_TEMPLATE_STEP_VARIABLE('rowsFound', 2),
60+
condition: 'equals',
61+
},
62+
],
63+
},
64+
},
65+
{
66+
position: 4,
67+
appKey: 'tiles',
68+
eventKey: 'createTileRow',
69+
parameters: {
70+
rowData: [
71+
{
72+
columnId: TILE_COL_DATA_PLACEHOLDER('Email'),
73+
cellValue: CREATE_TEMPLATE_STEP_VARIABLE(
74+
'Replace with email response',
75+
),
76+
},
77+
{
78+
columnId: TILE_COL_DATA_PLACEHOLDER('Name'),
79+
cellValue: CREATE_TEMPLATE_STEP_VARIABLE(
80+
'Replace with name response',
81+
),
82+
},
83+
{
84+
columnId: TILE_COL_DATA_PLACEHOLDER('Attending?'),
85+
cellValue: CREATE_TEMPLATE_STEP_VARIABLE(
86+
'Replace with attending response',
87+
),
88+
},
89+
],
90+
tableId: TILE_ID_PLACEHOLDER,
91+
},
92+
},
93+
{
94+
position: 5,
95+
appKey: 'toolbox',
96+
eventKey: 'ifThen',
97+
parameters: {
98+
depth: 0,
99+
branchName: 'Updating existing attendance',
100+
conditions: [
101+
{
102+
is: 'not',
103+
text: '0',
104+
field: CREATE_TEMPLATE_STEP_VARIABLE('rowsFound', 2),
105+
condition: 'equals',
106+
},
107+
],
108+
},
109+
},
110+
{
111+
position: 6,
50112
appKey: 'tiles',
51113
eventKey: 'updateSingleRow',
52114
parameters: {
53115
rowId: CREATE_TEMPLATE_STEP_VARIABLE('rowId', 2),
54116
rowData: [
55117
{
56-
columnId: TILE_COL_DATA_PLACEHOLDER('Attended?'),
57-
cellValue: 'Yes',
118+
columnId: TILE_COL_DATA_PLACEHOLDER('Attending?'),
119+
cellValue: CREATE_TEMPLATE_STEP_VARIABLE(
120+
'Replace with attending response',
121+
),
58122
},
59123
],
60124
tableId: TILE_ID_PLACEHOLDER,
@@ -63,17 +127,17 @@ export const ATTENDANCE_TAKING_TEMPLATE: ITemplate = {
63127
],
64128
tileTemplateData: {
65129
name: 'Event attendance',
66-
columns: ['Name', 'Email', 'Attended?'],
130+
columns: ['Email', 'Name', 'Attending?'],
67131
rowData: [
68132
{
69-
Name: 'Jane Doe',
70133
71-
'Attended?': 'No',
134+
Name: 'Jane Doe',
135+
'Attending?': 'No',
72136
},
73137
{
74-
Name: 'John Doe',
75138
76-
'Attended?': 'Yes',
139+
Name: 'John Doe',
140+
'Attending?': 'Yes',
77141
},
78142
],
79143
},

packages/backend/src/db/storage/route-support-enquiries.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ export const ROUTE_SUPPORT_ENQUIRIES_TEMPLATE: ITemplate = {
8484
parameters: {
8585
body: `<p style="margin: 0">You have received a support request from ${CREATE_TEMPLATE_STEP_VARIABLE(
8686
'Replace this with data from step 1',
87-
)}!</p><p style="margin: 0"></p><p style="margin: 0">Here is what their request is about:</p><p style="margin: 0">${CREATE_TEMPLATE_STEP_VARIABLE(
87+
)}! </p><p style="margin: 0"></p><p style="margin: 0">Here is what their request is about: </p><p style="margin: 0">${CREATE_TEMPLATE_STEP_VARIABLE(
8888
'Replace this with data from step 1',
8989
)}</p><p style="margin: 0"></p><p style="margin: 0">Please respond to them within 3 working days. Thank you!</p>`,
9090
subject: `You have received a IT support request from ${CREATE_TEMPLATE_STEP_VARIABLE(
9191
'Replace this with data from step 1',
9292
)}!`,
93-
senderName: 'IT support ',
93+
senderName: 'IT support request',
9494
destinationEmail: USER_EMAIL_PLACEHOLDER,
9595
},
9696
},
@@ -115,6 +115,20 @@ export const ROUTE_SUPPORT_ENQUIRIES_TEMPLATE: ITemplate = {
115115
},
116116
{
117117
position: 7,
118+
appKey: 'postman',
119+
eventKey: 'sendTransactionalEmail',
120+
parameters: {
121+
body: `<p style="margin: 0">You have received a support request from ${CREATE_TEMPLATE_STEP_VARIABLE(
122+
'Replace this with data from step 1',
123+
)}! </p><p style="margin: 0"></p><p style="margin: 0">Here is what their request is about: </p><p style="margin: 0">${CREATE_TEMPLATE_STEP_VARIABLE(
124+
'Replace this with data from step 1',
125+
)}</p><p style="margin: 0"></p><p style="margin: 0">Please respond to them within 3 working days. Thank you!</p>`,
126+
subject: `You have received a IT support request from ${CREATE_TEMPLATE_STEP_VARIABLE(
127+
'Replace this with data from step 1',
128+
)}!`,
129+
senderName: 'IT support request',
130+
destinationEmail: USER_EMAIL_PLACEHOLDER,
131+
},
118132
},
119133
{
120134
position: 8,
@@ -137,6 +151,20 @@ export const ROUTE_SUPPORT_ENQUIRIES_TEMPLATE: ITemplate = {
137151
},
138152
{
139153
position: 9,
154+
appKey: 'postman',
155+
eventKey: 'sendTransactionalEmail',
156+
parameters: {
157+
body: `<p style="margin: 0">You have received a support request from ${CREATE_TEMPLATE_STEP_VARIABLE(
158+
'Replace this with data from step 1',
159+
)}! </p><p style="margin: 0"></p><p style="margin: 0">Here is what their request is about: </p><p style="margin: 0">${CREATE_TEMPLATE_STEP_VARIABLE(
160+
'Replace this with data from step 1',
161+
)}</p><p style="margin: 0"></p><p style="margin: 0">Please respond to them within 3 working days. Thank you!</p>`,
162+
subject: `You have received a IT support request from ${CREATE_TEMPLATE_STEP_VARIABLE(
163+
'Replace this with data from step 1',
164+
)}!`,
165+
senderName: 'IT support request',
166+
destinationEmail: USER_EMAIL_PLACEHOLDER,
167+
},
140168
},
141169
],
142170
}

packages/backend/src/db/storage/update-mailing-lists.ts

Lines changed: 77 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const UPDATE_MAILING_LISTS_TEMPLATE: ITemplate = {
1616
description:
1717
'Maintain mailing lists and keep them updated with the latest recipient information',
1818
iconName: 'BiListUl',
19-
// Steps: formsg --> find tile row --> update tile row
19+
// Steps: formsg --> find tile row --> if-then condition --> create or update tile row
2020
steps: [
2121
{
2222
position: 1,
@@ -36,7 +36,7 @@ export const UPDATE_MAILING_LISTS_TEMPLATE: ITemplate = {
3636
filters: [
3737
{
3838
columnId: TILE_COL_DATA_PLACEHOLDER('Name'),
39-
value: 'Anna Lee',
39+
value: CREATE_TEMPLATE_STEP_VARIABLE('Replace with name response'),
4040
operator: 'equals',
4141
},
4242
],
@@ -46,15 +46,83 @@ export const UPDATE_MAILING_LISTS_TEMPLATE: ITemplate = {
4646
},
4747
{
4848
position: 3,
49+
appKey: 'toolbox',
50+
eventKey: 'ifThen',
51+
parameters: {
52+
depth: 0,
53+
branchName: 'Officer has not signed up for the mailing list',
54+
conditions: [
55+
{
56+
is: 'is',
57+
text: '0',
58+
field: CREATE_TEMPLATE_STEP_VARIABLE('rowsFound', 2),
59+
condition: 'equals',
60+
},
61+
],
62+
},
63+
},
64+
{
65+
position: 4,
66+
appKey: 'tiles',
67+
eventKey: 'createTileRow',
68+
parameters: {
69+
rowData: [
70+
{
71+
columnId: TILE_COL_DATA_PLACEHOLDER('Email'),
72+
cellValue: CREATE_TEMPLATE_STEP_VARIABLE(
73+
'Replace with email response',
74+
),
75+
},
76+
{
77+
columnId: TILE_COL_DATA_PLACEHOLDER('Name'),
78+
cellValue: CREATE_TEMPLATE_STEP_VARIABLE(
79+
'Replace with name response',
80+
),
81+
},
82+
{
83+
columnId: TILE_COL_DATA_PLACEHOLDER('Mobile number'),
84+
cellValue: CREATE_TEMPLATE_STEP_VARIABLE(
85+
'Replace with mobile number response',
86+
),
87+
},
88+
],
89+
tableId: TILE_ID_PLACEHOLDER,
90+
},
91+
},
92+
{
93+
position: 5,
94+
appKey: 'toolbox',
95+
eventKey: 'ifThen',
96+
parameters: {
97+
depth: 0,
98+
branchName: 'Officer has signed up for the mailing list',
99+
conditions: [
100+
{
101+
is: 'not',
102+
text: '0',
103+
field: CREATE_TEMPLATE_STEP_VARIABLE('rowsFound', 2),
104+
condition: 'equals',
105+
},
106+
],
107+
},
108+
},
109+
{
110+
position: 6,
49111
appKey: 'tiles',
50112
eventKey: 'updateSingleRow',
51113
parameters: {
52114
rowId: CREATE_TEMPLATE_STEP_VARIABLE('rowId', 2),
53115
rowData: [
116+
{
117+
columnId: TILE_COL_DATA_PLACEHOLDER('Name'),
118+
cellValue: CREATE_TEMPLATE_STEP_VARIABLE(
119+
'Replace with name response',
120+
),
121+
},
54122
{
55123
columnId: TILE_COL_DATA_PLACEHOLDER('Mobile number'),
56124
cellValue: CREATE_TEMPLATE_STEP_VARIABLE(
57-
'Replace with new mobile number from step 1',
125+
'Replace with mobile number response',
58126
),
59127
},
60128
],
@@ -64,28 +132,28 @@ export const UPDATE_MAILING_LISTS_TEMPLATE: ITemplate = {
64132
],
65133
tileTemplateData: {
66134
name: 'Mailing list',
67-
columns: ['Name', 'Email', 'Mobile number'],
135+
columns: ['Email', 'Name', 'Mobile number'],
68136
rowData: [
69137
{
70-
Name: 'Anna Lee',
71138
139+
Name: 'Anna Lee',
72140
'Mobile number': '+6598625072',
73141
},
74142
{
75-
Name: 'Susan Tan Jia Ling',
76143
144+
Name: 'Susan Tan Jia Ling',
77145
},
78146
{
79-
Name: 'Jane Lim',
80147
148+
Name: 'Jane Lim',
81149
},
82150
{
83-
Name: 'Amy Low',
84151
152+
Name: 'Amy Low',
85153
},
86154
{
87-
Name: 'Judy Ng',
88155
156+
Name: 'Judy Ng',
89157
},
90158
],
91159
},
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import type { IApp, ITemplateStep } from '@plumber/types'
2+
3+
import { Fragment } from 'react'
4+
import { Flex, Text } from '@chakra-ui/react'
5+
6+
import { BetweenStepsGraphic } from './TemplateBody'
7+
import TemplateStepContent from './TemplateStepContent'
8+
9+
interface IfThenBranchContentProps {
10+
branchSteps: ITemplateStep[]
11+
apps: IApp[]
12+
}
13+
14+
export default function IfThenBranchContent(props: IfThenBranchContentProps) {
15+
const { branchSteps, apps } = props
16+
return (
17+
<Flex
18+
key={branchSteps[0].position}
19+
flexDir="column"
20+
w="100%"
21+
p={4}
22+
borderRadius="lg"
23+
bg="#f8f9f9"
24+
gap={4}
25+
>
26+
{/* Branch name */}
27+
<Text textStyle="subhead-1" color="base.content.default" noOfLines={1}>
28+
{branchSteps[0].parameters?.branchName as string}
29+
</Text>
30+
31+
<Flex flexDir="column" w="100%" px={4} alignItems="center">
32+
{branchSteps.map((templateStep, index) => {
33+
return (
34+
<Fragment key={index}>
35+
<TemplateStepContent
36+
app={apps?.find((app: IApp) => templateStep.appKey === app.key)}
37+
templateStep={templateStep}
38+
isNested={true}
39+
/>
40+
{/* Don't show if it is the last step */}
41+
{index < branchSteps.length - 1 && <BetweenStepsGraphic />}
42+
</Fragment>
43+
)
44+
})}
45+
</Flex>
46+
</Flex>
47+
)
48+
}

0 commit comments

Comments
 (0)