import React, { useState, useEffect } from 'react' import { router, useForm, usePage } from '@inertiajs/react' import { HiOutlineClipboardDocumentList } from 'react-icons/hi2' import { isEmpty } from 'lodash' import { toastSuccess } from '@/Customer/utils' import { formatIDR } from '@/utils' import FormFile from '@/Components/FormFile' import Alert from '@/Components/Alert' export const FormUploadManual = () => { const { props: { accounts, deposit, flash, bank_admin_fee }, } = usePage() const [imageUrl, setImageUrl] = useState(deposit.image_prove_url) const [account, setAccount] = useState(null) const { data, setData, errors, processing, post } = useForm({ account_id: '', image: null, image_url: deposit.image_prove_url, }) const handleSelectAccount = (id) => { if (id === '') { setData('account_id', '') setAccount(null) return } const account = accounts.find((acc) => acc.id === id) setData('account_id', account.id) setAccount(account) } const handleCopyToClipboard = (text) => { toastSuccess('copied to clipboard') navigator.clipboard.writeText(text) } const handleSubmit = () => { if (processing) { return } post(route('transactions.deposit.update', deposit), { replace: true, preserveState: true, onSuccess: () => setTimeout( () => router.get(route(route().current(), deposit)), 3000 ), }) } useEffect(() => { if (deposit.account !== null) { handleSelectAccount(deposit.account.id) } }, [deposit]) if (isEmpty(imageUrl) == false) { return (
Jumlah Deposit | : | {deposit.amount} | |
Biaya Admin | : | {+bank_admin_fee === 0 ? ( 'Gratis' ) : ( <> Rp.{' '} {formatIDR( +bank_admin_fee )} > )} | |
Total Transfer | : | Rp.{' '} {formatIDR( +bank_admin_fee + +deposit.debit )} |
|