import React, { useEffect, useState } from 'react'; import { StyleSheet, View, Text, Button, Pressable, TouchableWithoutFeedback, Keyboard } from 'react-native'; import { globalStyles } from '../styles/global'; import InputBox from '../components/InputBox'; import StyledButton from '../components/StyledButton'; import DatePicker from '../components/DatePicker.js'; import deptApi from '../db/deptPage.api'; function DeptDetails({ route, navigation }) { const { item, loadLoan } = route.params const getDate = () => { var date = new Date(); return (String(date.toJSON()).split(/T/)[0]) } const [date, setDate] = useState(getDate()) const [message, setMessage] = useState('') const [money, setMoney] = useState('') const [remained_money, setRemained_money] = useState('') useEffect(() => { setDate(String(item.date)) setMessage(item.message) setMoney(String(item.money)) setRemained_money(String(item.remained_money)) }, []) const onUpdateHandle = async () => { await deptApi.updateDept({ date, message, money, remained_money }, item.id) loadLoan() navigation.navigate('DeptPage') } return ( { Keyboard.dismiss(); }}> setMessage(message) } /> setMoney(money) } /> setRemained_money(remained_money) } /> { onUpdateHandle() }} style={style.submitButton} /> ) } const style = StyleSheet.create({ Font: { fontFamily: 'GowunDodum-Regular' }, buttonRow: { fontFamily: 'GowunDodum-Regular', flexDirection: 'row', alignItems: "center", marginHorizontal: 10, marginVertical: 3, }, submitButton: { flex: 1, height: 50, }, cancelButton: { flex: 1, height: 50, } }); export default DeptDetails;