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.
84 lines
3.2 KiB
React
84 lines
3.2 KiB
React
1 year ago
|
import React, { useState } from 'react'
|
||
|
import { Head, router } from '@inertiajs/react'
|
||
|
import CustomerLayout from '@/Layouts/CustomerLayout'
|
||
|
|
||
|
export default function Index({
|
||
|
auth: { user },
|
||
1 year ago
|
poins: { data, next_page_url },
|
||
1 year ago
|
}) {
|
||
1 year ago
|
const [_poins, setpoins] = useState(data)
|
||
1 year ago
|
|
||
|
const handleNextPage = () => {
|
||
|
router.get(
|
||
|
next_page_url,
|
||
|
{},
|
||
|
{
|
||
|
replace: true,
|
||
|
preserveState: true,
|
||
1 year ago
|
only: ['poins'],
|
||
1 year ago
|
onSuccess: (res) => {
|
||
1 year ago
|
setpoins(_poins.concat(res.props.poins.data))
|
||
1 year ago
|
},
|
||
|
}
|
||
|
)
|
||
|
}
|
||
|
|
||
|
return (
|
||
|
<CustomerLayout>
|
||
1 year ago
|
<Head title="poin" />
|
||
1 year ago
|
<div className="flex flex-col w-full min-h-[calc(90dvh)]">
|
||
|
<div className="w-full pt-10 px-5">
|
||
|
<div className="text-base">{user.fullname}</div>
|
||
|
</div>
|
||
|
<div className="flex flex-row justify-between items-center pb-10 border-b px-5">
|
||
|
<div>
|
||
|
<div className="font-semibold text-xl text-gray-400">
|
||
1 year ago
|
poin
|
||
1 year ago
|
</div>
|
||
|
<div className="font-bold text-3xl">
|
||
1 year ago
|
{user.display_poin}
|
||
1 year ago
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div className="w-full">
|
||
|
<div className="flex flex-col py-10 space-y-5 px-5">
|
||
1 year ago
|
{_poins.map((poin) => (
|
||
1 year ago
|
<div
|
||
1 year ago
|
key={poin.id}
|
||
1 year ago
|
className="flex flex-row pb-2 items-center justify-between border-b"
|
||
|
onClick={() =>
|
||
|
router.get(
|
||
1 year ago
|
route('customer.poin.show', poin.id)
|
||
1 year ago
|
)
|
||
|
}
|
||
|
>
|
||
|
<div className="flex flex-col">
|
||
|
<div className="font-bold">
|
||
1 year ago
|
{poin.format_human_created_at}
|
||
1 year ago
|
</div>
|
||
|
<div className="font-thin">
|
||
1 year ago
|
{poin.description}
|
||
1 year ago
|
</div>
|
||
|
</div>
|
||
|
<div className="flex flex-col items-end">
|
||
|
<div className="font-bold text-lg">
|
||
1 year ago
|
{poin.amount}
|
||
1 year ago
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
))}
|
||
|
{next_page_url !== null && (
|
||
|
<div
|
||
|
onClick={handleNextPage}
|
||
|
className="w-full text-center px-2 py-1 border mt-5 hover:bg-blue-600 hover:text-white"
|
||
|
>
|
||
|
Load more
|
||
|
</div>
|
||
|
)}
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</CustomerLayout>
|
||
|
)
|
||
|
}
|