fix: Dry run in prerender flow (#21876)
* fix dry run in queued flow * All zeros uuid
This commit is contained in:
@@ -177,15 +177,23 @@ const _handleResponse = async ({
|
||||
}
|
||||
} else {
|
||||
moduleLogger.debug("Dry run mode - Form response not stored and also webhooks and emails not sent");
|
||||
// Create a mock response for dry run
|
||||
dbFormResponse = {
|
||||
id: 0,
|
||||
formId: form.id,
|
||||
response,
|
||||
chosenRouteId,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
if (queueFormResponse) {
|
||||
queuedFormResponse = {
|
||||
id: "00000000-0000-0000-0000-000000000000",
|
||||
formId: form.id,
|
||||
response,
|
||||
};
|
||||
} else {
|
||||
// Create a mock response for dry run
|
||||
dbFormResponse = {
|
||||
id: 0,
|
||||
formId: form.id,
|
||||
response,
|
||||
chosenRouteId,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
}
|
||||
}
|
||||
return {
|
||||
isPreview: !!isPreview,
|
||||
|
||||
@@ -455,7 +455,9 @@ export const methods = {
|
||||
|
||||
// We now record the response to routingFormResponse and connect that with queuedResponse, as the user actually opened the modal which is confirmed by this connect method call
|
||||
const newlyRecordedResponseId = await recordResponseIfQueued(params);
|
||||
if (!newlyRecordedResponseId) {
|
||||
// Allow 0 which is for dry run
|
||||
// Negative values are not possible
|
||||
if (typeof newlyRecordedResponseId !== "number") {
|
||||
return;
|
||||
}
|
||||
await ensureRoutingFormResponseIdInUrl({
|
||||
|
||||
@@ -39,6 +39,10 @@ export const recordResponseIfQueued = async (params: Record<string, string | str
|
||||
if (!queuedFormResponseId) {
|
||||
return null;
|
||||
}
|
||||
// Corresponding dry run value for routingFormResponseId is 0
|
||||
if (queuedFormResponseId === "00000000-0000-0000-0000-000000000000") {
|
||||
return 0;
|
||||
}
|
||||
// form is formId and isn't acutal Form data
|
||||
const { form: _1, ...actualFormData } = params;
|
||||
const res = await fetch(`/api/routing-forms/queued-response`, {
|
||||
|
||||
Reference in New Issue
Block a user