import React, { useEffect } from 'react' import { Head, Link, useForm } from '@inertiajs/react' import { isEmpty } from 'lodash' import { STATUS_APPROVE, 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 { formatIDDate, formatIDR } from '@/utils' export default function Form(props) { const { deposit } = props const { data, setData, post, processing, errors } = useForm({ debit: 0, is_valid: 0, 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('paylater.repay.update', deposit)) } useEffect(() => { if (isEmpty(deposit) === false) { setData({ debit: deposit.debit, is_valid: deposit.is_valid, reject_reason: deposit.reject_reason, }) return } }, [deposit]) return (
{deposit.description}
{deposit.account !== null && ( )} {deposit.deposit_location !== null && ( )} {isEmpty(deposit.editor) === false && ( )} {isEmpty(deposit.paylater.next_payment) === false && ( )}
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}
Pembayaran Hutang : {isEmpty( deposit.paylater .not_fullpayment_reason ) === false ? (

Sebagian

) : (

Penuh

)}
Tanggal Pemenuhan : {formatIDDate( deposit.paylater.next_payment )}
{isEmpty(deposit.image_prove_url) === false && (
)} {showForm && ( <>
Status
{errors.status && (
{errors.status}
)} {errors.reject_reason && (
{errors.reject_reason}
)}
{+data.is_valid === STATUS_REJECT && ( )}
)}
) }