PostMoney.js 3.58 KB
Newer Older
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, { useState } from 'react';
import { View, Text, StyleSheet, Button } from 'react-native';
import InputBox from './components/InputBox';
import ButtonsForm from './components/ButtonsForm';
import SelectForm from './components/SelectForm';
import StyledButton from './components/StyledButton';

const INIT_ASSET_TYPE = [
    {
        asset_id: '1',
        asset_name: '농협',
    },
    {
        asset_id: '2',
        asset_name: '신한',
    },
]

const INIT_CATEGORIES = [
    {
        category_id: '1',
        category_name: '식비',
    },
    {
        category_id: '2',
        category_name: '문화',
    },
    {
        category_id: '3',
        category_name: '교통비',
    },
    {
        category_id: '4',
        category_name: '기타',
    },
]

const PostMoney = () => {
    const [selectedIndex, setSelectedIndex] = useState(0)
    const [contents, setContents] = useState('')
    const [price, setPrice] = useState(0)
    const [asset_type, setAsset_type] = useState(INIT_ASSET_TYPE)
    const [selected_asset_type, setSelected_asset_type] = useState(INIT_ASSET_TYPE[0])
    const [categories, setCategories] = useState(INIT_CATEGORIES)
    const [selected_cat, setSelected_cat] = useState(INIT_CATEGORIES[0])

    console.log('입력 데이터 : ', selectedIndex, contents, price, selected_asset_type, selected_cat)

    return (
        <View>
            <View>
                <ButtonsForm
                    onPress={(index) => setSelectedIndex(index)}
                    selectedIndex={selectedIndex}
                    group={["수입", "지출", "이동"]} />
                <InputBox
                    inputTitle="내용"
                    placeholder="내용을 입력하세요"
                    onChangeText={
                        (contents) => setContents(contents)
                    }
                    maxLength={30}
                />
                <InputBox
                    inputTitle="금액"
                    placeholder="금액을 입력하세요"
                    onChangeText={
                        (price) => setPrice(price)
                    }
                    keyboardType="numeric"
                    maxLength={30}
                />
                <SelectForm
                    inputTitle="자산"
                    categories={asset_type}
                    selectedValue={selected_asset_type}
                    onValueChange={(itemValue, itemIndex) => setSelected_asset_type(itemValue)}
                />
                <SelectForm
                    inputTitle="구분"
                    categories={categories}
                    selectedValue={selected_cat}
                    onValueChange={(itemValue, itemIndex) => setSelected_cat(itemValue)}
                />
            </View>
            <View style={style.buttonRow}>
                <StyledButton
                    name="저장하기"
                    onPress={() => console.log('저장버튼')}
                    style={style.submitButton}
                />
                <StyledButton
                    name="취소"
                    onPress={() => console.log('취소버튼')}
                    style={style.cancelButton}
                />
            </View>
        </View>
    )
}

const style = StyleSheet.create({
    Font: {
        fontSize: 24
    },
    buttonRow: {
        flexDirection: 'row',
        alignItems: "center",
        marginHorizontal: 10,
        marginVertical: 3,
    },
    submitButton: {
        flex: 3,
        height: 50,
    },
    cancelButton: {
        flex: 1,
        height: 50,
    }
});

export default PostMoney;