Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
22 lines
676 B
TypeScript
22 lines
676 B
TypeScript
'use client'
|
|
|
|
import { useCallback } from 'react'
|
|
|
|
import { useAsyncResource } from '@/hooks/useAsyncResource'
|
|
import { GET_ADMIN_USER_DETAIL } from '@/services/adminUserDetail'
|
|
|
|
export const useAdminUserDetail = (userId: string) => {
|
|
const load = useCallback(
|
|
async (signal: AbortSignal) => {
|
|
const result = await GET_ADMIN_USER_DETAIL(userId, { errorMode: 'silent', signal })
|
|
|
|
if (!result.ok) throw new Error(result.error.message || 'دریافت اطلاعات کاربر ناموفق بود')
|
|
|
|
return result.data
|
|
},
|
|
[userId]
|
|
)
|
|
|
|
return useAsyncResource(load, { cacheKey: `admin-user:${userId}`, enabled: Boolean(userId), retries: 1 })
|
|
}
|