Skip to content

Commit 55d3ca7

Browse files
committed
finish onboarding logic
1 parent b1afdc6 commit 55d3ca7

File tree

5 files changed

+34
-26
lines changed

5 files changed

+34
-26
lines changed

client/src/components/MainLayout/MainLayout.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react'
22
import { View } from 'react-native'
33
import styled from 'styled-components'
4-
import { useMeQuery } from '../../generated/graphql'
4+
// import { useMeQuery } from '../../generated/graphql'
55
import Sidebar from './Sidebar'
66
import MenuIcon from './MenuIcon'
77

@@ -33,9 +33,10 @@ interface MainLayoutProps {
3333
export const SidebarContext = React.createContext({ sidebarOpen: false })
3434

3535
const MainLayout = ({ children }: MainLayoutProps) => {
36-
const { data } = useMeQuery()
36+
// const { data } = useMeQuery()
3737

38-
const [sidebarOpen, setSidebarOpen] = React.useState(!!(data && data.me && data.me.isOnboarded))
38+
// const [sidebarOpen, setSidebarOpen] = React.useState(!!(data && data.me && data.me.isOnboarded))
39+
const [sidebarOpen, setSidebarOpen] = React.useState(true)
3940

4041
return (
4142
<SidebarContext.Provider value={{ sidebarOpen }}>

client/src/screens/Home/Home.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ const Title = styled(Text)`
4444
`
4545

4646
const Home = () => {
47-
const { data, loading } = useMeQuery()
47+
const { data, loading, refetch } = useMeQuery()
4848
const { sidebarOpen } = React.useContext(SidebarContext)
4949
const firstName = data && data.me && data.me.profile.firstName
5050
const isOnboarded = data && data.me && data.me.isOnboarded
5151
return (
5252
<Wrapper sidebarOpen={sidebarOpen && width > 930}>
5353
{loading ? null : (
54-
<View style={{ width: '75%', height: '85%', overflow: 'hidden' }}>
54+
<View style={{ position: 'relative', width: '75%', height: '85%' }}>
5555
<Title>{`Hello, ${firstName}!`}</Title>
56-
{isOnboarded ? <Dashboard /> : <Onboard />}
56+
{isOnboarded ? <Dashboard /> : <Onboard done={refetch} />}
5757
</View>
5858
)}
5959
</Wrapper>

client/src/screens/Home/components/Onboard.tsx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,41 +39,38 @@ const DotRow = styled(View)`
3939
margin-bottom: 20px;
4040
`
4141

42-
const Onboard = () => {
42+
const Onboard = (props: { done: () => void }) => {
4343
const onboardUser = useOnboardUserMutation()
4444
const [selectedItem, setSelectedItem] = React.useState<MapsPrediction | null>(null)
4545
const [publicToken, setPublicToken] = React.useState<string>('')
4646
const [rent, setRent] = React.useState()
4747
const [page, setPage] = React.useState(0)
4848
const isNextDisabled = [!selectedItem || !selectedItem.place_id, !rent, !publicToken]
4949

50-
const onPressNext = async () => {
51-
if (page === 2) {
52-
await onboardUser({
53-
variables: {
54-
publicToken,
55-
property: {
56-
address: selectedItem!.description,
57-
placeId: selectedItem!.place_id,
58-
rentAmount: parseInt(rent),
59-
},
50+
const onPressDone = async (publicToken: string) => {
51+
await setPublicToken(publicToken)
52+
await onboardUser({
53+
variables: {
54+
publicToken,
55+
property: {
56+
address: selectedItem!.description,
57+
placeId: selectedItem!.place_id,
58+
rentAmount: parseInt(rent),
6059
},
61-
})
62-
console.log('DONE!!!')
63-
} else {
64-
setPage(page + 1)
65-
}
60+
},
61+
})
62+
props.done()
6663
}
6764

6865
return (
6966
<Box style={{ height: '75%' }}>
7067
<BoxInner>
7168
<OnboardPages
7269
rent={rent}
70+
page={page}
7371
setRent={setRent}
7472
setSelectedItem={setSelectedItem}
75-
setPublicToken={setPublicToken}
76-
page={page}
73+
setPublicToken={onPressDone}
7774
/>
7875
<View
7976
style={{ position: 'relative', marginBottom: 40, marginTop: 52, alignItems: 'center' }}
@@ -83,7 +80,10 @@ const Onboard = () => {
8380
<Dot active={i === page} />
8481
))}
8582
</DotRow>
86-
<Button onPress={onPressNext} disabled={isNextDisabled[page]}>
83+
<Button
84+
onPress={page !== 2 ? () => setPage(page + 1) : () => {}}
85+
disabled={isNextDisabled[page]}
86+
>
8787
{page === 2 ? 'Done' : 'Next'}
8888
</Button>
8989
</View>

server/config/local.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,11 @@
22
"PORT": 4000,
33
"DB_NAME": "oneFraction",
44
"MONGO_HOST": "",
5-
"ACCOUNTS_SECRET": "979083ce-a9b6-483d-a899-ea22d5b0a1dd"
5+
"ACCOUNTS_SECRET": "979083ce-a9b6-483d-a899-ea22d5b0a1dd",
6+
"PLAID_CLIENT_ID": "5cf92b434c3aa500121bfad9",
7+
"PLAID_SECRET": "7bec015f38a285e9d48d8fd16ba79b",
8+
"PLAID_PUBLIC_KEY": "3bc02bb8840d84f2e9b803add9191e",
9+
"PLAID_PRODUCTS": "transactions",
10+
"PLAID_COUNTRY_CODES": "US",
11+
"PLAID_ENV": "sandbox"
612
}

server/src/modules/user/UserResolver.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export default class UserResolver {
8484
itemId: response.item_id,
8585
}
8686
user.properties = [property]
87+
user.isOnboarded = true
8788
await user.save()
8889

8990
resolve(true)

0 commit comments

Comments
 (0)