How to use the react-orbitjs/dist.useOrbit function in react-orbitjs

To help you get started, we’ve selected a few react-orbitjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sillsdev / appbuilder-portal / source / SIL.AppBuilder.Portal.Frontend / src / ui / routes / projects / import / display.tsx View on Github external
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();
github sillsdev / appbuilder-portal / source / SIL.AppBuilder.Portal.Frontend / src / ui / routes / projects / new / display.tsx View on Github external
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]);
github sillsdev / appbuilder-portal / source / SIL.AppBuilder.Portal.Frontend / src / data / containers / with-current-organization / hook.ts View on Github external
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);
  }