How to use the react-orbitjs.useQuery 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 / admin / settings / stores / -components / form.tsx View on Github external
export default function StoreForm({ save, cancel, store }) {
  const { t } = useTranslations();
  const { dataStore } = useOrbit();

  const {
    result: { storeTypes },
  } = useQuery({ storeTypes: [(q) => q.findRecords('storeType'), buildOptions()] });

  const attributes = attributesFor(store || {});
  const isEditing = !!store;

  const existingStoreType = useMemo(() => getStoreType(dataStore, store), [dataStore, store]);

  // Form States
  const [name, setName] = useState(attributes.name || '');
  const [storeType, setStoreType] = useState(existingStoreType);
  const [description, setDescription] = useState(attributes.description || '');
  const [errors, setError] = useState>({});
  // End Form States

  const onSubmit = async (e) => {
    e.preventDefault();
    e.stopPropagation();
github sillsdev / appbuilder-portal / source / SIL.AppBuilder.Portal.Frontend / src / ui / routes / projects / show / with-data.tsx View on Github external
return function ProjectDataFetcher(props) {
    const { match } = useRouter();
    const {
      params: { id },
    } = match;

    const {
      isLoading,
      error,
      result: { project },
    } = useQuery({
      project: [
        (q) => buildFindRecord(q, 'project', id),
        buildOptions({
          include: [
            'products.product-builds.product-artifacts',
            'products.product-builds.product-publications',
            'products.user-tasks.user',
            // 'products.user-tasks.product.product-definition.workflow',
            'products.product-definition',
            // 'products.product-workflow',
            'organization.organization-product-definitions.product-definition.workflow.store-type',
            'group',
            'owner.group-memberships.group',
            'owner.organization-memberships.organization',
            'reviewers',
            'type',
github sillsdev / appbuilder-portal / source / SIL.AppBuilder.Portal.Frontend / src / ui / routes / admin / settings / stores / edit.tsx View on Github external
export default function EditForm() {
  const { t } = useTranslations();
  const { update } = useDataActions();
  const { history, match } = useRouter();
  const { id } = match.params || {};

  const {
    result: { store },
    isLoading,
  } = useQuery({
    store: [(q) => buildFindRecord(q, 'store', id), buildOptions({ include: ['store-type'] })],
  });

  if (isLoading) {
    return ;
  }

  const save = async (attributes, relationships) => {
    await update(store, attributes, relationships);

    toast.success(t('models.updateSuccess', { name: t('stores.name') }));

    history.push(paths.settings.stores.path());
  };
  const cancel = () => {
    history.push(paths.settings.stores.path());
github sillsdev / appbuilder-portal / source / SIL.AppBuilder.Portal.Frontend / src / data / containers / resources / user-task / list.tsx View on Github external
export function useUserTasksList(include?: string[]) {
  const requestOptions = buildOptions({
    include: include || defaultInclude,
  });
  const queryTask = useQuery({
    userTasks: [
      (q) => {
        const builder = q.findRecords('userTask');

        return builder;
      },
      requestOptions,
    ],
  });

  return { ...queryTask, userTasks: queryTask.result.userTasks };
}