Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const [store, dispatch] = useRedux();
const { currentOrganizationId } = store.data;
const currentUserOrganizations = retrieveRelation(dataStore, [
currentUser,
'organizationMemberships',
'organization',
]);
let organizationsAvailableToUser = currentUserOrganizations;
if (isSuperAdmin && all) {
organizationsAvailableToUser = _.uniqBy([...currentUserOrganizations, ...all], (org) => org.id);
}
const localId = localIdFromRecordIdentity(dataStore, {
type: 'organization',
id: currentOrganizationId,
});
let currentOrganization = useMemo(() => {
try {
if (currentOrganizationId) {
return dataStore.cache.query((q) => q.findRecord({ type: 'organization', id: localId }));
}
} catch (e) {
// if the current user is a super admin, this org has not yet
// been added to the cache
console.warn(`org not found for ${currentOrganizationId}`, e);
}
}, [currentOrganizationId, dataStore.cache, localId]);