add in final places

This commit is contained in:
Sara Vieira committed 2022-06-28 18:47:56 +02:00
1 parent 93599fe0c1
commit dfb0c07db0
3 files changed
+18 -9

No files matched your search

+2 -2
View File
@@ -4,7 +4,7 @@ import type { Project } from "@webstudio-is/sdk";
import { Designer, links } from "~/designer";
import * as db from "~/shared/db";
import config from "~/config";
import env from "~/env.server";
export { links };
export const loader: LoaderFunction = async ({ params }) => {
@@ -13,7 +13,7 @@ export const loader: LoaderFunction = async ({ params }) => {
if (project === null) {
return { errors: `Project "${params.id}" not found` };
}
return { config, project };
return { config, project, env };
};
type Data = {
+2 -1
View File
@@ -2,6 +2,7 @@ import { LoaderFunction, redirect } from "@remix-run/node";
import { authenticator } from "~/services/auth.server";
import config from "~/config";
import env from "~/env.server";
import { Login, links } from "~/auth/";
@@ -13,7 +14,7 @@ export const loader: LoaderFunction = async ({ request }) => {
return redirect(config.dashboardPath);
}
return { devLogin: process.env.DEV_LOGIN === "true" };
return { devLogin: process.env.DEV_LOGIN === "true", env };
};
const LoginRoute = () => {
+14 -6
View File
@@ -2,23 +2,31 @@ import { useLoaderData } from "@remix-run/react";
import type { LoaderFunction } from "@remix-run/node";
import { Root } from "@webstudio-is/sdk";
import { loadPreviewData, type PreviewData, type ErrorData } from "~/shared/db";
import env, { Env } from "~/env.server";
export const loader: LoaderFunction = async ({
params,
}): Promise<PreviewData | ErrorData> => {
type LoaderReturnType = Promise<
(PreviewData & { env: Env }) | (ErrorData & { env: Env })
>;
export const loader: LoaderFunction = async ({ params }): LoaderReturnType => {
if (params.projectId === undefined) {
return { errors: "Missing projectId" };
return { errors: "Missing projectId", env };
}
try {
return await loadPreviewData({ projectId: params.projectId });
const previewData = await loadPreviewData({ projectId: params.projectId });
return {
...previewData,
env,
};
} catch (error) {
if (error instanceof Error) {
return {
errors: error.message,
env,
};
}
}
return { errors: "Unexpected error" };
return { errors: "Unexpected error", env };
};
const PreviewRoute = () => {