mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-24 06:28:49 -05:00
97263a66cc
* add new zod schema for responses * add new client endpoints for responses * add services for responses and surveys * add new responses model to webhooks & email --------- Co-authored-by: Johannes <johannes@formbricks.com>
37 lines
1000 B
TypeScript
37 lines
1000 B
TypeScript
import { DisplayCreateRequest } from "@formbricks/types/js";
|
|
|
|
export const createDisplay = async (
|
|
displayCreateRequest: DisplayCreateRequest,
|
|
apiHost: string,
|
|
environmentId: string
|
|
): Promise<{ id: string }> => {
|
|
const res = await fetch(`${apiHost}/api/v1/client/environments/${environmentId}/displays`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(displayCreateRequest),
|
|
});
|
|
if (!res.ok) {
|
|
console.error(res.text);
|
|
throw new Error("Could not create display");
|
|
}
|
|
return await res.json();
|
|
};
|
|
|
|
export const markDisplayResponded = async (
|
|
displayId: string,
|
|
apiHost: string,
|
|
environmentId: string
|
|
): Promise<void> => {
|
|
const res = await fetch(
|
|
`${apiHost}/api/v1/client/environments/${environmentId}/displays/${displayId}/responded`,
|
|
{
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
}
|
|
);
|
|
if (!res.ok) {
|
|
throw new Error("Could not update display");
|
|
}
|
|
return;
|
|
};
|