import React, { useEffect } from 'react'
import { Head, Link, useForm } from '@inertiajs/react'
import { isEmpty } from 'lodash'
import {
STATUS_APPROVE,
STATUS_EXPIRED,
STATUS_REJECT,
STATUS_WAIT_APPROVE,
STATUS_WAIT_UPLOAD,
} from '@/constant'
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
import FormInput from '@/Components/FormInput'
import Button from '@/Components/Button'
import FormInputNumeric from '@/Components/FormInputNumeric'
import { formatIDR } from '@/utils'
export default function Form(props) {
const { deposit } = props
const { data, setData, post, processing, errors } = useForm({
debit: 0,
is_valid: '',
reject_reason: '',
})
const handleOnChange = (event) => {
setData(
event.target.name,
event.target.type === 'checkbox'
? event.target.checked
? 1
: 0
: event.target.value
)
}
const showForm =
+deposit.is_valid === STATUS_WAIT_APPROVE ||
+deposit.is_valid === STATUS_WAIT_UPLOAD
const handleSubmit = () => {
post(route('deposit.update', deposit))
}
useEffect(() => {
if (isEmpty(deposit) === false) {
setData({
debit: deposit.debit,
is_valid: deposit.is_valid,
reject_reason: deposit.reject_reason,
})
return
}
}, [deposit])
return (
Customer | : | {deposit.customer.name} |
Metode Pembayaran | : | {deposit.payment_channel} |
Bank Akun | : | {deposit.account.name} ( {deposit.account.bank_name}) |
Lokasi Cash / Setor Tunai | : | {deposit.deposit_location.name} |
Jumlah | : | {deposit.amount} |
Admin Fee | : | Rp {formatIDR(deposit.admin_fee)} |
Status | : | {deposit.status.text} |
Alasan Penolakan | : | {deposit.note} |
Approver | : | {deposit.editor.name} |
Tanggal | : | {deposit.format_created_at} |