Skip to content

Commit 3970e36

Browse files
authored
Merge pull request #3047 from StoDevX/expose-dev-bonapp-picker
Include development bonapp menu picker
2 parents d571405 + a7c44fb commit 3970e36

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

source/views/menus/dev-bonapp-picker.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// @flow
22
import * as React from 'react'
33
import {View, TextInput, StyleSheet} from 'react-native'
4+
import {NoticeView} from '@frogpond/notice'
45
import {TabBarIcon} from '@frogpond/navigation-tabs'
56
import * as c from '@frogpond/colors'
6-
import {Toolbar, ToolbarButton} from '@frogpond/toolbar'
7+
import {Toolbar} from '@frogpond/toolbar'
78
import type {TopLevelViewPropsType} from '../types'
89
import {BonAppHostedMenu} from './menu-bonapp'
910

@@ -26,7 +27,6 @@ type Props = TopLevelViewPropsType
2627

2728
type State = {
2829
cafeId: string,
29-
menu: ?any,
3030
}
3131

3232
export class BonAppPickerView extends React.PureComponent<Props, State> {
@@ -36,8 +36,7 @@ export class BonAppPickerView extends React.PureComponent<Props, State> {
3636
}
3737

3838
state = {
39-
cafeId: '34',
40-
menu: null,
39+
cafeId: '',
4140
}
4241

4342
chooseCafe = (cafeId: string) => {
@@ -53,20 +52,23 @@ export class BonAppPickerView extends React.PureComponent<Props, State> {
5352
<Toolbar onPress={() => {}}>
5453
<TextInput
5554
keyboardType="numeric"
56-
onBlur={this.chooseCafe}
57-
onChangeText={this.chooseCafe}
55+
onEndEditing={e => this.chooseCafe(e.nativeEvent.text)}
56+
placeholder="id"
57+
returnKeyType="done"
5858
style={styles.default}
59-
value={this.state.cafeId}
6059
/>
61-
<ToolbarButton isActive={true} title="Go" />
6260
</Toolbar>
63-
<BonAppHostedMenu
64-
key={this.state.cafeId}
65-
cafe={{id: this.state.cafeId}}
66-
loadingMessage={['Loading…']}
67-
name="BonApp"
68-
navigation={this.props.navigation}
69-
/>
61+
{this.state.cafeId ? (
62+
<BonAppHostedMenu
63+
key={this.state.cafeId}
64+
cafe={{id: this.state.cafeId}}
65+
loadingMessage={['Loading…']}
66+
name="BonApp"
67+
navigation={this.props.navigation}
68+
/>
69+
) : (
70+
<NoticeView text="Please enter a Cafe ID." />
71+
)}
7072
</View>
7173
)
7274
}

source/views/menus/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
import * as React from 'react'
44
import {TabNavigator, TabBarIcon} from '@frogpond/navigation-tabs'
5+
import {IS_PRODUCTION} from '@frogpond/constants'
56

67
import {BonAppHostedMenu} from './menu-bonapp'
78
import {GitHubHostedMenu} from './menu-github'
89
import {CarletonCafeIndex} from './carleton-menus'
9-
// import {BonAppPickerView} from './dev-bonapp-picker'
10+
import {BonAppPickerView} from './dev-bonapp-picker'
1011

1112
export {
1213
CarletonBurtonMenuScreen,
@@ -88,7 +89,7 @@ export const MenusView = TabNavigator({
8889
},
8990
},
9091

91-
// BonAppDevToolView: {screen: BonAppPickerView},
92+
...(!IS_PRODUCTION ? {BonAppDevToolView: {screen: BonAppPickerView}} : {}),
9293
})
9394
MenusView.navigationOptions = {
9495
title: 'Menus',

source/views/menus/menu-bonapp.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@ export class BonAppHostedMenu extends React.PureComponent<Props, State> {
262262
return <NoticeView text={msg} />
263263
}
264264

265+
if (Object.keys(this.state.cafeMenu.items).length === 0) {
266+
const msg = 'No items were found.'
267+
return <NoticeView text={msg} />
268+
}
269+
265270
const {ignoreProvidedMenus = false} = this.props
266271
const {now, cafeMenu, cafeInfo} = this.state
267272

0 commit comments

Comments
 (0)