MCPcopy Create free account
hub / github.com/dailydotdev/apps / useGetSquadAwardAdmin

Function useGetSquadAwardAdmin

packages/shared/src/hooks/useCoresFeature.ts:53–75  ·  view source on GitHub ↗
(
  props: UseGetSquadAwardAdminProps,
)

Source from the content-addressed store, hash-verified

51}
52
53export const useGetSquadAwardAdmin = (
54 props: UseGetSquadAwardAdminProps,
55): UserShortProfile | null | undefined => {
56 const hasAccess = useCoresFeature();
57
58 if (
59 props.squad.currentMember?.role === SourceMemberRole.Admin ||
60 !hasAccess
61 ) {
62 return null;
63 }
64
65 // Return the first user that's eligible for cores
66 return props.squad?.privilegedMembers?.find((receivingUser: SourceMember) => {
67 if (receivingUser.role !== SourceMemberRole.Admin) {
68 return false;
69 }
70 return canAwardUser({
71 sendingUser: props.sendingUser,
72 receivingUser: receivingUser.user as unknown as LoggedUser,
73 });
74 })?.user;
75};
76
77export const useCanPurchaseCores = (): boolean => {
78 const hasAccess = useHasAccessToCores();

Callers 1

SquadAwardButtonFunction · 0.90

Calls 2

canAwardUserFunction · 0.90
useCoresFeatureFunction · 0.85

Tested by

no test coverage detected