Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 105x 2x 2x 105x 105x 1x 1x 105x | import { useQuery } from "@tanstack/react-query";
import { API } from "aws-amplify";
import { FormSchema, ReactQueryApiError } from "shared-types";
import { reInsertRegex } from "shared-utils";
export const getForm = async (formId: string, formVersion?: string): Promise<FormSchema> => {
const form = await API.post("os", "/forms", {
body: { formId, formVersion },
});
return reInsertRegex(form);
};
export const useGetForm = (formId: string, formVersion?: string) => {
return useQuery<FormSchema, ReactQueryApiError>([formId, formVersion], () =>
getForm(formId, formVersion),
);
};
export type ResultObject = {
[formId: string]: string[];
};
export const getAllForms = async () => {
const results = await API.get("os", "/allForms", {});
return results;
};
export const useGetAllForms = () => {
return useQuery<ResultObject, ReactQueryApiError>(["All Webforms"], () => getAllForms());
};
|