import React, { Fragment, useRef, useState, useEffect } from 'react';
import Styled from 'styled-components/native';
import EmptyLayout from '~/Components/Layouts/EmptyLayout';
import Form from '~/Components/Form';
import Theme from '~/Themes';
import { Util } from '~/Utils/utils';
import { View } from 'react-native';
import { ListStyle } from '~/Components/Listing/Search';
import Icon from '~/Components/UIControls/Icon';
import IconButton from '~/Components/UIControls/IconButton';
import { usePrompt } from '~/Components/UIControls/Message';
import Weather from '~/Screens/Dashboard/Weather';
import { isTrue } from '~/Components/UIControls/Common';
import { UploadFileType } from '~/Components/UIControls/UploadFile';
import Button from '~/Components/UIControls/Button';
import { usePopup } from '~/Components/UIControls/Popup';

const Human = Styled.View`
    flex-direction: row;
    justify-content: center;
    align-items: center;
    height: 32px;
    border: 0px;
    margin-left:10px;
    margin-bottom:10px;
    padding-left:15px;
    padding-right:15px;
    background-color: #0b83e6;
    border-radius:5px;
    overflow:hidden;
`;
const HumanName = Styled.Text`
    font-size: 16;
    font-family: ${Theme.Fonts.Regular};
    include-font-padding: false;
    line-height: 24;
    letter-spacing: -1.6;
    color: white;
`;
const HumanRemove = ({ onPress = () => {} }) => {
    return (
        <IconButton iconFamily="AntDesign" iconName="minuscircle" color="white" size={20} onPress={onPress} style={{ marginLeft: 10 }} />
    );
};

const HumanManager = ({ editable, initialHumans, setValue, humansDataPath }) => {
    const [humans, setHumans] = useState(Array.isArray(initialHumans) ? initialHumans : []);

    const { prompt } = usePrompt();

    useEffect(() => {
        if (Array.isArray(initialHumans)) {
            setValue(humansDataPath, [...initialHumans]);
            setHumans([...initialHumans]);
        } else {
            setValue(humansDataPath, []);
            setHumans([]);
        }
    }, [editable]);

    const addHuman = () => {
        prompt({
            title: '인원명',
            message: '추가할 인원의 이름을 입력하세요.',
            defaultValue: '',
            confirm: (text) => {
                let newHumans = [...humans];
                newHumans.push(text);
                setValue(humansDataPath, newHumans, true);
                setHumans(newHumans);
            },
        });
    };

    const removeHuman = (index) => {
        let newHumans = [];
        for (let i = 0; i < humans.length; i++) {
            if (index == i) continue;
            newHumans.push(humans[i]);
        }
        setValue(humansDataPath, newHumans, true);
        setHumans(newHumans);
    };

    return (
        <Fragment>
            <Form.FieldSetHead>
                <Form.Legend>
                    <Form.LegendLabel>인원목록</Form.LegendLabel>
                </Form.Legend>
                <Form.ButtonGroup>
                    {isTrue(editable) && (
                        <Form.HeadButton
                            onPress={() => {
                                addHuman();
                            }}
                        >
                            <Form.LegendLabel>추가</Form.LegendLabel>
                        </Form.HeadButton>
                    )}
                </Form.ButtonGroup>
            </Form.FieldSetHead>
            <Form.FieldSet style={{ flexDirection: 'row', flexWrap: 'wrap', alignItems: 'flex-start' }}>
                {humans && Array.isArray(humans) && humans.length > 0 ? (
                    humans.map((name, index) => {
                        return (
                            <Fragment key={`human-${index}`}>
                                <Human style={!isTrue(editable) && { backgroundColor: '#9aa3ac' }}>
                                    <HumanName>{name}</HumanName>
                                    {isTrue(editable) && (
                                        <HumanRemove
                                            onPress={() => {
                                                removeHuman(index);
                                            }}
                                        />
                                    )}
                                </Human>
                            </Fragment>
                        );
                    })
                ) : (
                    <View style={{ flex: 1, height: 100, justifyContent: 'center', alignItems: 'center' }}>
                        <Form.Label
                            style={{
                                textAlign: 'center',
                                fontFamily: Theme.Fonts.Regular,
                                letterSpacing: -1.6,
                                fontSize: 18,
                                lineHeight: 30,
                            }}
                        >
                            인원을 추가해 주세요.
                        </Form.Label>
                    </View>
                )}
            </Form.FieldSet>
            <Form.Regist name={humansDataPath} />
        </Fragment>
    );
};

export default Screen = ({ navigation, register, unregister, data, setData, setValue, errors }) => {
    const action = navigation.getParam('action', Form.VIEW);
    const editable = navigation.getParam('editable', action == Form.VIEW ? false : true);
    const setEditable = (value) => {
        navigation.setParams({ editable: value });
    };
    const refreshList = navigation.getParam('refreshList', () => {});
    const siteId = navigation.getParam('siteId', 0);
    const addDate = navigation.getParam('addDate', new Date());
    const setAddDate = (value) => {
        navigation.setParams({ addDate: value });
    };
    const businessFieldId = navigation.getParam('businessFieldId', 0);
    const isApproved = navigation.getParam('isApproved', false);

    const { openPopup } = usePopup();

    return (
        <EmptyLayout>
            <Form.Container id="daily-report-basic-info-form" style={{ paddingLeft: 0, paddingTop: 0, paddingRight: 0, paddingBottom: 0 }}>
                <Form.FieldSetHead>
                    <Form.Legend>
                        <Form.LegendLabel>기본정보</Form.LegendLabel>
                    </Form.Legend>
                </Form.FieldSetHead>
                <Form.FieldSet>
                    <Form.Field>
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>제목</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={data.Name}
                            onChangeText={(text) => {
                                setValue('Name', text, true);
                            }}
                        />
                    </Form.Field>
                    <Form.Regist editable={editable} name="Name" rule={{ required: '제목을 입력하세요.' }} error={errors.SitemapId} />

                    <Form.Field>
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>특이사항</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={data.Contents}
                            onChangeText={(text) => {
                                setValue('Contents', text, true);
                            }}
                        />
                    </Form.Field>
                    <Form.Regist editable={editable} name="Contents" />

                    <Form.Field>
                        <Form.TitleTop style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>첨부파일</Form.Label>
                        </Form.TitleTop>
                        <Form.UploadFile
                            type={UploadFileType.Image}
                            editable={editable}
                            defaultFile={data.CmFile}
                            onUpload={(isUpload, result) => {
                                Form.uploadFile('CmFile', isUpload, result);
                            }}
                            onDelete={() => {
                                Form.deleteFile('CmFile');
                            }}
                        />
                    </Form.Field>
                    <Form.RegistFile editable={editable} name="CmFile" value={Util.get(data, 'CmFile')} />
                </Form.FieldSet>

                {isApproved && (
                    <Fragment>
                        <Form.FieldSetHead>
                            <Form.Legend>
                                <Form.LegendLabel>결재정보</Form.LegendLabel>
                            </Form.Legend>
                        </Form.FieldSetHead>
                        <Form.FieldSet>
                            <Form.Field>
                                <Form.Title>
                                    <Form.Label>결재자</Form.Label>
                                </Form.Title>
                                <Form.Input editable={editable} defaultValue={data.ApproverUserName} />
                            </Form.Field>
                            {/*
                            <Form.Field>
                                <Form.Title><Form.Label>결재자2</Form.Label></Form.Title>
                                <Form.Input editable={editable} defaultValue={data.ApproverUserName2} />
                            </Form.Field>
                            <Form.Field>
                                <Form.Title><Form.Label>결재자3</Form.Label></Form.Title>
                                <Form.Input editable={editable} defaultValue={data.ApproverUserName3} />
                            </Form.Field>
                            <Form.Field>
                                <Form.Title><Form.Label>결재자4</Form.Label></Form.Title>
                                <Form.Input editable={editable} defaultValue={data.ApproverUserName4} />
                            </Form.Field>
                            <Form.Field>
                                <Form.Title><Form.Label>결재자5</Form.Label></Form.Title>
                                <Form.Input editable={editable} defaultValue={data.ApproverUserName5} />
                            </Form.Field>
                            */}
                        </Form.FieldSet>
                    </Fragment>
                )}

                <Form.FieldSetHead>
                    <Form.Legend>
                        <Form.LegendLabel>날씨정보</Form.LegendLabel>
                    </Form.Legend>
                </Form.FieldSetHead>
                <Weather doNotFetch={true} weatherinfo={Util.get(data, 'DataObject.Weather')} style={{ marginTop: 10 }} />

                <Form.FieldSetHead>
                    <Form.Legend>
                        <Form.LegendLabel>인원현황</Form.LegendLabel>
                    </Form.Legend>
                </Form.FieldSetHead>
                <Form.FieldSet>
                    <Form.Field>
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>총원</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={Util.get(data, 'DataObject.HumanResourceTotal')}
                            onChangeText={(text) => {
                                setValue('DataObject.HumanResourceTotal', text, true);
                            }}
                        />
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>결원</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={Util.get(data, 'DataObject.HumanResourceVacancy')}
                            onChangeText={(text) => {
                                setValue('DataObject.HumanResourceVacancy', text, true);
                            }}
                        />
                    </Form.Field>
                    <Form.Regist editable={editable} name="DataObject.HumanResourceTotal" />
                    <Form.Regist editable={editable} name="DataObject.HumanResourceVacancy" />

                    <Form.Field>
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>비번</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={Util.get(data, 'DataObject.HumanResourceOff')}
                            onChangeText={(text) => {
                                setValue('DataObject.HumanResourceOff', text, true);
                            }}
                        />
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>휴가</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={Util.get(data, 'DataObject.HumanResourceVacation')}
                            onChangeText={(text) => {
                                setValue('DataObject.HumanResourceVacation', text, true);
                            }}
                        />
                    </Form.Field>
                    <Form.Regist editable={editable} name="DataObject.HumanResourceOff" />
                    <Form.Regist editable={editable} name="DataObject.HumanResourceVacation" />

                    <Form.Field>
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>휴무</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={Util.get(data, 'DataObject.HumanResourceClosed')}
                            onChangeText={(text) => {
                                setValue('DataObject.HumanResourceClosed', text, true);
                            }}
                        />
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>교육</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={Util.get(data, 'DataObject.HumanResourceTrain')}
                            onChangeText={(text) => {
                                setValue('DataObject.HumanResourceTrain', text, true);
                            }}
                        />
                    </Form.Field>
                    <Form.Regist editable={editable} name="DataObject.HumanResourceClosed" />
                    <Form.Regist editable={editable} name="DataObject.HumanResourceTrain" />

                    <Form.Field>
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>출장</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={Util.get(data, 'DataObject.HumanResourceOut')}
                            onChangeText={(text) => {
                                setValue('DataObject.HumanResourceOut', text, true);
                            }}
                        />
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>당직</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={Util.get(data, 'DataObject.HumanResourceEtc')}
                            onChangeText={(text) => {
                                setValue('DataObject.HumanResourceEtc', text, true);
                            }}
                        />
                    </Form.Field>
                    <Form.Regist editable={editable} name="DataObject.HumanResourceOut" />
                    <Form.Regist editable={editable} name="DataObject.HumanResourceEtc" />

                    <Form.Field>
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>현원</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={Util.get(data, 'DataObject.HumanResourceCurrent')}
                            onChangeText={(text) => {
                                setValue('DataObject.HumanResourceCurrent', text, true);
                            }}
                        />
                    </Form.Field>
                    <Form.Regist editable={editable} name="DataObject.HumanResourceCurrent" />
                </Form.FieldSet>

                <Form.FieldSetHead>
                    <Form.Legend>
                        <Form.LegendLabel>인원내역</Form.LegendLabel>
                    </Form.Legend>
                </Form.FieldSetHead>
                <Form.FieldSet>
                    <Form.Field>
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>비번</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={Util.get(data, 'DataObject.HumanResourceOffName')}
                            onChangeText={(text) => {
                                setValue('DataObject.HumanResourceOffName', text, true);
                            }}
                        />
                        {/*
                        <Button
                            style={{
                                width: 60,
                                paddingLeft: 3,
                                paddingRight: 0,
                                paddingTop: 0,
                                paddingBottom: 0,
                            }}
                            buttonStyle={{ height: 40 }}
                            textStyle={{ fontSize: 14 }}
                            onPress={() => {
                                openPopup('/Popup/DragDropSample/Index', {}, (result) => {
                                    setValue('DataObject.HumanResourceOffName', result, true);
                                    setData({ ...data, DataObject: { ...data.DataObject, HumanResourceOffName: result } });
                                });
                            }}
                        >
                            선택
                        </Button>
                        */}
                    </Form.Field>
                    <Form.Regist editable={editable} name="DataObject.HumanResourceOffName" />

                    <Form.Field>
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>휴가</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={Util.get(data, 'DataObject.HumanResourceVacationName')}
                            onChangeText={(text) => {
                                setValue('DataObject.HumanResourceVacationName', text, true);
                            }}
                        />
                        {/*
                        <Button
                            style={{
                                width: 60,
                                paddingLeft: 3,
                                paddingRight: 0,
                                paddingTop: 0,
                                paddingBottom: 0,
                            }}
                            buttonStyle={{ height: 40 }}
                            textStyle={{ fontSize: 14 }}
                            onPress={() => {
                                openPopup('/Popup/DragDropSample/Index', {}, (result) => {
                                    setValue('DataObject.HumanResourceVacationName', result, true);
                                    setData({ ...data, DataObject: { ...data.DataObject, HumanResourceVacationName: result } });
                                });
                            }}
                        >
                            선택
                        </Button>
                        */}
                    </Form.Field>
                    <Form.Regist editable={editable} name="DataObject.HumanResourceVacationName" />

                    <Form.Field>
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>휴무</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={Util.get(data, 'DataObject.HumanResourceClosedName')}
                            onChangeText={(text) => {
                                setValue('DataObject.HumanResourceClosedName', text, true);
                            }}
                        />
                        {/*
                        <Button
                            style={{
                                width: 60,
                                paddingLeft: 3,
                                paddingRight: 0,
                                paddingTop: 0,
                                paddingBottom: 0,
                            }}
                            buttonStyle={{ height: 40 }}
                            textStyle={{ fontSize: 14 }}
                            onPress={() => {
                                openPopup('/Popup/DragDropSample/Index', {}, (result) => {
                                    setValue('DataObject.HumanResourceClosedName', result, true);
                                    setData({ ...data, DataObject: { ...data.DataObject, HumanResourceClosedName: result } });
                                });
                            }}
                        >
                            선택
                        </Button>
                        */}
                    </Form.Field>
                    <Form.Regist editable={editable} name="DataObject.HumanResourceClosedName" />

                    <Form.Field>
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>교육</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={Util.get(data, 'DataObject.HumanResourceTrainName')}
                            onChangeText={(text) => {
                                setValue('DataObject.HumanResourceTrainName', text, true);
                            }}
                        />
                    </Form.Field>
                    <Form.Regist editable={editable} name="DataObject.HumanResourceTrainName" />

                    <Form.Field>
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>출장</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={Util.get(data, 'DataObject.HumanResourceOutName')}
                            onChangeText={(text) => {
                                setValue('DataObject.HumanResourceOutName', text, true);
                            }}
                        />
                    </Form.Field>
                    <Form.Regist editable={editable} name="DataObject.HumanResourceOutName" />

                    <Form.Field>
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>당직</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={Util.get(data, 'DataObject.HumanResourceEtcName')}
                            onChangeText={(text) => {
                                setValue('DataObject.HumanResourceEtcName', text, true);
                            }}
                        />
                    </Form.Field>
                    <Form.Regist editable={editable} name="DataObject.HumanResourceEtcName" />

                    <Form.Field>
                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                            <Form.Label>현원</Form.Label>
                        </Form.Title>
                        <Form.Input
                            editable={editable}
                            defaultValue={Util.get(data, 'DataObject.HumanResourceCurrentName')}
                            onChangeText={(text) => {
                                setValue('DataObject.HumanResourceCurrentName', text, true);
                            }}
                        />
                    </Form.Field>
                    <Form.Regist editable={editable} name="DataObject.HumanResourceCurrentName" />
                </Form.FieldSet>

                {Util.get(data, 'DataObject.Energies') &&
                    Util.get(data, 'DataObject.Energies').map((energy, energyIndex) => {
                        return (
                            <Fragment key={`summary-${energyIndex}`}>
                                <Form.SeparateLine style={{ display: 'none' }}>
                                    <Form.SeparateLabel>{Util.get(energy, `FacilityTypeName`)}</Form.SeparateLabel>
                                </Form.SeparateLine>
                                <Form.Regist editable={editable} name={`DataObject.Energies[${energyIndex}].FacilityTypeName`} />

                                {Util.get(energy, 'List') &&
                                    Util.get(energy, 'List').map((item, itemIndex) => {
                                        return (
                                            <Fragment key={`item-${energyIndex}-${itemIndex}`}>
                                                <Form.FieldSetHead style={{ display: 'none' }}>
                                                    <Form.Legend>
                                                        <Form.LegendLabel>{Util.get(item, 'Name')}</Form.LegendLabel>
                                                    </Form.Legend>
                                                </Form.FieldSetHead>
                                                <Form.FieldSet style={{ display: 'none' }}>
                                                    <Form.Regist
                                                        editable={editable}
                                                        name={`DataObject.Energies[${energyIndex}].List[${itemIndex}].FacilityCode`}
                                                    />
                                                    <Form.Regist
                                                        editable={editable}
                                                        name={`DataObject.Energies[${energyIndex}].List[${itemIndex}].PropertyId`}
                                                    />
                                                    <Form.Regist
                                                        editable={editable}
                                                        name={`DataObject.Energies[${energyIndex}].List[${itemIndex}].Name`}
                                                    />

                                                    <Form.Field>
                                                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                                                            <Form.Label>금일</Form.Label>
                                                        </Form.Title>
                                                        <Form.Input
                                                            editable={editable}
                                                            defaultValue={Util.get(item, 'Today')}
                                                            onChangeText={(text) => {
                                                                setValue(
                                                                    `DataObject.Energies[${energyIndex}].List[${itemIndex}].Today`,
                                                                    text,
                                                                    true,
                                                                );
                                                            }}
                                                        />
                                                    </Form.Field>
                                                    <Form.Regist
                                                        editable={editable}
                                                        name={`DataObject.Energies[${energyIndex}].List[${itemIndex}].Today`}
                                                    />

                                                    <Form.Field>
                                                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                                                            <Form.Label>전일</Form.Label>
                                                        </Form.Title>
                                                        <Form.Input
                                                            editable={editable}
                                                            defaultValue={Util.get(item, 'DayBefore')}
                                                            onChangeText={(text) => {
                                                                setValue(
                                                                    `DataObject.Energies[${energyIndex}].List[${itemIndex}].DayBefore`,
                                                                    text,
                                                                    true,
                                                                );
                                                            }}
                                                        />
                                                    </Form.Field>
                                                    <Form.Regist
                                                        editable={editable}
                                                        name={`DataObject.Energies[${energyIndex}].List[${itemIndex}].DayBefore`}
                                                    />

                                                    <Form.Field>
                                                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                                                            <Form.Label>금일사용량</Form.Label>
                                                        </Form.Title>
                                                        <Form.Input
                                                            editable={editable}
                                                            defaultValue={Util.get(item, 'DailyUsage')}
                                                            onChangeText={(text) => {
                                                                setValue(
                                                                    `DataObject.Energies[${energyIndex}].List[${itemIndex}].DailyUsage`,
                                                                    text,
                                                                    true,
                                                                );
                                                            }}
                                                        />
                                                    </Form.Field>
                                                    <Form.Regist
                                                        editable={editable}
                                                        name={`DataObject.Energies[${energyIndex}].List[${itemIndex}].DailyUsage`}
                                                    />

                                                    <Form.Field>
                                                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                                                            <Form.Label>당월사용량</Form.Label>
                                                        </Form.Title>
                                                        <Form.Input
                                                            editable={editable}
                                                            defaultValue={Util.get(item, 'MonthUsage')}
                                                            onChangeText={(text) => {
                                                                setValue(
                                                                    `DataObject.Energies[${energyIndex}].List[${itemIndex}].MonthUsage`,
                                                                    text,
                                                                    true,
                                                                );
                                                            }}
                                                        />
                                                    </Form.Field>
                                                    <Form.Regist
                                                        editable={editable}
                                                        name={`DataObject.Energies[${energyIndex}].List[${itemIndex}].MonthUsage`}
                                                    />
                                                </Form.FieldSet>
                                            </Fragment>
                                        );
                                    })}

                                <Form.FieldSetHead style={{ borderColor: 'chocolate' }}>
                                    <Form.Legend style={{ backgroundColor: 'chocolate' }}>
                                        <Form.LegendLabel>{Util.get(energy, 'Total.Name')}</Form.LegendLabel>
                                    </Form.Legend>
                                </Form.FieldSetHead>
                                <Form.FieldSet>
                                    <Form.Regist editable={editable} name={`DataObject.Energies[${energyIndex}].FacilityTypeId`} />
                                    <Form.Regist editable={editable} name={`DataObject.Energies[${energyIndex}].Total.Name`} />

                                    <Form.Field>
                                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                                            <Form.Label>금일</Form.Label>
                                        </Form.Title>
                                        <Form.Input
                                            editable={editable}
                                            defaultValue={Util.get(energy, 'Total.Today')}
                                            onChangeText={(text) => {
                                                setValue(`DataObject.Energies[${energyIndex}].Total.Today`, text, true);
                                            }}
                                        />
                                    </Form.Field>
                                    <Form.Regist editable={editable} name={`DataObject.Energies[${energyIndex}].Total.Today`} />

                                    <Form.Field>
                                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                                            <Form.Label>전일</Form.Label>
                                        </Form.Title>
                                        <Form.Input
                                            editable={editable}
                                            defaultValue={Util.get(energy, 'Total.DayBefore')}
                                            onChangeText={(text) => {
                                                setValue(`DataObject.Energies[${energyIndex}].Total.DayBefore`, text, true);
                                            }}
                                        />
                                    </Form.Field>
                                    <Form.Regist editable={editable} name={`DataObject.Energies[${energyIndex}].Total.DayBefore`} />

                                    <Form.Field>
                                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                                            <Form.Label>금일사용량</Form.Label>
                                        </Form.Title>
                                        <Form.Input
                                            editable={editable}
                                            defaultValue={Util.get(energy, 'Total.DailyUsage')}
                                            onChangeText={(text) => {
                                                setValue(`DataObject.Energies[${energyIndex}].Total.DailyUsage`, text, true);
                                            }}
                                        />
                                    </Form.Field>
                                    <Form.Regist editable={editable} name={`DataObject.Energies[${energyIndex}].Total.DailyUsage`} />

                                    <Form.Field>
                                        <Form.Title style={{ justifyContent: 'flex-end' }}>
                                            <Form.Label>당월사용량</Form.Label>
                                        </Form.Title>
                                        <Form.Input
                                            editable={editable}
                                            defaultValue={Util.get(energy, 'Total.MonthUsage')}
                                            onChangeText={(text) => {
                                                setValue(`DataObject.Energies[${energyIndex}].Total.MonthUsage`, text, true);
                                            }}
                                        />
                                    </Form.Field>
                                    <Form.Regist editable={editable} name={`DataObject.Energies[${energyIndex}].Total.MonthUsage`} />
                                </Form.FieldSet>
                            </Fragment>
                        );
                    })}

                <Form.Field style={{ height: 100 }} />
            </Form.Container>
        </EmptyLayout>
    );
};
