Fakultas Ilmu Komputer UI

index.tsx 1.26 KB
Newer Older
1
import React, { FC } from 'react';
2
import { View, StyleSheet } from 'react-native';
3
4
5
6
7
8
9
10
11
12
import { LikertScale, RadioButtonGroup, TextField } from 'components/form';

import {
  dietReportSelectFields,
  dietReportTextFields,
} from 'constants/weeklyReport';
import { ReportProps } from '../../types';
import { layoutStyles } from 'styles';

const Report2: FC<ReportProps> = ({ getTextInputProps, getFormFieldProps }) => (
13
  <View style={layoutStyles}>
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
    {dietReportSelectFields.dietReportPage2.map((props, i) => {
      const FormField = props.scaleDescription ? LikertScale : RadioButtonGroup;
      return (
        <View key={`report2-select${i}`} style={styles.spacing}>
          <FormField
            {...props}
            choices={props.choiceList.map((label: string, id: number) => ({
              label,
              value: id + 1,
            }))}
            {...getFormFieldProps(props.name)}
            required
          />
        </View>
      );
    })}
    {dietReportTextFields.dietReportPage2.map((props, i) => (
      <TextField
        {...props}
        {...getTextInputProps(props.name)}
        key={`report2-textfield${i}`}
      />
    ))}
37
  </View>
38
39
40
41
42
43
44
45
46
);

export const styles = StyleSheet.create({
  spacing: {
    marginBottom: 24,
  },
});

export default Report2;