2022-06-17 20:50:21 +08:00
|
|
|
export default function (helpers) {
|
|
|
|
const { parsePostData, response } = helpers;
|
|
|
|
|
|
|
|
this.get("/wizard.json", () => {
|
|
|
|
return response({
|
|
|
|
wizard: {
|
|
|
|
start: "hello-world",
|
|
|
|
completed: true,
|
|
|
|
steps: [
|
|
|
|
{
|
|
|
|
id: "hello-world",
|
|
|
|
title: "hello there",
|
|
|
|
index: 0,
|
|
|
|
description: "hello!",
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
id: "full_name",
|
|
|
|
type: "text",
|
|
|
|
required: true,
|
|
|
|
description: "Your name",
|
|
|
|
},
|
|
|
|
],
|
2022-07-27 09:23:01 +08:00
|
|
|
next: "styling",
|
2022-06-17 20:50:21 +08:00
|
|
|
},
|
|
|
|
{
|
2022-07-27 09:23:01 +08:00
|
|
|
id: "styling",
|
2022-06-17 20:50:21 +08:00
|
|
|
title: "Second step",
|
|
|
|
index: 1,
|
2022-08-02 16:43:25 +08:00
|
|
|
fields: [{ id: "some_title", type: "text" }],
|
2022-06-17 20:50:21 +08:00
|
|
|
previous: "hello-world",
|
2022-08-01 17:19:09 +08:00
|
|
|
next: "corporate",
|
2022-06-17 20:50:21 +08:00
|
|
|
},
|
|
|
|
{
|
2022-08-01 17:19:09 +08:00
|
|
|
id: "corporate",
|
2022-06-17 20:50:21 +08:00
|
|
|
index: 2,
|
|
|
|
fields: [
|
2022-08-02 16:43:25 +08:00
|
|
|
{ id: "company_name", type: "text", required: true },
|
|
|
|
{ id: "theme_preview", type: "component" },
|
2022-06-17 20:50:21 +08:00
|
|
|
],
|
2022-07-27 09:23:01 +08:00
|
|
|
previous: "styling",
|
2022-06-17 20:50:21 +08:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
this.put("/wizard/steps/:id", (request) => {
|
|
|
|
const body = parsePostData(request.requestBody);
|
|
|
|
|
|
|
|
if (body.fields.full_name === "Server Fail") {
|
|
|
|
return response(422, {
|
|
|
|
errors: [{ field: "full_name", description: "Invalid name" }],
|
|
|
|
});
|
2022-08-02 16:43:25 +08:00
|
|
|
} else if (body.fields.company_name === "Server Fail") {
|
|
|
|
return response(422, {
|
|
|
|
errors: [
|
|
|
|
{ field: "company_name", description: "Invalid company name" },
|
|
|
|
],
|
|
|
|
});
|
2022-06-17 20:50:21 +08:00
|
|
|
} else {
|
|
|
|
return response(200, { success: true });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|