Function: useUserEndorsement()
useUserEndorsement(
preprintUri,userDid,options):UseQueryResult<null| {comment:string;contributions: ("data"|"methodological"|"analytical"|"theoretical"|"empirical"|"conceptual"|"technical"|"replication"|"reproducibility"|"synthesis"|"interdisciplinary"|"pedagogical"|"visualization"|"societal-impact"|"clinical")[];createdAt:string;endorser: {avatar:string;did:string;displayName:string;handle:string; };preprintUri:string;updatedAt:string;uri:string; },Error>
Defined in: web/lib/hooks/use-endorsement.ts:287
Checks if a user has endorsed a preprint.
Parameters
preprintUri
string
AT-URI of the preprint
userDid
string
DID of the user to check
options
UseEndorsementsOptions = {}
Hook options
Returns
UseQueryResult<null | { comment: string; contributions: ("data" | "methodological" | "analytical" | "theoretical" | "empirical" | "conceptual" | "technical" | "replication" | "reproducibility" | "synthesis" | "interdisciplinary" | "pedagogical" | "visualization" | "societal-impact" | "clinical")[]; createdAt: string; endorser: { avatar: string; did: string; displayName: string; handle: string; }; preprintUri: string; updatedAt: string; uri: string; }, Error>
Query result with user's endorsement or null
Remarks
Returns the user's endorsement if it exists, or null if not. Useful for showing/hiding the endorsement form and displaying user's existing endorsement.
Example
const { data: userEndorsement, isLoading } = useUserEndorsement(
preprintUri,
currentUser.did
);
if (userEndorsement) {
return <YourEndorsement endorsement={userEndorsement} />;
}
return <EndorsementForm preprintUri={preprintUri} />;