feat(service): add public certificate data hook
Add new useCertificatePublicData hook to fetch certificate data from public endpoint without authentication. This hook combines user, team, submission, and winner data in a single request. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
da8b08cd73
commit
afaaff4a7f
@@ -15,6 +15,41 @@ interface User {
|
|||||||
updated_at?: string;
|
updated_at?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Certificate public data types
|
||||||
|
interface CertificateUserData {
|
||||||
|
id: string;
|
||||||
|
fullname: string;
|
||||||
|
email: string;
|
||||||
|
avatar?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CertificateTeamData {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
logo?: string;
|
||||||
|
is_leader: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CertificateSubmissionData {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
repository_url?: string;
|
||||||
|
demo_url?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CertificateWinnerData {
|
||||||
|
rank: number;
|
||||||
|
prize?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CertificatePublicData {
|
||||||
|
user: CertificateUserData;
|
||||||
|
team?: CertificateTeamData;
|
||||||
|
submission?: CertificateSubmissionData;
|
||||||
|
winner?: CertificateWinnerData;
|
||||||
|
}
|
||||||
|
|
||||||
// Update user request type
|
// Update user request type
|
||||||
interface UpdateUserRequest {
|
interface UpdateUserRequest {
|
||||||
fullname?: string;
|
fullname?: string;
|
||||||
@@ -118,3 +153,17 @@ export const useUserDetailsById = (userId: string) => {
|
|||||||
enabled: !!userId,
|
enabled: !!userId,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Public certificate data hook (no authentication required)
|
||||||
|
export const useCertificatePublicData = (userId: string, enabled = true) => {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ['certificate-public-data', userId],
|
||||||
|
queryFn: async () => {
|
||||||
|
const response = await hackathonApi.get<HackathonApiResponse<CertificatePublicData>>(
|
||||||
|
`/certificates/${userId}`
|
||||||
|
);
|
||||||
|
return { data: response.data.data };
|
||||||
|
},
|
||||||
|
enabled: enabled && !!userId,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user