- Restructured docker-compose for Nginx Proxy Manager (no custom nginx) - Added domain wordly.art configuration - Added Prometheus + Grafana monitoring stack with pre-configured dashboards - Added PostgreSQL backup script to NAS (daily/weekly/monthly rotation) - Added alert rules for backend, system, and Docker metrics - Updated deployment guide for NPM + IONOS DNS homelab setup - Added marketing plan document - PDF translator and watermark support - Enhanced middleware, routes, and translator modules Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
30 lines
926 B
TypeScript
30 lines
926 B
TypeScript
'use client';
|
|
|
|
import { useQuery, UseQueryResult } from '@tanstack/react-query';
|
|
import { useRouter } from 'next/navigation';
|
|
import { apiClient, ApiClientError } from '@/lib/apiClient';
|
|
import type { User } from './types';
|
|
|
|
export function useUser(): UseQueryResult<User, ApiClientError> {
|
|
const router = useRouter();
|
|
|
|
return useQuery({
|
|
queryKey: ['user', 'me'],
|
|
queryFn: async (): Promise<User> => {
|
|
const response = await apiClient.get<{ data: User; meta: Record<string, unknown> }>('/api/v1/auth/me');
|
|
return response.data;
|
|
},
|
|
retry: (failureCount, error) => {
|
|
if (error.status === 401) {
|
|
localStorage.removeItem('token');
|
|
localStorage.removeItem('refresh_token');
|
|
localStorage.removeItem('user');
|
|
router.push('/auth/login?redirect=/dashboard');
|
|
return false;
|
|
}
|
|
return failureCount < 2;
|
|
},
|
|
staleTime: 5 * 60 * 1000,
|
|
});
|
|
}
|