'use client';

import { useQuery } from '@tanstack/react-query';
import { getUserData } from '@/app/lib/action';

export default function HomePage() {
	const {
		data: userData,
		isLoading,
		isError,
		error,
	} = useQuery({
		queryKey: ['userData'],
		queryFn: () => {
			return getUserData();
		},
	});

	if (isLoading) return <div>Loading...</div>;
	if (isError) return <div>Error: {error.message}</div>;

	return (
		<div>
			<h1>user email</h1>
			<span>
				{userData.email}
			</span>
		</div>
	);
}