Skip to content

Commit

Permalink
add todos demo pages
Browse files Browse the repository at this point in the history
  • Loading branch information
schuyler1d committed Jan 15, 2021
1 parent 9b7a595 commit 6468a0f
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/components/AssignmentSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ export class AssignmentSummary extends Component {
};

goToTodos(contactsFilter, assignmentId) {
const { organizationId, router } = this.props;

const { organizationId, router, todoLink } = this.props;
if (todoLink) {
return todoLink(contactsFilter, assignmentId, router);
}
if (contactsFilter) {
router.push(
`/app/${organizationId}/todos/${assignmentId}/${contactsFilter}`
Expand Down Expand Up @@ -269,7 +271,8 @@ AssignmentSummary.propTypes = {
router: PropTypes.object,
assignment: PropTypes.object,
texter: PropTypes.object,
refreshData: PropTypes.func
refreshData: PropTypes.func,
todoLink: PropTypes.func
};

export default withRouter(AssignmentSummary);
130 changes: 129 additions & 1 deletion src/components/AssignmentTexter/Demo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -529,19 +529,144 @@ export const tests = testName => {
hasUnassignedContactsForTexter: 200
},
texter: {
id: 123,
firstName: "Carlos",
lastName: "Tlastname"
},
currentUser: {
id: 123,
roles: ["SUSPENDED", "TEXTER", "VETTED_TEXTER"]
}
}
},

// other tests:
// c: current question response is deeper in the state
// d: no questions at all
// e: opted out
todos1: {
organizationId: "fake",
texter: {
id: 123,
profileComplete: true,
terms: true,
roles: ["SUSPENDED", "TEXTER"]
},
assignment: {
id: "fakeassignment",
hasUnassignedContactsForTexter: true,
allContactsCount: 100,
unmessagedCount: 10,
unrepliedCount: 5,
badTimezoneCount: 20,
totalMessagedCount: 5,
pastMessagesCount: 5,
skippedMessagesCount: 5,
campaign: {
id: "fakecampaign",
title: "Fake Campaign",
description: "Will save the world",
batchSize: 100,
useDynamicAssignment: true,
introHtml: null,
primaryColor: null,
texterUIConfig: {
options: JSON.stringify(sideboxOptions),
sideboxChoices
},
organization: {
id: "fake"
}
}
},
refreshData: () => {
console.log("Summary refresh triggered");
},
todoLink: (contactsFilter, aId, router) => {
console.log("todoLink", contactsFilter, aId);
if (contactsFilter === "text") {
router.push("/demo/text");
} else {
router.push("/demo/reply");
}
}
},
todos2: {
organizationId: "fake",
texter: {
id: 123,
profileComplete: true,
terms: true,
roles: ["SUSPENDED", "TEXTER"]
},
assignment: {
id: "fakeassignment",
hasUnassignedContactsForTexter: false,
allContactsCount: 100,
unmessagedCount: 10,
unrepliedCount: 5,
badTimezoneCount: 20,
totalMessagedCount: 5,
pastMessagesCount: 5,
skippedMessagesCount: 5,
campaign: {
id: "fakecampaign",
title: "Fake Campaign",
description: "Will save the world",
batchSize: 100,
useDynamicAssignment: true,
introHtml: null,
primaryColor: null,
texterUIConfig: {
options: JSON.stringify(sideboxOptions),
sideboxChoices
},
organization: {
id: "fake"
}
},
feedback: {
isAcknowledged: false,
createdBy: {
name: "Mx Reviewer"
},
message:
"You did so well! Note this is a demo and issues, skills and messaging are customizable, and this would be a final message written by the reviewer.",
issueCounts: {
optOut: 1,
tagging: 1,
response: 1,
scriptEdit: 1,
engagement: 1
},
skillCounts: {
extraOptOut: 1,
jumpAhead: 1,
multiMessage: 1,
composing: 1
},
sweepComplete: true
}
},
refreshData: () => {
console.log("Summary refresh triggered");
},
todoLink: (contactsFilter, aId, router) => {
console.log("todoLink", contactsFilter, aId);
if (contactsFilter === "text") {
router.push("/demo/text");
} else {
router.push("/demo/reply");
}
}
}
};
return testData[testName];
};

export const assignmentSummaryTestProps = {
summaryA: {}
};

export function generateDemoTexterContact(testName) {
const test = tests(testName);
const DemoAssignmentTexterContact = function(props) {
Expand All @@ -566,6 +691,7 @@ export function generateDemoTexterContact(testName) {
campaign={test.assignment.campaign}
texter={test.texter}
assignment={test.assignment}
currentUser={test.currentUser}
navigationToolbarChildren={test.navigationToolbarChildren}
enabledSideboxes={props.enabledSideboxes}
messageStatusFilter={test.messageStatusFilter}
Expand All @@ -588,6 +714,7 @@ export function generateDemoTexterContact(testName) {
};

const DemoTexterTest = function(props) {
console.log("DemoTexterTest", test);
return (
<ContactController
assignment={test.assignment}
Expand All @@ -603,6 +730,7 @@ export function generateDemoTexterContact(testName) {
organizationId={"1"}
ChildComponent={DemoAssignmentTexterContact}
messageStatusFilter={test.messageStatusFilter}
currentUser={test.currentUser}
/>
);
};
Expand Down
18 changes: 17 additions & 1 deletion src/routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ import {
DemoTexterNeedsMessage,
DemoTexterNeedsResponse,
DemoTexter2ndQuestion,
DemoTexterDynAssign
DemoTexterDynAssign,
tests
} from "./components/AssignmentTexter/Demo";
import AssignmentSummary from "./components/AssignmentSummary";
import AdminPhoneNumberInventory from "./containers/AdminPhoneNumberInventory";

const checkDowntime = (nextState, replace) => {
Expand Down Expand Up @@ -264,6 +266,20 @@ export default function makeRoutes(requireAuth = () => {}) {
topNav: null
}}
/>
<Route
path="todos"
components={{
main: props => <AssignmentSummary {...tests("todos1")} />,
topNav: p => <TopNav title="Spoke Texting Demo" orgId={"fake"} />
}}
/>
<Route
path="todos2"
components={{
main: props => <AssignmentSummary {...tests("todos2")} />,
topNav: p => <TopNav title="Spoke Texting Demo2" orgId={"fake"} />
}}
/>
</Route>
</Route>
);
Expand Down

0 comments on commit 6468a0f

Please sign in to comment.