Browse Source

Update proxiwash screens to use TypeScript

Arnaud Vergnet 3 years ago
parent
commit
9f4dcda7d9

+ 1
- 0
src/components/Screens/WebSectionList.tsx View File

38
 
38
 
39
 export type SectionListDataType<ItemT> = Array<{
39
 export type SectionListDataType<ItemT> = Array<{
40
   title: string;
40
   title: string;
41
+  icon?: string;
41
   data: Array<ItemT>;
42
   data: Array<ItemT>;
42
   keyExtractor?: (data: ItemT) => string;
43
   keyExtractor?: (data: ItemT) => string;
43
 }>;
44
 }>;

+ 10
- 9
src/constants/ProxiwashConstants.ts View File

17
  * along with Campus INSAT.  If not, see <https://www.gnu.org/licenses/>.
17
  * along with Campus INSAT.  If not, see <https://www.gnu.org/licenses/>.
18
  */
18
  */
19
 
19
 
20
+export enum MachineStates {
21
+  AVAILABLE,
22
+  RUNNING,
23
+  RUNNING_NOT_STARTED,
24
+  FINISHED,
25
+  UNAVAILABLE,
26
+  ERROR,
27
+  UNKNOWN,
28
+}
29
+
20
 export default {
30
 export default {
21
-  machineStates: {
22
-    AVAILABLE: 0,
23
-    RUNNING: 1,
24
-    RUNNING_NOT_STARTED: 2,
25
-    FINISHED: 3,
26
-    UNAVAILABLE: 4,
27
-    ERROR: 5,
28
-    UNKNOWN: 6,
29
-  },
30
   stateIcons: [
31
   stateIcons: [
31
     'radiobox-blank',
32
     'radiobox-blank',
32
     'progress-check',
33
     'progress-check',

+ 0
- 122
src/screens/Proxiwash/ProxiwashAboutScreen.js View File

1
-/*
2
- * Copyright (c) 2019 - 2020 Arnaud Vergnet.
3
- *
4
- * This file is part of Campus INSAT.
5
- *
6
- * Campus INSAT is free software: you can redistribute it and/or modify
7
- *  it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * Campus INSAT is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with Campus INSAT.  If not, see <https://www.gnu.org/licenses/>.
18
- */
19
-
20
-// @flow
21
-
22
-import * as React from 'react';
23
-import {Image, View} from 'react-native';
24
-import i18n from 'i18n-js';
25
-import {Card, Avatar, Paragraph, Title} from 'react-native-paper';
26
-import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView';
27
-import type {CardTitleIconPropsType} from '../../constants/PaperStyles';
28
-import ProxiwashConstants from '../../constants/ProxiwashConstants';
29
-
30
-const LOGO = 'https://etud.insa-toulouse.fr/~amicale_app/images/Proxiwash.png';
31
-
32
-export type LaundromatType = {
33
-  id: string,
34
-  title: string,
35
-  subtitle: string,
36
-  description: string,
37
-  tarif: string,
38
-  paymentMethods: string,
39
-  icon: string,
40
-  url: string,
41
-};
42
-
43
-/**
44
- * Class defining the proxiwash about screen.
45
- */
46
-export default class ProxiwashAboutScreen extends React.Component<null> {
47
-  static getCardItem(item: LaundromatType): React.Node {
48
-    return (
49
-      <Card style={{margin: 5}}>
50
-        <Card.Title
51
-          title={i18n.t(item.title)}
52
-          subtitle={i18n.t(item.subtitle)}
53
-          left={(iconProps: CardTitleIconPropsType): React.Node => (
54
-            <Avatar.Icon size={iconProps.size} icon={item.icon} />
55
-          )}
56
-        />
57
-        <Card.Content>
58
-          <Paragraph>{i18n.t(item.description)}</Paragraph>
59
-          <Title>{i18n.t('screens.proxiwash.tariffs')}</Title>
60
-          <Paragraph>{i18n.t(item.tarif)}</Paragraph>
61
-          <Title>{i18n.t('screens.proxiwash.paymentMethods')}</Title>
62
-          <Paragraph>{i18n.t(item.paymentMethods)}</Paragraph>
63
-        </Card.Content>
64
-      </Card>
65
-    );
66
-  }
67
-
68
-  render(): React.Node {
69
-    return (
70
-      <CollapsibleScrollView style={{padding: 5}} hasTab>
71
-        <View
72
-          style={{
73
-            width: '100%',
74
-            height: 100,
75
-            marginTop: 20,
76
-            marginBottom: 20,
77
-            justifyContent: 'center',
78
-            alignItems: 'center',
79
-          }}>
80
-          <Image
81
-            source={{uri: LOGO}}
82
-            style={{height: '100%', width: '100%', resizeMode: 'contain'}}
83
-          />
84
-        </View>
85
-
86
-        {ProxiwashAboutScreen.getCardItem(ProxiwashConstants.washinsa)}
87
-
88
-        {ProxiwashAboutScreen.getCardItem(ProxiwashConstants.tripodeB)}
89
-
90
-        <Card style={{margin: 5}}>
91
-          <Card.Title
92
-            title={i18n.t('screens.proxiwash.dryer')}
93
-            left={(iconProps: CardTitleIconPropsType): React.Node => (
94
-              <Avatar.Icon size={iconProps.size} icon="tumble-dryer" />
95
-            )}
96
-          />
97
-          <Card.Content>
98
-            <Title>{i18n.t('screens.proxiwash.procedure')}</Title>
99
-            <Paragraph>{i18n.t('screens.proxiwash.dryerProcedure')}</Paragraph>
100
-            <Title>{i18n.t('screens.proxiwash.tips')}</Title>
101
-            <Paragraph>{i18n.t('screens.proxiwash.dryerTips')}</Paragraph>
102
-          </Card.Content>
103
-        </Card>
104
-
105
-        <Card style={{margin: 5}}>
106
-          <Card.Title
107
-            title={i18n.t('screens.proxiwash.washer')}
108
-            left={(iconProps: CardTitleIconPropsType): React.Node => (
109
-              <Avatar.Icon size={iconProps.size} icon="washing-machine" />
110
-            )}
111
-          />
112
-          <Card.Content>
113
-            <Title>{i18n.t('screens.proxiwash.procedure')}</Title>
114
-            <Paragraph>{i18n.t('screens.proxiwash.washerProcedure')}</Paragraph>
115
-            <Title>{i18n.t('screens.proxiwash.tips')}</Title>
116
-            <Paragraph>{i18n.t('screens.proxiwash.washerTips')}</Paragraph>
117
-          </Card.Content>
118
-        </Card>
119
-      </CollapsibleScrollView>
120
-    );
121
-  }
122
-}

+ 117
- 0
src/screens/Proxiwash/ProxiwashAboutScreen.tsx View File

1
+/*
2
+ * Copyright (c) 2019 - 2020 Arnaud Vergnet.
3
+ *
4
+ * This file is part of Campus INSAT.
5
+ *
6
+ * Campus INSAT is free software: you can redistribute it and/or modify
7
+ *  it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * Campus INSAT is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with Campus INSAT.  If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+import * as React from 'react';
21
+import {Image, View} from 'react-native';
22
+import i18n from 'i18n-js';
23
+import {Card, Avatar, Paragraph, Title} from 'react-native-paper';
24
+import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView';
25
+import ProxiwashConstants from '../../constants/ProxiwashConstants';
26
+
27
+const LOGO = 'https://etud.insa-toulouse.fr/~amicale_app/images/Proxiwash.png';
28
+
29
+export type LaundromatType = {
30
+  id: string;
31
+  title: string;
32
+  subtitle: string;
33
+  description: string;
34
+  tarif: string;
35
+  paymentMethods: string;
36
+  icon: string;
37
+  url: string;
38
+};
39
+
40
+function getCardItem(item: LaundromatType) {
41
+  return (
42
+    <Card style={{margin: 5}}>
43
+      <Card.Title
44
+        title={i18n.t(item.title)}
45
+        subtitle={i18n.t(item.subtitle)}
46
+        left={(iconProps) => (
47
+          <Avatar.Icon size={iconProps.size} icon={item.icon} />
48
+        )}
49
+      />
50
+      <Card.Content>
51
+        <Paragraph>{i18n.t(item.description)}</Paragraph>
52
+        <Title>{i18n.t('screens.proxiwash.tariffs')}</Title>
53
+        <Paragraph>{i18n.t(item.tarif)}</Paragraph>
54
+        <Title>{i18n.t('screens.proxiwash.paymentMethods')}</Title>
55
+        <Paragraph>{i18n.t(item.paymentMethods)}</Paragraph>
56
+      </Card.Content>
57
+    </Card>
58
+  );
59
+}
60
+
61
+/**
62
+ * Class defining the proxiwash about screen.
63
+ */
64
+export default function ProxiwashAboutScreen() {
65
+  return (
66
+    <CollapsibleScrollView style={{padding: 5}} hasTab>
67
+      <View
68
+        style={{
69
+          width: '100%',
70
+          height: 100,
71
+          marginTop: 20,
72
+          marginBottom: 20,
73
+          justifyContent: 'center',
74
+          alignItems: 'center',
75
+        }}>
76
+        <Image
77
+          source={{uri: LOGO}}
78
+          style={{height: '100%', width: '100%', resizeMode: 'contain'}}
79
+        />
80
+      </View>
81
+
82
+      {getCardItem(ProxiwashConstants.washinsa)}
83
+
84
+      {getCardItem(ProxiwashConstants.tripodeB)}
85
+
86
+      <Card style={{margin: 5}}>
87
+        <Card.Title
88
+          title={i18n.t('screens.proxiwash.dryer')}
89
+          left={(iconProps) => (
90
+            <Avatar.Icon size={iconProps.size} icon="tumble-dryer" />
91
+          )}
92
+        />
93
+        <Card.Content>
94
+          <Title>{i18n.t('screens.proxiwash.procedure')}</Title>
95
+          <Paragraph>{i18n.t('screens.proxiwash.dryerProcedure')}</Paragraph>
96
+          <Title>{i18n.t('screens.proxiwash.tips')}</Title>
97
+          <Paragraph>{i18n.t('screens.proxiwash.dryerTips')}</Paragraph>
98
+        </Card.Content>
99
+      </Card>
100
+
101
+      <Card style={{margin: 5}}>
102
+        <Card.Title
103
+          title={i18n.t('screens.proxiwash.washer')}
104
+          left={(iconProps) => (
105
+            <Avatar.Icon size={iconProps.size} icon="washing-machine" />
106
+          )}
107
+        />
108
+        <Card.Content>
109
+          <Title>{i18n.t('screens.proxiwash.procedure')}</Title>
110
+          <Paragraph>{i18n.t('screens.proxiwash.washerProcedure')}</Paragraph>
111
+          <Title>{i18n.t('screens.proxiwash.tips')}</Title>
112
+          <Paragraph>{i18n.t('screens.proxiwash.washerTips')}</Paragraph>
113
+        </Card.Content>
114
+      </Card>
115
+    </CollapsibleScrollView>
116
+  );
117
+}

src/screens/Proxiwash/ProxiwashScreen.js → src/screens/Proxiwash/ProxiwashScreen.tsx View File

17
  * along with Campus INSAT.  If not, see <https://www.gnu.org/licenses/>.
17
  * along with Campus INSAT.  If not, see <https://www.gnu.org/licenses/>.
18
  */
18
  */
19
 
19
 
20
-// @flow
21
-
22
 import * as React from 'react';
20
 import * as React from 'react';
23
 import {Alert, View} from 'react-native';
21
 import {Alert, View} from 'react-native';
24
 import i18n from 'i18n-js';
22
 import i18n from 'i18n-js';
29
 import * as Notifications from '../../utils/Notifications';
27
 import * as Notifications from '../../utils/Notifications';
30
 import AsyncStorageManager from '../../managers/AsyncStorageManager';
28
 import AsyncStorageManager from '../../managers/AsyncStorageManager';
31
 import ProxiwashListItem from '../../components/Lists/Proxiwash/ProxiwashListItem';
29
 import ProxiwashListItem from '../../components/Lists/Proxiwash/ProxiwashListItem';
32
-import ProxiwashConstants from '../../constants/ProxiwashConstants';
30
+import ProxiwashConstants, {
31
+  MachineStates,
32
+} from '../../constants/ProxiwashConstants';
33
 import CustomModal from '../../components/Overrides/CustomModal';
33
 import CustomModal from '../../components/Overrides/CustomModal';
34
 import AprilFoolsManager from '../../managers/AprilFoolsManager';
34
 import AprilFoolsManager from '../../managers/AprilFoolsManager';
35
 import MaterialHeaderButtons, {
35
 import MaterialHeaderButtons, {
36
   Item,
36
   Item,
37
 } from '../../components/Overrides/CustomHeaderButton';
37
 } from '../../components/Overrides/CustomHeaderButton';
38
 import ProxiwashSectionHeader from '../../components/Lists/Proxiwash/ProxiwashSectionHeader';
38
 import ProxiwashSectionHeader from '../../components/Lists/Proxiwash/ProxiwashSectionHeader';
39
-import type {CustomThemeType} from '../../managers/ThemeManager';
40
 import {
39
 import {
41
   getCleanedMachineWatched,
40
   getCleanedMachineWatched,
42
   getMachineEndDate,
41
   getMachineEndDate,
47
 import type {SectionListDataType} from '../../components/Screens/WebSectionList';
46
 import type {SectionListDataType} from '../../components/Screens/WebSectionList';
48
 import type {LaundromatType} from './ProxiwashAboutScreen';
47
 import type {LaundromatType} from './ProxiwashAboutScreen';
49
 
48
 
50
-const modalStateStrings = {};
49
+const modalStateStrings: {[key in MachineStates]: string} = {
50
+  [MachineStates.AVAILABLE]: i18n.t('screens.proxiwash.modal.ready'),
51
+  [MachineStates.RUNNING]: i18n.t('screens.proxiwash.modal.running'),
52
+  [MachineStates.RUNNING_NOT_STARTED]: i18n.t(
53
+    'screens.proxiwash.modal.runningNotStarted',
54
+  ),
55
+  [MachineStates.FINISHED]: i18n.t('screens.proxiwash.modal.finished'),
56
+  [MachineStates.UNAVAILABLE]: i18n.t('screens.proxiwash.modal.broken'),
57
+  [MachineStates.ERROR]: i18n.t('screens.proxiwash.modal.error'),
58
+  [MachineStates.UNKNOWN]: i18n.t('screens.proxiwash.modal.unknown'),
59
+};
51
 
60
 
52
 const REFRESH_TIME = 1000 * 10; // Refresh every 10 seconds
61
 const REFRESH_TIME = 1000 * 10; // Refresh every 10 seconds
53
 const LIST_ITEM_HEIGHT = 64;
62
 const LIST_ITEM_HEIGHT = 64;
54
 
63
 
55
 export type ProxiwashMachineType = {
64
 export type ProxiwashMachineType = {
56
-  number: string,
57
-  state: string,
58
-  maxWeight: number,
59
-  startTime: string,
60
-  endTime: string,
61
-  donePercent: string,
62
-  remainingTime: string,
63
-  program: string,
65
+  number: string;
66
+  state: MachineStates;
67
+  maxWeight: number;
68
+  startTime: string;
69
+  endTime: string;
70
+  donePercent: string;
71
+  remainingTime: string;
72
+  program: string;
64
 };
73
 };
65
 
74
 
66
 type PropsType = {
75
 type PropsType = {
67
-  navigation: StackNavigationProp,
68
-  theme: CustomThemeType,
76
+  navigation: StackNavigationProp<any>;
77
+  theme: ReactNativePaper.Theme;
69
 };
78
 };
70
 
79
 
71
 type StateType = {
80
 type StateType = {
72
-  modalCurrentDisplayItem: React.Node,
73
-  machinesWatched: Array<ProxiwashMachineType>,
74
-  selectedWash: string,
81
+  modalCurrentDisplayItem: React.ReactNode;
82
+  machinesWatched: Array<ProxiwashMachineType>;
83
+  selectedWash: string;
75
 };
84
 };
76
 
85
 
77
 /**
86
 /**
92
   modalRef: null | Modalize;
101
   modalRef: null | Modalize;
93
 
102
 
94
   fetchedData: {
103
   fetchedData: {
95
-    dryers: Array<ProxiwashMachineType>,
96
-    washers: Array<ProxiwashMachineType>,
104
+    dryers: Array<ProxiwashMachineType>;
105
+    washers: Array<ProxiwashMachineType>;
97
   };
106
   };
98
 
107
 
99
   /**
108
   /**
100
    * Creates machine state parameters using current theme and translations
109
    * Creates machine state parameters using current theme and translations
101
    */
110
    */
102
-  constructor() {
103
-    super();
111
+  constructor(props: PropsType) {
112
+    super(props);
113
+    this.modalRef = null;
114
+    this.fetchedData = {dryers: [], washers: []};
104
     this.state = {
115
     this.state = {
105
       modalCurrentDisplayItem: null,
116
       modalCurrentDisplayItem: null,
106
       machinesWatched: AsyncStorageManager.getObject(
117
       machinesWatched: AsyncStorageManager.getObject(
110
         AsyncStorageManager.PREFERENCES.selectedWash.key,
121
         AsyncStorageManager.PREFERENCES.selectedWash.key,
111
       ),
122
       ),
112
     };
123
     };
113
-    modalStateStrings[ProxiwashConstants.machineStates.AVAILABLE] = i18n.t(
114
-      'screens.proxiwash.modal.ready',
115
-    );
116
-    modalStateStrings[ProxiwashConstants.machineStates.RUNNING] = i18n.t(
117
-      'screens.proxiwash.modal.running',
118
-    );
119
-    modalStateStrings[
120
-      ProxiwashConstants.machineStates.RUNNING_NOT_STARTED
121
-    ] = i18n.t('screens.proxiwash.modal.runningNotStarted');
122
-    modalStateStrings[ProxiwashConstants.machineStates.FINISHED] = i18n.t(
123
-      'screens.proxiwash.modal.finished',
124
-    );
125
-    modalStateStrings[ProxiwashConstants.machineStates.UNAVAILABLE] = i18n.t(
126
-      'screens.proxiwash.modal.broken',
127
-    );
128
-    modalStateStrings[ProxiwashConstants.machineStates.ERROR] = i18n.t(
129
-      'screens.proxiwash.modal.error',
130
-    );
131
-    modalStateStrings[ProxiwashConstants.machineStates.UNKNOWN] = i18n.t(
132
-      'screens.proxiwash.modal.unknown',
133
-    );
134
   }
124
   }
135
 
125
 
136
   /**
126
   /**
139
   componentDidMount() {
129
   componentDidMount() {
140
     const {navigation} = this.props;
130
     const {navigation} = this.props;
141
     navigation.setOptions({
131
     navigation.setOptions({
142
-      headerRight: (): React.Node => (
132
+      headerRight: () => (
143
         <MaterialHeaderButtons>
133
         <MaterialHeaderButtons>
144
           <Item
134
           <Item
145
             title="switch"
135
             title="switch"
146
             iconName="swap-horizontal"
136
             iconName="swap-horizontal"
147
-            onPress={():void => navigation.navigate('settings')}
137
+            onPress={(): void => navigation.navigate('settings')}
148
           />
138
           />
149
           <Item
139
           <Item
150
             title="information"
140
             title="information"
164
     );
154
     );
165
     if (selected !== state.selectedWash) {
155
     if (selected !== state.selectedWash) {
166
       this.setState({
156
       this.setState({
167
-        selectedWash: selected
157
+        selectedWash: selected,
168
       });
158
       });
169
     }
159
     }
170
-  }
160
+  };
171
 
161
 
172
   /**
162
   /**
173
    * Callback used when pressing the about button.
163
    * Callback used when pressing the about button.
208
    * @param isDryer True if the given item is a dryer
198
    * @param isDryer True if the given item is a dryer
209
    * @return {*}
199
    * @return {*}
210
    */
200
    */
211
-  getModalContent(
212
-    title: string,
213
-    item: ProxiwashMachineType,
214
-    isDryer: boolean,
215
-  ): React.Node {
201
+  getModalContent(title: string, item: ProxiwashMachineType, isDryer: boolean) {
216
     const {props, state} = this;
202
     const {props, state} = this;
217
-    let button = {
203
+    let button: {text: string; icon: string; onPress: () => void} = {
218
       text: i18n.t('screens.proxiwash.modal.ok'),
204
       text: i18n.t('screens.proxiwash.modal.ok'),
219
       icon: '',
205
       icon: '',
220
-      onPress: undefined,
206
+      onPress: () => undefined,
221
     };
207
     };
222
     let message = modalStateStrings[item.state];
208
     let message = modalStateStrings[item.state];
223
-    const onPress = this.onSetupNotificationsPress.bind(this, item);
224
-    if (item.state === ProxiwashConstants.machineStates.RUNNING) {
209
+    const onPress = () => this.onSetupNotificationsPress(item);
210
+    if (item.state === MachineStates.RUNNING) {
225
       let remainingTime = parseInt(item.remainingTime, 10);
211
       let remainingTime = parseInt(item.remainingTime, 10);
226
-      if (remainingTime < 0) remainingTime = 0;
212
+      if (remainingTime < 0) {
213
+        remainingTime = 0;
214
+      }
227
 
215
 
228
       button = {
216
       button = {
229
         text: isMachineWatched(item, state.machinesWatched)
217
         text: isMachineWatched(item, state.machinesWatched)
230
           ? i18n.t('screens.proxiwash.modal.disableNotifications')
218
           ? i18n.t('screens.proxiwash.modal.disableNotifications')
231
           : i18n.t('screens.proxiwash.modal.enableNotifications'),
219
           : i18n.t('screens.proxiwash.modal.enableNotifications'),
232
         icon: '',
220
         icon: '',
233
-        onPress,
221
+        onPress: onPress,
234
       };
222
       };
235
       message = i18n.t('screens.proxiwash.modal.running', {
223
       message = i18n.t('screens.proxiwash.modal.running', {
236
         start: item.startTime,
224
         start: item.startTime,
247
         }}>
235
         }}>
248
         <Card.Title
236
         <Card.Title
249
           title={title}
237
           title={title}
250
-          left={(): React.Node => (
238
+          left={() => (
251
             <Avatar.Icon
239
             <Avatar.Icon
252
               icon={isDryer ? 'tumble-dryer' : 'washing-machine'}
240
               icon={isDryer ? 'tumble-dryer' : 'washing-machine'}
253
               color={props.theme.colors.text}
241
               color={props.theme.colors.text}
259
           <Text>{message}</Text>
247
           <Text>{message}</Text>
260
         </Card.Content>
248
         </Card.Content>
261
 
249
 
262
-        {button.onPress !== undefined ? (
250
+        {button.onPress ? (
263
           <Card.Actions>
251
           <Card.Actions>
264
             <Button
252
             <Button
265
               icon={button.icon}
253
               icon={button.icon}
280
    * @param section The section to render
268
    * @param section The section to render
281
    * @return {*}
269
    * @return {*}
282
    */
270
    */
283
-  getRenderSectionHeader = ({
284
-    section,
285
-  }: {
286
-    section: {title: string},
287
-  }): React.Node => {
271
+  getRenderSectionHeader = ({section}: {section: {title: string}}) => {
288
     const isDryer = section.title === i18n.t('screens.proxiwash.dryers');
272
     const isDryer = section.title === i18n.t('screens.proxiwash.dryers');
289
     const nbAvailable = this.getMachineAvailableNumber(isDryer);
273
     const nbAvailable = this.getMachineAvailableNumber(isDryer);
290
     return (
274
     return (
307
     item,
291
     item,
308
     section,
292
     section,
309
   }: {
293
   }: {
310
-    item: ProxiwashMachineType,
311
-    section: {title: string},
312
-  }): React.Node => {
294
+    item: ProxiwashMachineType;
295
+    section: {title: string};
296
+  }) => {
313
     const {machinesWatched} = this.state;
297
     const {machinesWatched} = this.state;
314
     const isDryer = section.title === i18n.t('screens.proxiwash.dryers');
298
     const isDryer = section.title === i18n.t('screens.proxiwash.dryers');
315
     return (
299
     return (
369
    */
353
    */
370
   getMachineAvailableNumber(isDryer: boolean): number {
354
   getMachineAvailableNumber(isDryer: boolean): number {
371
     let data;
355
     let data;
372
-    if (isDryer) data = this.fetchedData.dryers;
373
-    else data = this.fetchedData.washers;
356
+    if (isDryer) {
357
+      data = this.fetchedData.dryers;
358
+    } else {
359
+      data = this.fetchedData.washers;
360
+    }
374
     let count = 0;
361
     let count = 0;
375
     data.forEach((machine: ProxiwashMachineType) => {
362
     data.forEach((machine: ProxiwashMachineType) => {
376
-      if (machine.state === ProxiwashConstants.machineStates.AVAILABLE)
363
+      if (machine.state === MachineStates.AVAILABLE) {
377
         count += 1;
364
         count += 1;
365
+      }
378
     });
366
     });
379
     return count;
367
     return count;
380
   }
368
   }
386
    * @return {*}
374
    * @return {*}
387
    */
375
    */
388
   createDataset = (fetchedData: {
376
   createDataset = (fetchedData: {
389
-    dryers: Array<ProxiwashMachineType>,
390
-    washers: Array<ProxiwashMachineType>,
377
+    dryers: Array<ProxiwashMachineType>;
378
+    washers: Array<ProxiwashMachineType>;
391
   }): SectionListDataType<ProxiwashMachineType> => {
379
   }): SectionListDataType<ProxiwashMachineType> => {
392
     const {state} = this;
380
     const {state} = this;
393
     let data = fetchedData;
381
     let data = fetchedData;
466
       if (
454
       if (
467
         machine.number === selectedMachine.number &&
455
         machine.number === selectedMachine.number &&
468
         machine.endTime === selectedMachine.endTime
456
         machine.endTime === selectedMachine.endTime
469
-      )
457
+      ) {
470
         newList.splice(index, 1);
458
         newList.splice(index, 1);
459
+      }
471
     });
460
     });
472
     this.saveNewWatchedList(newList);
461
     this.saveNewWatchedList(newList);
473
   }
462
   }
480
     );
469
     );
481
   }
470
   }
482
 
471
 
483
-  render(): React.Node {
472
+  render() {
484
     const {state} = this;
473
     const {state} = this;
485
     const {navigation} = this.props;
474
     const {navigation} = this.props;
486
     let data: LaundromatType;
475
     let data: LaundromatType;

Loading…
Cancel
Save