/
routeConfiguration.js
375 lines (359 loc) · 13.5 KB
/
routeConfiguration.js
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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
import React from 'react';
import loadable from '@loadable/component';
import getPageDataLoadingAPI from '../containers/pageDataLoadingAPI';
import NotFoundPage from '../containers/NotFoundPage/NotFoundPage';
import PreviewResolverPage from '../containers/PreviewResolverPage/PreviewResolverPage';
// routeConfiguration needs to initialize containers first
// Otherwise, components will import form container eventually and
// at that point css bundling / imports will happen in wrong order.
import { NamedRedirect } from '../components';
const pageDataLoadingAPI = getPageDataLoadingAPI();
const AuthenticationPage = loadable(() => import(/* webpackChunkName: "AuthenticationPage" */ '../containers/AuthenticationPage/AuthenticationPage'));
const CheckoutPage = loadable(() => import(/* webpackChunkName: "CheckoutPage" */ '../containers/CheckoutPage/CheckoutPage'));
const CMSPage = loadable(() => import(/* webpackChunkName: "CMSPage" */ '../containers/CMSPage/CMSPage'));
const ContactDetailsPage = loadable(() => import(/* webpackChunkName: "ContactDetailsPage" */ '../containers/ContactDetailsPage/ContactDetailsPage'));
const EditListingPage = loadable(() => import(/* webpackChunkName: "EditListingPage" */ '../containers/EditListingPage/EditListingPage'));
const EmailVerificationPage = loadable(() => import(/* webpackChunkName: "EmailVerificationPage" */ '../containers/EmailVerificationPage/EmailVerificationPage'));
const InboxPage = loadable(() => import(/* webpackChunkName: "InboxPage" */ '../containers/InboxPage/InboxPage'));
const LandingPage = loadable(() => import(/* webpackChunkName: "LandingPage" */ '../containers/LandingPage/LandingPage'));
const ListingPageCoverPhoto = loadable(() => import(/* webpackChunkName: "ListingPageCoverPhoto" */ /* webpackPrefetch: true */ '../containers/ListingPage/ListingPageCoverPhoto'));
const ListingPageCarousel = loadable(() => import(/* webpackChunkName: "ListingPageCarousel" */ /* webpackPrefetch: true */ '../containers/ListingPage/ListingPageCarousel'));
const ManageListingsPage = loadable(() => import(/* webpackChunkName: "ManageListingsPage" */ '../containers/ManageListingsPage/ManageListingsPage'));
const PasswordChangePage = loadable(() => import(/* webpackChunkName: "PasswordChangePage" */ '../containers/PasswordChangePage/PasswordChangePage'));
const PasswordRecoveryPage = loadable(() => import(/* webpackChunkName: "PasswordRecoveryPage" */ '../containers/PasswordRecoveryPage/PasswordRecoveryPage'));
const PasswordResetPage = loadable(() => import(/* webpackChunkName: "PasswordResetPage" */ '../containers/PasswordResetPage/PasswordResetPage'));
const PaymentMethodsPage = loadable(() => import(/* webpackChunkName: "PaymentMethodsPage" */ '../containers/PaymentMethodsPage/PaymentMethodsPage'));
const PrivacyPolicyPage = loadable(() => import(/* webpackChunkName: "PrivacyPolicyPage" */ '../containers/PrivacyPolicyPage/PrivacyPolicyPage'));
const ProfilePage = loadable(() => import(/* webpackChunkName: "ProfilePage" */ '../containers/ProfilePage/ProfilePage'));
const ProfileSettingsPage = loadable(() => import(/* webpackChunkName: "ProfileSettingsPage" */ '../containers/ProfileSettingsPage/ProfileSettingsPage'));
const SearchPageWithMap = loadable(() => import(/* webpackChunkName: "SearchPageWithMap" */ /* webpackPrefetch: true */ '../containers/SearchPage/SearchPageWithMap'));
const SearchPageWithGrid = loadable(() => import(/* webpackChunkName: "SearchPageWithGrid" */ /* webpackPrefetch: true */ '../containers/SearchPage/SearchPageWithGrid'));
const StripePayoutPage = loadable(() => import(/* webpackChunkName: "StripePayoutPage" */ '../containers/StripePayoutPage/StripePayoutPage'));
const TermsOfServicePage = loadable(() => import(/* webpackChunkName: "TermsOfServicePage" */ '../containers/TermsOfServicePage/TermsOfServicePage'));
const TransactionPage = loadable(() => import(/* webpackChunkName: "TransactionPage" */ '../containers/TransactionPage/TransactionPage'));
// Styleguide helps you to review current components and develop new ones
const StyleguidePage = loadable(() => import(/* webpackChunkName: "StyleguidePage" */ '../containers/StyleguidePage/StyleguidePage'));
export const ACCOUNT_SETTINGS_PAGES = [
'ContactDetailsPage',
'PasswordChangePage',
'StripePayoutPage',
'PaymentMethodsPage',
];
// https://en.wikipedia.org/wiki/Universally_unique_identifier#Nil_UUID
const draftId = '00000000-0000-0000-0000-000000000000';
const draftSlug = 'draft';
const RedirectToLandingPage = () => <NamedRedirect name="LandingPage" />;
// NOTE: Most server-side endpoints are prefixed with /api. Requests to those
// endpoints are indended to be handled in the server instead of the browser and
// they will not render the application. So remember to avoid routes starting
// with /api and if you encounter clashing routes see server/index.js if there's
// a conflicting route defined there.
// Our routes are exact by default.
// See behaviour from Routes.js where Route is created.
const routeConfiguration = (layoutConfig) => {
const SearchPage = layoutConfig.searchPage?.variantType === 'map'
? SearchPageWithMap
: SearchPageWithGrid;
const ListingPage = layoutConfig.listingPage?.variantType === 'carousel'
? ListingPageCarousel
: ListingPageCoverPhoto;
return [
{
path: '/',
name: 'LandingPage',
component: LandingPage,
loadData: pageDataLoadingAPI.LandingPage.loadData,
},
{
path: '/p/:pageId',
name: 'CMSPage',
component: CMSPage,
loadData: pageDataLoadingAPI.CMSPage.loadData,
},
{
path: '/s',
name: 'SearchPage',
component: SearchPage,
loadData: pageDataLoadingAPI.SearchPage.loadData,
},
{
path: '/l',
name: 'ListingBasePage',
component: RedirectToLandingPage,
},
{
path: '/l/:slug/:id',
name: 'ListingPage',
component: ListingPage,
loadData: pageDataLoadingAPI.ListingPage.loadData,
},
{
path: '/l/:slug/:id/checkout',
name: 'CheckoutPage',
auth: true,
component: CheckoutPage,
setInitialValues: pageDataLoadingAPI.CheckoutPage.setInitialValues,
},
{
path: '/l/:slug/:id/:variant',
name: 'ListingPageVariant',
auth: true,
authPage: 'LoginPage',
component: ListingPage,
loadData: pageDataLoadingAPI.ListingPage.loadData,
},
{
path: '/l/new',
name: 'NewListingPage',
auth: true,
component: () => (
<NamedRedirect
name="EditListingPage"
params={{ slug: draftSlug, id: draftId, type: 'new', tab: 'details' }}
/>
),
},
{
path: '/l/:slug/:id/:type/:tab',
name: 'EditListingPage',
auth: true,
component: EditListingPage,
loadData: pageDataLoadingAPI.EditListingPage.loadData,
},
{
path: '/l/:slug/:id/:type/:tab/:returnURLType',
name: 'EditListingStripeOnboardingPage',
auth: true,
component: EditListingPage,
loadData: pageDataLoadingAPI.EditListingPage.loadData,
},
// Canonical path should be after the `/l/new` path since they
// conflict and `new` is not a valid listing UUID.
{
path: '/l/:id',
name: 'ListingPageCanonical',
component: ListingPage,
loadData: pageDataLoadingAPI.ListingPage.loadData,
},
{
path: '/u',
name: 'ProfileBasePage',
component: RedirectToLandingPage,
},
{
path: '/u/:id',
name: 'ProfilePage',
component: ProfilePage,
loadData: pageDataLoadingAPI.ProfilePage.loadData,
},
{
path: '/profile-settings',
name: 'ProfileSettingsPage',
auth: true,
authPage: 'LoginPage',
component: ProfileSettingsPage,
},
// Note: authenticating with IdP (e.g. Facebook) expects that /login path exists
// so that in the error case users can be redirected back to the LoginPage
// In case you change this, remember to update the route in server/api/auth/loginWithIdp.js
{
path: '/login',
name: 'LoginPage',
component: AuthenticationPage,
extraProps: { tab: 'login' },
},
{
path: '/signup',
name: 'SignupPage',
component: AuthenticationPage,
extraProps: { tab: 'signup' },
loadData: pageDataLoadingAPI.AuthenticationPage.loadData,
},
{
path: '/confirm',
name: 'ConfirmPage',
component: AuthenticationPage,
extraProps: { tab: 'confirm' },
loadData: pageDataLoadingAPI.AuthenticationPage.loadData,
},
{
path: '/recover-password',
name: 'PasswordRecoveryPage',
component: PasswordRecoveryPage,
},
{
path: '/inbox',
name: 'InboxBasePage',
auth: true,
authPage: 'LoginPage',
component: () => <NamedRedirect name="InboxPage" params={{ tab: 'sales' }} />,
},
{
path: '/inbox/:tab',
name: 'InboxPage',
auth: true,
authPage: 'LoginPage',
component: InboxPage,
loadData: pageDataLoadingAPI.InboxPage.loadData,
},
{
path: '/order/:id',
name: 'OrderDetailsPage',
auth: true,
authPage: 'LoginPage',
component: TransactionPage,
extraProps: { transactionRole: 'customer' },
loadData: (params, ...rest) =>
pageDataLoadingAPI.TransactionPage.loadData({ ...params, transactionRole: 'customer' }, ...rest),
setInitialValues: pageDataLoadingAPI.TransactionPage.setInitialValues,
},
{
path: '/order/:id/details',
name: 'OrderDetailsPageRedirect',
auth: true,
authPage: 'LoginPage',
component: props => <NamedRedirect name="OrderDetailsPage" params={{ id: props.params?.id }} />,
},
{
path: '/sale/:id',
name: 'SaleDetailsPage',
auth: true,
authPage: 'LoginPage',
component: TransactionPage,
extraProps: { transactionRole: 'provider' },
loadData: pageDataLoadingAPI.TransactionPage.loadData,
},
{
path: '/sale/:id/details',
name: 'SaleDetailsPageRedirect',
auth: true,
authPage: 'LoginPage',
component: props => <NamedRedirect name="SaleDetailsPage" params={{ id: props.params?.id }} />,
},
{
path: '/listings',
name: 'ManageListingsPage',
auth: true,
authPage: 'LoginPage',
component: ManageListingsPage,
loadData: pageDataLoadingAPI.ManageListingsPage.loadData,
},
{
path: '/account',
name: 'AccountSettingsPage',
auth: true,
authPage: 'LoginPage',
component: () => <NamedRedirect name="ContactDetailsPage" />,
},
{
path: '/account/contact-details',
name: 'ContactDetailsPage',
auth: true,
authPage: 'LoginPage',
component: ContactDetailsPage,
loadData: pageDataLoadingAPI.ContactDetailsPage.loadData,
},
{
path: '/account/change-password',
name: 'PasswordChangePage',
auth: true,
authPage: 'LoginPage',
component: PasswordChangePage,
},
{
path: '/account/payments',
name: 'StripePayoutPage',
auth: true,
authPage: 'LoginPage',
component: StripePayoutPage,
loadData: pageDataLoadingAPI.StripePayoutPage.loadData,
},
{
path: '/account/payments/:returnURLType',
name: 'StripePayoutOnboardingPage',
auth: true,
authPage: 'LoginPage',
component: StripePayoutPage,
loadData: pageDataLoadingAPI.StripePayoutPage.loadData,
},
{
path: '/account/payment-methods',
name: 'PaymentMethodsPage',
auth: true,
authPage: 'LoginPage',
component: PaymentMethodsPage,
loadData: pageDataLoadingAPI.PaymentMethodsPage.loadData,
},
{
path: '/terms-of-service',
name: 'TermsOfServicePage',
component: TermsOfServicePage,
loadData: pageDataLoadingAPI.TermsOfServicePage.loadData,
},
{
path: '/privacy-policy',
name: 'PrivacyPolicyPage',
component: PrivacyPolicyPage,
loadData: pageDataLoadingAPI.PrivacyPolicyPage.loadData,
},
{
path: '/styleguide',
name: 'Styleguide',
component: StyleguidePage,
},
{
path: '/styleguide/g/:group',
name: 'StyleguideGroup',
component: StyleguidePage,
},
{
path: '/styleguide/c/:component',
name: 'StyleguideComponent',
component: StyleguidePage,
},
{
path: '/styleguide/c/:component/:example',
name: 'StyleguideComponentExample',
component: StyleguidePage,
},
{
path: '/styleguide/c/:component/:example/raw',
name: 'StyleguideComponentExampleRaw',
component: StyleguidePage,
extraProps: { raw: true },
},
{
path: '/notfound',
name: 'NotFoundPage',
component: props => <NotFoundPage {...props} />,
},
// Do not change this path!
//
// The API expects that the application implements /reset-password endpoint
{
path: '/reset-password',
name: 'PasswordResetPage',
component: PasswordResetPage ,
},
// Do not change this path!
//
// The API expects that the application implements /verify-email endpoint
{
path: '/verify-email',
name: 'EmailVerificationPage',
auth: true,
authPage: 'LoginPage',
component: EmailVerificationPage,
loadData: pageDataLoadingAPI.EmailVerificationPage.loadData,
},
// Do not change this path!
//
// The API expects that the application implements /preview endpoint
{
path: '/preview',
name: 'PreviewResolverPage',
component: PreviewResolverPage ,
},
];
};
export default routeConfiguration;