Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit edcbd66

Browse files
committed
fix: Merge error and missing dot
1 parent cdca8d1 commit edcbd66

File tree

2 files changed

+71
-30
lines changed

2 files changed

+71
-30
lines changed

pages/admin/app.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class App extends React.Component {
8888
async fetchApp() {
8989
const qs = queryString.parse(document.location.search)
9090
if (qs.id && this.props.jwt) {
91-
const request = await fetch(`${this.propsapiServer}/api/admin/apps/${qs.id}`, {
91+
const request = await fetch(`${this.props.apiServer}/api/admin/apps/${qs.id}`, {
9292
method: 'GET',
9393
headers: new Headers({
9494
Authorization: `Bearer ${this.props.jwt}`,
@@ -151,10 +151,6 @@ class App extends React.Component {
151151
// const app = this.props.selectedApp
152152
// const { name } = this.state;
153153
const app = this.state
154-
<<<<<<< HEAD
155-
const { categories, authentications, storageNetworks, blockchains } = this.props
156-
=======
157-
>>>>>>> origin/develop
158154
if (!app.name) {
159155
return <h1>Loading</h1>
160156
}

pages/maker/index.js

Lines changed: 70 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,131 @@
11
import React, { useEffect } from 'react'
2+
import { useRouter } from 'next/router'
23
import { Flex, Box, Type } from 'blockstack-ui'
34
import { connect } from 'react-redux'
5+
import isNaN from 'lodash/isNaN'
46

57
import { selectMaker, selectAppList, selectCurrentApp, selectCompetionStatus } from '@stores/maker/selectors'
68
import { fetchApps, selectAppAction } from '@stores/maker/actions'
79
import { selectApiServer, selectUser } from '@stores/apps/selectors'
10+
import { MakerContainer, MakerContentBox, MakerStickyStatusBox } from '@components/maker/styled'
811
import { Page } from '@components/page'
912
import Head from '@containers/head'
1013
import Maker from '@components/maker'
11-
import { MakerContainer, MakerContentBox, MakerStickyStatusBox } from '@components/maker/styled'
1214

13-
const MakerPortal = ({ apiServer, user, maker, loading, errorMessage, appList, selectedApp, dispatch }) => {
15+
const MakerPortal = ({ params, apiServer, user, maker, errorMessage, appList, selectedApp, competionStatus, dispatch }) => {
1416

15-
const MakerPortal = ({ query, params, apiServer, user, maker, errorMessage, appList, selectedApp, competionStatus, dispatch }) => {
16-
console.log('Rendering component')
17+
const hasAppId = params && !!params.appId
1718

18-
const app = selectedApp
19+
const router = useRouter()
1920

20-
function handleChangingApp (event) {
21-
event.persist()
22-
const id = event.target.value
23-
dispatch(selectAppAction(id))
21+
console.log(router)
22+
const updateMakerRoute = id => {
23+
router.push(
24+
{
25+
pathname: '/maker',
26+
query: {
27+
params: { appId: id }
28+
},
29+
as: `/maker/${id}`
30+
},
31+
{
32+
shallow: true
33+
}
34+
)
35+
}
36+
37+
const getAppId = () => {
38+
39+
const id = parseInt(params.appId, 10)
40+
if (isNaN(id)) return null
41+
return id
2442
}
2543

26-
if (loading || !app) {
44+
useEffect(() => {
45+
async function fetchAppsOnInit () {
46+
await fetchApps({ apiServer, user })(dispatch)
47+
48+
if (hasAppId) {
49+
dispatch(selectAppAction(getAppId()))
50+
}
51+
}
52+
fetchAppsOnInit()
53+
}, [])
54+
55+
if (maker.loading || !selectedApp) {
2756
return (
2857
<Page innerPadding={0} wrap>
2958
<Flex>
3059
<Box width={1}>
31-
<Type fontSize={5} my={7} textAlign="center">{loading ? 'Loading...' : errorMessage}</Type>
60+
<Type fontSize={5} my={7} textAlign="center">{maker.loading ? 'Loading...' : errorMessage}</Type>
3261
</Box>
3362
</Flex>
3463
</Page>
3564
)
3665
}
3766

67+
// if (!hasAppId) {
68+
// if (appList.length === 0) throw new Error('wlkdsfsldfl')
69+
// const { id } = appList[0]
70+
// console.log('has no app id take first', id)
71+
// updateMakerRoute(id)
72+
// dispatch(selectAppAction(id))
73+
// }
74+
75+
function handleChangingApp (event) {
76+
event.persist()
77+
const id = event.target.value
78+
dispatch(selectAppAction(id))
79+
updateMakerRoute(id)
80+
}
81+
82+
3883
return (
3984
<Page innerPadding={0} wrap>
40-
<Head title={app.name} />
85+
<Head title={selectedApp.name} />
4186
<MakerContainer>
4287
<Box>
43-
<select onChange={handleChangingApp}>
44-
{appList.map(({ name, id }) => (
45-
<option key={id} value={id}>{name}</option>
46-
))}
47-
</select>
88+
{
89+
appList.length &&
90+
<select onChange={handleChangingApp} value={getAppId()}>
91+
{appList.map(({ name, id }) => (
92+
<option key={id} value={id}>{name}</option>
93+
))}
94+
</select>
95+
}
4896
</Box>
4997
<Type fontSize={3} fontWeight={500} mx={[4, 6]} py={6} px={[20, 0]}>
50-
{app.name}
98+
{selectedApp.name}
5199
</Type>
52100
<Flex flexDirection={['column', 'column', 'row-reverse']} maxWidth={[null, null, 1140]} alignItems="flex-start">
53101
<MakerStickyStatusBox>
54102
<Maker.Status
55-
app={app}
103+
app={selectedApp}
56104
apiServer={apiServer}
57105
status={competionStatus}
58106
/>
59107
</MakerStickyStatusBox>
60108
<Box>
61109
<MakerContentBox>
62110
<Maker.PaymentDetails
63-
app={app}
111+
app={selectedApp}
64112
user={user}
65113
apiServer={apiServer}
66114
dispatch={dispatch}
67-
// onPaymentDetailsComplete={() => dispatch(setPaymentDetailsComplete())}
68115
/>
69116
</MakerContentBox>
70117
<MakerContentBox>
71118
<Maker.KYC
72-
app={app}
119+
app={selectedApp}
73120
user={user}
74121
apiServer={apiServer}
75-
// onKycComplete={() => dispatch(setKycComplete())}
76122
/>
77123
</MakerContentBox>
78124
<MakerContentBox>
79125
<Maker.ParticipationAgreement
80-
app={app}
126+
app={selectedApp}
81127
user={user}
82128
apiServer={apiServer}
83-
// onLegalComplete={() => dispatch(setLegalComplete())}
84129
/>
85130
</MakerContentBox>
86131
</Box>

0 commit comments

Comments
 (0)