Route::middleware('auth')->prefix('dashboard')->name('dash.')->group(function () {
Route::get('wallet', function () {
return Inertia::render('dashboard/wallet');
})->name('wallet');
});
import dash from '@/routes/dash';
const mainNavItems: NavItem[] = [
{
title: 'Wallet',
href: dash.wallet().url,
icon: LayoutGrid,
},
];
Route::middleware('auth')->prefix('api')->name('api.')->group(function () {
Route::prefix('dashboard')->name('dash.')->group(function () {
Route::controller(WalletApiController::class)->group(function(){
Route::prefix('wallet')->name('wallet.')->group(function(){
Route::get('history', 'showHistory')->name('history');
});
});
// Other API routes can be added here
});
});
import api from "@/routes/api";
useEffect(() => {
const fetchData = async () => {
try {
setIsLoading(true);
const res = await fetch(api.dash.wallet.history().url);
const result = await res.json();
if (result.code == 200) {
const data = result.data;
setItems(data);
} else {
toast.error(result.message, { description: result.code || '' });
}
} catch (error) {
console.error('Error:', error);
let message = "Something went wrong.";
if (error instanceof Error) {
message = error.message;
} else if (typeof error === "string") {
message = error;
}
toast.error(message);
} finally {
setIsLoading(false);
}
}
fetchData();
}, []);