You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
3.6 KiB
React

1 year ago
import React from 'react'
import { Head, router } from '@inertiajs/react'
1 year ago
import { HiChevronLeft, HiClipboardDocumentList } from 'react-icons/hi2'
import CustomerLayout from '@/Layouts/CustomerLayout'
1 year ago
import { PayButton } from './DetailPartials/PayButton'
import { FormUploadManual } from './DetailPartials/FormUploadManual'
import { FormUploadCashDeposit } from './DetailPartials/FormUploadCashDeposit'
import {
PAYMENT_CASH_DEPOSIT,
PAYMENT_MANUAL,
PAYMENT_MIDTRANS,
STATUS_REJECT,
1 year ago
STATUS_EXPIRED,
1 year ago
} from '@/constant'
1 year ago
import { handleCopyToClipboard } from '../utils'
const ActionSection = ({ deposit }) => {
1 year ago
if (deposit.is_valid === STATUS_EXPIRED) {
return (
<div className="w-full px-5">
<div className="my-5">
<div className="bg-red-50 text-red-700 p-3 border rounded-md">
Expired
</div>
</div>
</div>
)
}
if (deposit.is_valid === STATUS_REJECT) {
return (
<div className="w-full px-5">
<div className="my-5">
<div className="bg-red-50 text-red-700 p-3 border rounded-md">
{deposit.note}
</div>
</div>
</div>
)
}
1 year ago
return (
<div className="w-full">
1 year ago
{deposit.payment_channel === PAYMENT_MIDTRANS && <PayButton />}
{deposit.payment_channel === PAYMENT_MANUAL && <FormUploadManual />}
{deposit.payment_channel === PAYMENT_CASH_DEPOSIT && (
<FormUploadCashDeposit />
)}
</div>
)
}
export default function Detail({ deposit, back }) {
return (
<CustomerLayout>
<Head title="Top Up" />
<div className="flex flex-col min-h-[calc(95dvh)]">
<div
className="w-full px-5 py-5"
onClick={() => {
router.get(route(back))
}}
>
<HiChevronLeft className="font-bold h-5 w-5" />
</div>
{/* detail */}
1 year ago
<div className="flex flex-row items-center pb-5 border-b px-5">
<div className="w-full">
1 year ago
<div
className="font-semibold text-xl text-gray-400 flex flex-row items-center w-full"
onClick={() =>
handleCopyToClipboard(deposit.description)
}
>
<div>{deposit.description}</div>
<div className="pl-3 text-gray-400">
<HiClipboardDocumentList />
</div>
</div>
<div className="font-bold text-3xl">
{deposit.amount}
</div>
<div className="text-gray-400">
{deposit.format_created_at}
</div>
</div>
<div>
<div
1 year ago
className={`text-xs ${deposit.status.text_color} `}
>
{deposit.status.text}
</div>
</div>
</div>
{/* action */}
{deposit.is_valid !== 0 && <ActionSection deposit={deposit} />}
</div>
</CustomerLayout>
)
}