add: full auth functionality
add: zustand auth store add: jwt auto refresh
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
"use client"
|
||||
|
||||
import { ReactQueryProvider } from '@/components/providers/ReactQueryProvider'
|
||||
|
||||
export default function ProfileLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<ReactQueryProvider>
|
||||
<div className="min-h-screen grid">
|
||||
{children}
|
||||
</div>
|
||||
</ReactQueryProvider>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
"use client";
|
||||
|
||||
import { useProfile } from '@/hooks/auth/useProfile';
|
||||
import { useAuthStore } from '@/zustand/authStore';
|
||||
import React, { useEffect } from 'react'
|
||||
|
||||
type Props = object
|
||||
|
||||
function ProfileIndex({ }: Props) {
|
||||
const isAuthenticated = useAuthStore((state) => state.isAuthenticated);
|
||||
|
||||
const { mutate, data, isPending } = useProfile();
|
||||
|
||||
useEffect(() => {
|
||||
if (isAuthenticated) {
|
||||
mutate();
|
||||
}
|
||||
}, [isAuthenticated])
|
||||
|
||||
return (
|
||||
<div>
|
||||
{isPending && 'Loading...'}
|
||||
<br />
|
||||
{data && JSON.stringify(data)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ProfileIndex
|
||||
Reference in New Issue
Block a user