Skip to content

Commit 9d13586

Browse files
committed
chore: add for-each template
1 parent 0f8b9e5 commit 9d13586

File tree

5 files changed

+124
-5
lines changed

5 files changed

+124
-5
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import type { ITemplate } from '@plumber/types'
2+
3+
import {
4+
CREATE_TEMPLATE_STEP_VARIABLE,
5+
TILE_COL_DATA_PLACEHOLDER,
6+
TILE_ID_PLACEHOLDER,
7+
USER_EMAIL_PLACEHOLDER,
8+
} from './constants'
9+
10+
const FOR_EACH_REMINDER_ID = 'b8dd6c22-3578-460d-89e2-e2062b3601f2'
11+
12+
export const FOR_EACH_REMINDER_TEMPLATE: ITemplate = {
13+
id: FOR_EACH_REMINDER_ID,
14+
name: 'Schedule reminders to a list of emails',
15+
description: 'Schedule a recurring reminder to a group of people',
16+
iconName: 'BiCalendar',
17+
tags: ['new'],
18+
// Steps: scheduler --> tiles --> for-each --> postman --> tiles
19+
steps: [
20+
{
21+
position: 1,
22+
appKey: 'scheduler',
23+
eventKey: 'everyDay',
24+
parameters: { hour: '10', triggersOnWeekend: false },
25+
},
26+
{
27+
position: 2,
28+
appKey: 'tiles',
29+
eventKey: 'findMultipleRows',
30+
parameters: {
31+
tableId: TILE_ID_PLACEHOLDER,
32+
filters: [
33+
{
34+
columnId: TILE_COL_DATA_PLACEHOLDER('RSVPed'),
35+
value: 'Yes',
36+
operator: 'equals',
37+
},
38+
{
39+
columnId: TILE_COL_DATA_PLACEHOLDER('Reminder sent'),
40+
operator: 'empty',
41+
},
42+
],
43+
returnLastRowFirst: true,
44+
},
45+
},
46+
{
47+
position: 3,
48+
appKey: 'toolbox',
49+
eventKey: 'forEach',
50+
parameters: {
51+
items: CREATE_TEMPLATE_STEP_VARIABLE(
52+
'Replace with rows data from step 2',
53+
2,
54+
),
55+
},
56+
},
57+
{
58+
position: 4,
59+
appKey: 'postman',
60+
eventKey: 'sendTransactionalEmail',
61+
parameters: {
62+
body: '<p style="margin: 0">This is a gentle reminder for the upcoming event! </p>',
63+
subject: 'Event reminder',
64+
senderName: 'Event reminder',
65+
destinationEmail: USER_EMAIL_PLACEHOLDER,
66+
},
67+
},
68+
{
69+
position: 5,
70+
appKey: 'tiles',
71+
eventKey: 'updateSingleRow',
72+
parameters: {
73+
tableId: TILE_ID_PLACEHOLDER,
74+
rowId: CREATE_TEMPLATE_STEP_VARIABLE(
75+
'Replace with Row ID from Step 3',
76+
3,
77+
),
78+
rowData: [
79+
{
80+
columnId: TILE_COL_DATA_PLACEHOLDER('Reminder sent'),
81+
cellValue: 'Yes',
82+
},
83+
],
84+
},
85+
},
86+
],
87+
tileTemplateData: {
88+
name: 'Event Sign ups',
89+
columns: ['Name', 'Email', 'Mobile number', 'RSVPed', 'Reminder sent'],
90+
rowData: [
91+
{
92+
Name: 'Anna Lee',
93+
94+
'Mobile number': '+6598625072',
95+
RSVPed: 'Yes',
96+
},
97+
{
98+
Name: 'Susan Tan Jia Ling',
99+
100+
},
101+
{
102+
Name: 'Jane Lim',
103+
104+
RSVPed: 'Yes',
105+
},
106+
{
107+
Name: 'Amy Low',
108+
109+
RSVPed: 'Yes',
110+
},
111+
{
112+
Name: 'Judy Ng',
113+
114+
},
115+
],
116+
},
117+
}

packages/backend/src/db/storage/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { ITemplate } from '@plumber/types'
22

33
import { ATTENDANCE_TAKING_TEMPLATE } from './attendance-taking'
4+
import { FOR_EACH_REMINDER_TEMPLATE } from './for-each-reminder'
45
import { GET_LIVE_UPDATES_THROUGH_TELEGRAM_TEMPLATE } from './get-live-updates-through-telegram'
56
import { ROUTE_SUPPORT_ENQUIRIES_TEMPLATE } from './route-support-enquiries'
6-
import { SCHEDULE_REMINDERS_TEMPLATE } from './schedule-reminders'
77
import { SEND_A_COPY_OF_FORM_RESPONSE_TEMPLATE } from './send-a-copy-of-form-response'
88
import { SEND_FOLLOW_UPS_TEMPLATE } from './send-follow-ups'
99
import { SEND_MESSAGE_TO_A_SLACK_CHANNEL_TEMPLATE } from './send-message-to-a-slack-channel'
@@ -29,7 +29,7 @@ function deepFreeze<T>(object: T): T {
2929
export const TEMPLATES: ITemplate[] = deepFreeze<ITemplate[]>([
3030
SEND_FOLLOW_UPS_TEMPLATE, // contains demo video
3131
SEND_A_COPY_OF_FORM_RESPONSE_TEMPLATE,
32-
SCHEDULE_REMINDERS_TEMPLATE,
32+
FOR_EACH_REMINDER_TEMPLATE,
3333
TRACK_FEEDBACK_TEMPLATE,
3434
ATTENDANCE_TAKING_TEMPLATE,
3535
UPDATE_MAILING_LISTS_TEMPLATE,

packages/backend/src/graphql/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,7 @@ type TemplateStep {
964964
enum TemplateTagType {
965965
demo
966966
empty # for empty flows state
967+
new
967968
}
968969

969970
# End of template types

packages/frontend/src/pages/Templates/components/TemplateTile.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default function TemplateTile({ template }: TemplateTileProps) {
1616
const navigate = useNavigate()
1717

1818
const isDemoTemplate = tags?.some((tag) => tag === 'demo')
19+
const isNewTemplate = tags?.some((tag) => tag === 'new')
1920

2021
return (
2122
<Tile
@@ -25,9 +26,9 @@ export default function TemplateTile({ template }: TemplateTileProps) {
2526
</Box>
2627
)}
2728
badge={
28-
isDemoTemplate ? (
29+
isDemoTemplate || isNewTemplate ? (
2930
<Badge bg="primary.100" color="primary.500">
30-
Demo included
31+
{isDemoTemplate ? 'Demo included' : 'New'}
3132
</Badge>
3233
) : undefined
3334
}

packages/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ export interface ITemplate {
967967
}
968968

969969
// demo template or for empty flows state
970-
export type TemplateTagType = 'demo' | 'empty'
970+
export type TemplateTagType = 'demo' | 'empty' | 'new'
971971

972972
export interface ITemplateStep {
973973
position: number // primary key, no need id for now

0 commit comments

Comments
 (0)