Skip to content

Commit

Permalink
Request opt-in form
Browse files Browse the repository at this point in the history
  • Loading branch information
ericnewcomer committed Sep 26, 2023
1 parent 60328f7 commit ab7991b
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 5 deletions.
19 changes: 19 additions & 0 deletions lambda/optins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export const optins = {
next: null,
previous: null,
results: [
{
uuid: '8fc583a0-0700-434d-b238-8053af1d040e',
name: 'Newsletter',
created_on: '2023-09-25T04:43:19.103443Z'
},
{
uuid: '806f52e7-ad6a-4ede-8793-6f51b60a30ec',
name: 'U-Report Polls',
created_on: '2023-09-23T00:18:41.572795Z'
}
]
};
const { getOpts } = require('./utils');

exports.handler = (evt, ctx, cb) => cb(null, getOpts({ body: JSON.stringify(optins) }));
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@
groups: base + 'groups',
fields: base + 'fields',
labels: base + 'labels',
optins: base + 'optins',
channels: base + 'channels',
classifiers: base + 'classifiers',
ticketers: base + 'ticketers',
Expand Down
1 change: 1 addition & 0 deletions src/components/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Array [
"groups": "/assets/groups.json",
"labels": "/assets/labels.json",
"languages": "/assets/languages.json",
"optins": "/assets/optins.json",
"recents": "/assets/recents.json",
"recipients": "/assets/recipients.json",
"resthooks": "/assets/resthooks.json",
Expand Down
5 changes: 4 additions & 1 deletion src/components/flow/actions/action/Action.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
border-radius: 0px;
}
}

clear: both;
}

Expand Down Expand Up @@ -47,6 +48,7 @@
&.transfer_airtime,
&.open_ticket,
&.missing,
&.request_optin,
&.enter_flow {
width: $node_min_width - $action_padding * 2;
padding: $action_padding;
Expand All @@ -73,6 +75,7 @@
.overlay {
display: block;
}

.body {
background: #fff !important;
}
Expand Down Expand Up @@ -126,4 +129,4 @@
background: rgba(255, 255, 255, 0.9);
$color_1: rgba(0, 0, 0, 0.12);
$color_2: rgba(0, 0, 0, 0.1);
}
}
6 changes: 2 additions & 4 deletions src/components/flow/actions/requestoptin/RequestOptInForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@ export default class AddLabelsForm extends React.PureComponent<
}

public handleOptInCreated(optin: Asset): void {
// update our store with our new group
this.props.addAsset('optins', optin);

this.handleOptInChanged(this.state.optin.value);
console.log(optin);
this.handleOptInChanged([optin]);
}

public render(): JSX.Element {
Expand Down
16 changes: 16 additions & 0 deletions src/config/__snapshots__/typeConfigs.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,14 @@ Array [
"name": "Split by URN Type",
"type": "split_by_scheme",
},
Object {
"component": [Function],
"description": "Send an Opt-In request",
"filter": "optins",
"form": [Function],
"name": "Request Opt-In",
"type": "request_optin",
},
]
`;

Expand Down Expand Up @@ -583,6 +591,14 @@ Object {
"name": "Remove from Group",
"type": "remove_contact_groups",
},
"request_optin": Object {
"component": [Function],
"description": "Send an Opt-In request",
"filter": "optins",
"form": [Function],
"name": "Request Opt-In",
"type": "request_optin",
},
"say_msg": Object {
"component": [Function],
"description": "Play a message",
Expand Down
16 changes: 16 additions & 0 deletions src/test/assets/optins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"next": null,
"previous": null,
"results": [
{
"uuid": "8fc583a0-0700-434d-b238-8053af1d040e",
"name": "Newsletter",
"created_on": "2023-09-25T04:43:19.103443Z"
},
{
"uuid": "806f52e7-ad6a-4ede-8793-6f51b60a30ec",
"name": "U-Report Polls",
"created_on": "2023-09-23T00:18:41.572795Z"
}
]
}
1 change: 1 addition & 0 deletions src/test/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const config: FlowEditorConfig = {
brand: 'RapidPro',
endpoints: {
resthooks: '/assets/resthooks.json',
optins: '/assets/optins.json',
flows: '/assets/flows.json',
globals: '/assets/globals.json',
groups: '/assets/groups.json',
Expand Down

0 comments on commit ab7991b

Please sign in to comment.