mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-05 13:20:03 -06:00
formbricks-com make waitlist submission synchronous again, add warmup request
This commit is contained in:
@@ -17,6 +17,13 @@ export function Survey({ survey, formbricksUrl, formId }: SurveyProps) {
|
||||
|
||||
const schema = useMemo(() => generateSchema(survey), [survey]);
|
||||
|
||||
useEffect(() => {
|
||||
// warmup request
|
||||
fetch(`${formbricksUrl}/api/capture/forms/${formId}/submissions`, {
|
||||
method: "OPTIONS",
|
||||
});
|
||||
});
|
||||
|
||||
const navigateToNextPage = (currentSubmission: any) => {
|
||||
const nextPage = calculateNextPage(survey, currentSubmission);
|
||||
setCurrentPage(nextPage);
|
||||
|
||||
@@ -93,8 +93,7 @@ export function SurveyPage({
|
||||
const updatedSubmission = { ...submission, ...data };
|
||||
setSubmission(updatedSubmission);
|
||||
try {
|
||||
sendToFormbricks(data);
|
||||
await waitForAnimation(400);
|
||||
await sendToFormbricks(data);
|
||||
setSubmittingPage(false);
|
||||
onSubmit(updatedSubmission);
|
||||
plausible(`waitlistSubmitPage-${page.id}`);
|
||||
@@ -104,9 +103,6 @@ export function SurveyPage({
|
||||
}
|
||||
};
|
||||
|
||||
// set timeout promise
|
||||
const waitForAnimation = (ms: number) => new Promise((res) => setTimeout(res, ms));
|
||||
|
||||
const handleSubmitElement = () => {
|
||||
if (page.config?.autoSubmit && page.elements.length == 1) {
|
||||
formRef.current?.requestSubmit();
|
||||
|
||||
Reference in New Issue
Block a user