Add useGroupLookup hook
This commit is contained in:
17
app/soapbox/hooks/api/groups/useGroupLookup.ts
Normal file
17
app/soapbox/hooks/api/groups/useGroupLookup.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { Entities } from 'soapbox/entity-store/entities';
|
||||
import { useEntityLookup } from 'soapbox/entity-store/hooks';
|
||||
import { useApi } from 'soapbox/hooks/useApi';
|
||||
import { groupSchema } from 'soapbox/schemas';
|
||||
|
||||
function useGroupLookup(slug: string) {
|
||||
const api = useApi();
|
||||
|
||||
return useEntityLookup(
|
||||
Entities.GROUPS,
|
||||
(group) => group.slug === slug,
|
||||
() => api.get(`/api/v1/groups/lookup?name=${slug}`),
|
||||
{ schema: groupSchema },
|
||||
);
|
||||
}
|
||||
|
||||
export { useGroupLookup };
|
||||
Reference in New Issue
Block a user