-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEmailFields.jsx
More file actions
122 lines (113 loc) · 2.99 KB
/
EmailFields.jsx
File metadata and controls
122 lines (113 loc) · 2.99 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import React from "react";
import PropTypes from "prop-types";
import Animated, { FadeInDown, FadeInUp } from "react-native-reanimated";
import { moderateScale } from "react-native-size-matters";
import { Badge } from "./Badge";
import { InputEmailChip } from "../InputEmailChip";
export const EmailFields = ({
shouldShowEmailFields,
setIsEmailFieldsVisible,
isEmailFieldsVisible,
toEmails,
toEmailsForForward,
ccEmails,
bccEmails,
setToEmails,
setToEmailsForForward,
setBccEmails,
setCcEmails,
isReplyOptionSelected,
isNoteOptionSelected,
isForwardOptionSelected,
}) => {
const firstToEmail = isReplyOptionSelected
? toEmails[0]
: toEmailsForForward[0];
let badge = "";
if (firstToEmail) {
badge = `To ${firstToEmail}`;
} else if (isForwardOptionSelected) {
badge = "Click here to enter email id.";
}
const totalEmailsMinus1 =
toEmails.length +
toEmailsForForward.length +
ccEmails.length +
bccEmails.length -
1;
if (!shouldShowEmailFields) return null;
return isEmailFieldsVisible ? (
<Animated.View
entering={FadeInDown}
key={isEmailFieldsVisible}
pb={moderateScale(10)}
>
{isReplyOptionSelected && (
<InputEmailChip
disabled
emails={toEmails}
label="To:"
onUpdate={setToEmails}
/>
)}
{isForwardOptionSelected && (
<InputEmailChip
disabled={false}
emails={toEmailsForForward}
label="To:"
onUpdate={setToEmailsForForward}
/>
)}
<InputEmailChip
disabled={false}
emails={ccEmails}
label="Cc:"
onUpdate={setCcEmails}
/>
<InputEmailChip
disabled={false}
emails={bccEmails}
label="Bcc:"
onUpdate={setBccEmails}
/>
</Animated.View>
) : (
<Animated.View
alignItems="flex-start"
entering={FadeInUp}
flexDirection="row"
flexWrap="wrap"
key={isEmailFieldsVisible}
style={
isNoteOptionSelected && {
height: moderateScale(0),
width: moderateScale(0),
}
}
onTouchStart={() => setIsEmailFieldsVisible(true)}
>
{toEmails.length > 0 && (
<>
<Badge text={badge} />
{totalEmailsMinus1 > 1 && <Badge text={`+ ${totalEmailsMinus1}`} />}
</>
)}
</Animated.View>
);
};
EmailFields.propTypes = {
shouldShowEmailFields: PropTypes.bool,
isEmailFieldsVisible: PropTypes.bool,
setIsEmailFieldsVisible: PropTypes.func,
ccEmails: PropTypes.arrayOf(PropTypes.string),
toEmails: PropTypes.arrayOf(PropTypes.string),
toEmailsForForward: PropTypes.arrayOf(PropTypes.string),
bccEmails: PropTypes.arrayOf(PropTypes.string),
setBccEmails: PropTypes.func,
setCcEmails: PropTypes.func,
setToEmails: PropTypes.func,
setToEmailsForForward: PropTypes.func,
isReplyOptionSelected: PropTypes.bool,
isNoteOptionSelected: PropTypes.bool,
isForwardOptionSelected: PropTypes.bool,
};