forked from ProgressiveCoders/Spoke
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroutes.jsx
More file actions
334 lines (331 loc) · 11 KB
/
Copy pathroutes.jsx
File metadata and controls
334 lines (331 loc) · 11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
import { IndexRoute, IndexRedirect, Route } from "react-router";
import App from "./components/App";
import AdminDashboard from "./components/AdminDashboard";
import AdminCampaignList from "./containers/AdminCampaignList";
import AdminCampaignStats from "./containers/AdminCampaignStats";
import AdminPersonList from "./containers/AdminPersonList";
import AdminIncomingMessageList from "./containers/AdminIncomingMessageList";
import AdminCampaignEdit from "./containers/AdminCampaignEdit";
import AdminReplySender from "./containers/AdminReplySender";
import AdminCampaignMessagingService from "./containers/AdminCampaignMessagingService";
import AdminBulkScriptEditor from "./containers/AdminBulkScriptEditor";
import TexterDashboard from "./components/TexterDashboard";
import OrganizationWrapper from "./components/OrganizationWrapper";
import TopNav from "./components/TopNav";
import DashboardLoader from "./containers/DashboardLoader";
import TexterTodoList from "./containers/TexterTodoList";
import TexterTodo from "./containers/TexterTodo";
import Login from "./components/Login";
import Terms from "./containers/Terms";
import Downtime from "./components/Downtime";
import React from "react";
import CreateOrganization from "./containers/CreateOrganization";
import CreateAdditionalOrganization from "./containers/CreateAdditionalOrganization";
import AdminOrganizationsDashboard from "./containers/AdminOrganizationsDashboard";
import JoinTeam from "./containers/JoinTeam";
import Home from "./containers/Home";
import Settings from "./containers/Settings";
import Tags from "./containers/Tags";
import UserEdit from "./containers/UserEdit";
import TexterFaqs from "./components/TexterFrequentlyAskedQuestions";
import FAQs from "./lib/faqs";
import {
DemoTexterNeedsMessage,
DemoTexterNeedsResponse,
DemoTexter2ndQuestion,
DemoTexterDynAssign,
tests
} from "./components/AssignmentTexter/Demo";
import AssignmentSummary from "./components/AssignmentSummary";
import AdminPhoneNumberInventory from "./containers/AdminPhoneNumberInventory";
const checkDowntime = (nextState, replace) => {
if (global.DOWNTIME && nextState.location.pathname !== "/downtime") {
replace({
pathname: "/downtime"
});
}
};
const checkTexterDowntime = requireAuth => (nextState, replace) => {
if (global.DOWNTIME_TEXTER && nextState.location.pathname !== "/downtime") {
replace({
pathname: "/downtime"
});
} else {
return requireAuth(nextState, replace);
}
};
export default function makeRoutes(requireAuth = () => {}) {
return (
<Route path="/" component={App} onEnter={checkDowntime}>
<IndexRoute component={Home} />
<Route path="downtime" component={Downtime} />
<Route path="admin" component={AdminDashboard} onEnter={requireAuth}>
<IndexRoute component={() => <DashboardLoader path="/admin" />} />
<Route path=":organizationId" component={OrganizationWrapper}>
<IndexRedirect to="campaigns" />
<Route path="campaigns">
<IndexRoute component={AdminCampaignList} />
<Route path=":campaignId">
<IndexRoute component={AdminCampaignStats} />
<Route path="edit" component={AdminCampaignEdit} />
<Route path="send-replies" component={AdminReplySender} />
<Route
path="messaging-service"
component={AdminCampaignMessagingService}
/>
</Route>
</Route>
<Route path="people" component={AdminPersonList} />
<Route path="incoming" component={AdminIncomingMessageList} />
<Route path="bulk-script-editor" component={AdminBulkScriptEditor} />
<Route path="tags" component={Tags} />
<Route path="settings" component={Settings} />
<Route path="phone-numbers" component={AdminPhoneNumberInventory} />
</Route>
</Route>
<Route path="app" onEnter={checkTexterDowntime(requireAuth)}>
<IndexRoute
component={props => {
return (
<TexterDashboard
main={<DashboardLoader path="/app" />}
topNav={
<TopNav
title="Spoke Texting"
orgId={props.params.organizationId}
/>
}
/>
);
}}
/>
<Route path=":organizationId" component={OrganizationWrapper}>
<IndexRedirect to="todos" />
<Route
path="faqs"
component={props => {
return (
<TexterDashboard
main={<TexterFaqs faqs={FAQs} />}
topNav={
<TopNav
title="Account"
orgId={props.params.organizationId}
/>
}
/>
);
}}
/>
<Route
path="account/:userId"
component={props => {
return (
<TexterDashboard
main={
<UserEdit
userId={props.params.userId}
organizationId={props.params.organizationId}
/>
}
topNav={
<TopNav
title="Account"
orgId={props.params.organizationId}
/>
}
/>
);
}}
/>
<Route path="todos">
<IndexRoute
component={props => {
return (
<TexterDashboard
main={<TexterTodoList {...props} />}
topNav={
<TopNav
title="Spoke Texting"
orgId={props.params.organizationId}
/>
}
/>
);
}}
/>
<Route
path="other/:userId"
component={props => {
return (
<TexterDashboard
main={<TexterTodoList {...props} />}
topNav={
<TopNav
title="Spoke Texting"
orgId={props.params.organizationId}
/>
}
/>
);
}}
/>
<Route
path="review/:reviewContactId"
component={props => {
return (
<TexterDashboard fullScreen={<TexterTodo {...props} />} />
);
}}
/>
<Route path=":assignmentId">
<Route
path="text"
component={props => {
return (
<TexterDashboard
fullScreen={
<TexterTodo {...props} messageStatus="needsMessage" />
}
/>
);
}}
/>
<Route
path="reply"
component={props => {
return (
<TexterDashboard
fullScreen={
<TexterTodo {...props} messageStatus="needsResponse" />
}
/>
);
}}
/>
<Route
path="stale"
component={props => {
return (
<TexterDashboard
fullScreen={
<TexterTodo {...props} messageStatus="convo" />
}
/>
);
}}
/>
<Route
path="skipped"
component={props => {
return (
<TexterDashboard
fullScreen={
<TexterTodo {...props} messageStatus="closed" />
}
/>
);
}}
/>
<Route
path="allreplies"
component={props => {
return (
<TexterDashboard
fullScreen={
<TexterTodo {...props} messageStatus="allReplies" />
}
/>
);
}}
/>
<Route
path="all"
component={props => {
return (
<TexterDashboard
fullScreen={
<TexterTodo
{...props}
messageStatus="needsMessageOrResponse"
/>
}
/>
);
}}
/>
</Route>
</Route>
</Route>
</Route>
<Route path="login" component={Login} />
<Route path="organizations" component={AdminOrganizationsDashboard} />
<Route path="terms" component={Terms} />
<Route path="reset/:resetHash" component={Home} onEnter={requireAuth} />
<Route
path="invite/:inviteId"
component={CreateOrganization}
onEnter={requireAuth}
/>
<Route
path="addOrganization/:inviteId"
component={CreateAdditionalOrganization}
onEnter={requireAuth}
/>
<Route
path=":organizationUuid/join/:campaignId"
component={JoinTeam}
onEnter={requireAuth}
/>
<Route
path=":organizationUuid/join"
component={JoinTeam}
onEnter={requireAuth}
/>
<Route path="demo" component={TexterDashboard}>
<Route
path="text"
components={{
main: props => <DemoTexterNeedsMessage {...props} />,
topNav: null
}}
/>
<Route
path="reply"
components={{
main: props => <DemoTexterNeedsResponse {...props} />,
topNav: null
}}
/>
<Route
path="reply2"
components={{
main: props => <DemoTexter2ndQuestion {...props} />,
topNav: null
}}
/>
<Route
path="dyn"
components={{
main: props => <DemoTexterDynAssign {...props} />,
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>
);
}