mirror of
https://github.com/walkxcode/dashboard-icons.git
synced 2025-10-27 05:29:03 +08:00
feat(hooks): add useExistingIconNames hook and clean up debug logs
- Add new useExistingIconNames hook for fetching community gallery icon names - Implement proper caching with 5-minute stale time - Remove debug console.log statements from useSubmissions hook - Improve code organization and reusability - Add proper error handling and retry configuration
This commit is contained in:
@@ -14,18 +14,13 @@ export function useSubmissions() {
|
|||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: submissionKeys.lists(),
|
queryKey: submissionKeys.lists(),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
console.log("🔍 Fetching submissions...")
|
|
||||||
const records = await pb.collection("submissions").getFullList<Submission>({
|
const records = await pb.collection("submissions").getFullList<Submission>({
|
||||||
sort: "-updated",
|
sort: "-updated",
|
||||||
expand: "created_by,approved_by",
|
expand: "created_by,approved_by",
|
||||||
requestKey: null,
|
requestKey: null,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log("📊 Fetched submissions:", records.length)
|
|
||||||
if (records.length > 0) {
|
if (records.length > 0) {
|
||||||
console.log("📋 First submission sample:", records[0])
|
|
||||||
console.log("👤 First submission created_by field:", records[0].created_by)
|
|
||||||
console.log("🔗 First submission expand data:", (records[0] as any).expand)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return records
|
return records
|
||||||
@@ -105,6 +100,28 @@ export function useRejectSubmission() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch existing icon names for the combobox
|
||||||
|
export function useExistingIconNames() {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["existing-icon-names"],
|
||||||
|
queryFn: async () => {
|
||||||
|
const records = await pb.collection("community_gallery").getFullList({
|
||||||
|
fields: "name",
|
||||||
|
sort: "name",
|
||||||
|
requestKey: null,
|
||||||
|
})
|
||||||
|
|
||||||
|
const uniqueNames = Array.from(new Set(records.map((r) => r.name)))
|
||||||
|
return uniqueNames.map((name) => ({
|
||||||
|
label: name,
|
||||||
|
value: name,
|
||||||
|
}))
|
||||||
|
},
|
||||||
|
staleTime: 5 * 60 * 1000, // 5 minutes
|
||||||
|
retry: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Check authentication status
|
// Check authentication status
|
||||||
export function useAuth() {
|
export function useAuth() {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
|
|||||||
Reference in New Issue
Block a user