mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-19 11:11:05 -05:00
fix: advanced logic data migration
This commit is contained in:
@@ -53,10 +53,6 @@ const extractResponseData = (response: TResponse, survey: TSurvey): Record<strin
|
||||
responseData[fieldId] = response.data[fieldId];
|
||||
});
|
||||
|
||||
survey.variables.forEach((variable) => {
|
||||
responseData[variable.id] = response.variables[variable.id];
|
||||
});
|
||||
|
||||
return responseData;
|
||||
};
|
||||
|
||||
@@ -68,6 +64,9 @@ const mapResponsesToTableData = (responses: TResponse[], survey: TSurvey): TResp
|
||||
responseId: response.id,
|
||||
tags: response.tags,
|
||||
notes: response.notes,
|
||||
variables: survey.variables.reduce((acc, curr) => {
|
||||
return Object.assign(acc, { [curr.id]: response.variables[curr.id] });
|
||||
}, {}),
|
||||
verifiedEmail: typeof response.data["verifiedEmail"] === "string" ? response.data["verifiedEmail"] : "",
|
||||
language: response.language,
|
||||
}));
|
||||
@@ -86,9 +85,8 @@ export const ResponseDataView: React.FC<ResponseDataViewProps> = ({
|
||||
updateResponse,
|
||||
isFetchingFirstPage,
|
||||
}) => {
|
||||
console.log({ responses, survey });
|
||||
const data = mapResponsesToTableData(responses, survey);
|
||||
console.log({ data });
|
||||
|
||||
return (
|
||||
<div className="w-full">
|
||||
<ResponseTable
|
||||
|
||||
@@ -232,7 +232,7 @@ export const generateColumns = (
|
||||
</div>
|
||||
),
|
||||
cell: ({ row }) => {
|
||||
const variableResponse = row.original.responseData[variable.id];
|
||||
const variableResponse = row.original.variables[variable.id];
|
||||
if (typeof variableResponse === "string" || typeof variableResponse === "number") {
|
||||
return <div className="text-slate-900">{variableResponse}</div>;
|
||||
}
|
||||
|
||||
@@ -213,7 +213,15 @@ function convertLogic(
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const actionTarget = oldLogic.destination === "end" ? surveyEndings[0].id : oldLogic.destination;
|
||||
let actionTarget = oldLogic.destination;
|
||||
|
||||
if (actionTarget === "end") {
|
||||
if (surveyEndings.length > 0) {
|
||||
actionTarget = surveyEndings[0].id;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
const action: TAction = {
|
||||
id: createId(),
|
||||
|
||||
@@ -342,6 +342,7 @@ export const ZResponseTableData = z.object({
|
||||
notes: z.array(ZResponseNote),
|
||||
language: z.string().nullable(),
|
||||
responseData: ZResponseData,
|
||||
variables: z.record(z.union([z.string(), z.number()])),
|
||||
});
|
||||
|
||||
export type TResponseTableData = z.infer<typeof ZResponseTableData>;
|
||||
|
||||
Reference in New Issue
Block a user