• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

akvo / nmis-mobile / 5723893709

01 Aug 2023 07:32AM UTC coverage: 80.065% (+7.3%) from 72.774%
5723893709

push

github

wayangalihpratama
[#32] Fix prettier

636 of 840 branches covered (75.71%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

1332 of 1618 relevant lines covered (82.32%)

16.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/app/src/form/fields/TypeMultipleOption.js
1
import React from 'react';
2
import { View } from 'react-native';
3
import { FieldLabel } from '../support';
4
import { styles } from '../styles';
5
import { CheckBox } from '@rneui/themed';
6
import { MultiSelect } from 'react-native-element-dropdown';
7
import { UIState } from '../../store';
8
import { i18n } from '../../lib';
9

10
const TypeMultipleOption = ({
4✔
11
  onChange,
12
  values,
13
  keyform,
14
  id,
15
  name,
16
  option = [],
4✔
17
  tooltip,
18
  required,
19
  requiredSign,
20
}) => {
21
  const isCheckBox = React.useMemo(() => {
6✔
22
    return option.length <= 3;
6✔
23
  }, [option]);
24
  const activeLang = UIState.useState((s) => s.lang);
12✔
25
  const trans = i18n.text(activeLang);
6✔
26

27
  return (
6✔
28
    <View style={styles.multipleOptionContainer}>
29
      <FieldLabel
30
        keyform={keyform}
31
        name={name}
32
        tooltip={tooltip}
33
        requiredSign={required ? requiredSign : null}
6✔
34
      />
35
      {isCheckBox ? (
6✔
36
        option.map((opt, opti) => (
37
          <CheckBox
3✔
38
            key={opti}
39
            containerStyle={styles.radioFieldContainer}
40
            textStyle={styles.radioFieldText}
41
            checked={values?.[id]?.includes(opt.name)}
42
            onPress={() => {
43
              if (onChange) {
1!
44
                values?.[id]?.includes(opt.name)
1!
45
                  ? onChange(`${id}.${opti}`, null)
46
                  : onChange(`${id}.${opti}`, opt.name);
47
              }
48
            }}
49
            title={opt.label}
50
          />
51
        ))
52
      ) : (
53
        <MultiSelect
54
          style={[styles.dropdownField]}
55
          selectedStyle={styles.dropdownSelectedList}
56
          data={option}
57
          search
58
          maxHeight={300}
59
          labelField="label"
60
          valueField="name"
61
          searchPlaceholder={trans.searchPlaceholder}
62
          placeholder={trans.selectItem}
63
          value={values?.[id] || []}
2✔
64
          onChange={(value) => {
65
            if (onChange) {
×
66
              onChange(id, value);
×
67
            }
68
          }}
69
          testID="type-multiple-option-dropdown"
70
        />
71
      )}
72
    </View>
73
  );
74
};
75

76
export default TypeMultipleOption;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc