import React, { useState } from 'react' import { Head, router } from '@inertiajs/react' import CustomerLayout from '@/Layouts/CustomerLayout' export default function Index({ auth: { user }, coins: { data, next_page_url }, }) { const [_coins, setCoins] = useState(data) const handleNextPage = () => { router.get( next_page_url, {}, { replace: true, preserveState: true, only: ['coins'], onSuccess: (res) => { setCoins(_coins.concat(res.props.coins.data)) }, } ) } return (
{user.fullname}
Coin
Rp {user.display_coin}
{_coins.map((coin) => (
router.get( route('customer.coin.show', coin.id) ) } >
{coin.format_human_created_at}
{coin.description}
{coin.amount}
))} {next_page_url !== null && (
Load more
)}
) }