Allow use of useCurrentUser/useCurrentTeam hooks in unauthenticated components
This commit is contained in:
@@ -17,6 +17,7 @@ import Modal from "~/components/Modal";
|
||||
import PaginatedList from "~/components/PaginatedList";
|
||||
import Text from "~/components/Text";
|
||||
import useBoolean from "~/hooks/useBoolean";
|
||||
import useCurrentTeam from "~/hooks/useCurrentTeam";
|
||||
import useStores from "~/hooks/useStores";
|
||||
|
||||
type Props = {
|
||||
@@ -29,11 +30,11 @@ function AddGroupsToCollection(props: Props) {
|
||||
const [newGroupModalOpen, handleNewGroupModalOpen, handleNewGroupModalClose] =
|
||||
useBoolean(false);
|
||||
const [query, setQuery] = React.useState("");
|
||||
|
||||
const { auth, collectionGroupMemberships, groups, policies } = useStores();
|
||||
const { fetchPage: fetchGroups } = groups;
|
||||
|
||||
const team = useCurrentTeam();
|
||||
const { collectionGroupMemberships, groups, policies } = useStores();
|
||||
const { t } = useTranslation();
|
||||
const { fetchPage: fetchGroups } = groups;
|
||||
const can = policies.abilities(team.id);
|
||||
|
||||
const debouncedFetch = React.useMemo(
|
||||
() => debounce((query) => fetchGroups({ query }), 250),
|
||||
@@ -65,13 +66,6 @@ function AddGroupsToCollection(props: Props) {
|
||||
}
|
||||
};
|
||||
|
||||
const { user, team } = auth;
|
||||
if (!user || !team) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const can = policies.abilities(team.id);
|
||||
|
||||
return (
|
||||
<Flex column>
|
||||
{can.createGroup ? (
|
||||
|
||||
Reference in New Issue
Block a user