-
Notifications
You must be signed in to change notification settings - Fork 3k
/
SetTimePage.js
73 lines (65 loc) · 2.41 KB
/
SetTimePage.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
import lodashGet from 'lodash/get';
import React from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import FullscreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import TimePicker from '@components/TimePicker/TimePicker';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import usePrivatePersonalDetails from '@hooks/usePrivatePersonalDetails';
import useThemeStyles from '@hooks/useThemeStyles';
import * as User from '@libs/actions/User';
import compose from '@libs/compose';
import DateUtils from '@libs/DateUtils';
import Navigation from '@libs/Navigation/Navigation';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
const propTypes = {
...withLocalizePropTypes,
};
function SetTimePage({translate, privatePersonalDetails, customStatus}) {
usePrivatePersonalDetails();
const styles = useThemeStyles();
const clearAfter = lodashGet(customStatus, 'clearAfter', '');
const onSubmit = (time) => {
const timeToUse = DateUtils.combineDateAndTime(time, clearAfter);
User.updateDraftCustomStatus({clearAfter: timeToUse});
Navigation.goBack(ROUTES.SETTINGS_STATUS_CLEAR_AFTER);
};
if (lodashGet(privatePersonalDetails, 'isLoading', true)) {
return <FullscreenLoadingIndicator />;
}
return (
<ScreenWrapper
includeSafeAreaPaddingBottom
testID={SetTimePage.displayName}
>
<HeaderWithBackButton
title={translate('statusPage.time')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_STATUS_CLEAR_AFTER)}
/>
<View style={styles.flex1}>
<TimePicker
inputID="timePicker"
defaultValue={clearAfter}
style={styles.flexGrow1}
onSubmit={onSubmit}
/>
</View>
</ScreenWrapper>
);
}
SetTimePage.propTypes = propTypes;
SetTimePage.displayName = 'SetTimePage';
export default compose(
withLocalize,
withOnyx({
privatePersonalDetails: {
key: ONYXKEYS.PRIVATE_PERSONAL_DETAILS,
},
customStatus: {
key: ONYXKEYS.CUSTOM_STATUS_DRAFT,
},
}),
)(SetTimePage);