mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-30 11:41:05 -05:00
fix: nocodeForm not accessible from the outside
This commit is contained in:
@@ -15,6 +15,20 @@ export const useNoCodeForm = (formId) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const useNoCodeFormPublic = (formId) => {
|
||||
const { data, error, mutate } = useSWR(
|
||||
`/api/public/forms/${formId}/nocodeform`,
|
||||
fetcher
|
||||
);
|
||||
|
||||
return {
|
||||
noCodeForm: data,
|
||||
isLoadingNoCodeForm: !error && !data,
|
||||
isErrorNoCodeForm: error,
|
||||
mutateNoCodeForm: mutate,
|
||||
};
|
||||
};
|
||||
|
||||
export const createNoCodeForm = async (formId) => {
|
||||
try {
|
||||
const res = await fetch(`/api/forms/${formId}/nocodeform`, {
|
||||
|
||||
+15
-1
@@ -1,7 +1,21 @@
|
||||
import intlFormat from "date-fns/intlFormat";
|
||||
import { formatDistance } from "date-fns";
|
||||
|
||||
export const fetcher = (url) => fetch(url).then((res) => res.json());
|
||||
export const fetcher = async (url) => {
|
||||
const res = await fetch(url);
|
||||
|
||||
// If the status code is not in the range 200-299,
|
||||
// we still try to parse and throw it.
|
||||
if (!res.ok) {
|
||||
const error: any = new Error("An error occurred while fetching the data.");
|
||||
// Attach extra info to the error object.
|
||||
error.info = await res.json();
|
||||
error.status = res.status;
|
||||
throw error;
|
||||
}
|
||||
|
||||
return res.json();
|
||||
};
|
||||
|
||||
export const shuffle = (array) => {
|
||||
array = [...array];
|
||||
|
||||
Reference in New Issue
Block a user