Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function Display({ currentOrganizationId, currentOrganization, create }) {
const { history } = useRouter();
const { dataStore } = useOrbit();
const { t } = useTranslations();
const [disableSubmit, setDisableSubmit] = useState(false);
const [groupId, setGroupId] = useState();
const [jsonfile, setJsonfile] = useState(null);
const [typeId, setTypeId] = useState();
const { currentUser } = useCurrentUser();
useEffect(() => {
setGroupId(undefined);
}, [currentOrganizationId]);
const areAllRequiredFieldsPresent = useCallback(() => {
return !isEmpty(jsonfile) && !isEmpty(groupId) && !isEmpty(typeId);
}, [jsonfile, groupId, typeId]);
const isSaveDisabled = disableSubmit || !areAllRequiredFieldsPresent();
export default function Display({ currentOrganizationId, currentOrganization, create }) {
const { history } = useRouter();
const { dataStore } = useOrbit();
const { t } = useTranslations();
const [disableSubmit, setDisableSubmit] = useState(false);
const [isPublic, setIsPublic] = useToggle(true);
const [groupId, setGroupId] = useState();
const [language, setLanguage] = useState('');
const [description, setDescription] = useState('');
const [typeId, setTypeId] = useState();
const [name, setName] = useState('');
useEffect(() => {
setGroupId(undefined);
}, [currentOrganizationId]);
const areAllRequiredFieldsPresent = useCallback(() => {
return !isEmpty(name) && !isEmpty(groupId) && !isEmpty(language) && !isEmpty(typeId);
}, [name, groupId, language, typeId]);
export function useCurrentOrganization() {
const { history } = useRouter();
const { currentUser, isSuperAdmin } = useCurrentUser();
const {
dataStore,
subscriptions: { all },
} = useOrbit({
all: (q) => q.findRecords('organization'),
});
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);
}