Skip to content

Commit

Permalink
refactor: 💡 changes related to form submission page
Browse files Browse the repository at this point in the history
  • Loading branch information
growupanand committed Mar 30, 2024
1 parent 9781e48 commit f658846
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import Image from "next/image";
import { Form } from "@convoform/db";

export function FormSubmissionPageHeader({
form,
}: {
form: Pick<
Form,
| "organizationName"
| "organizationLogoUrl"
| "showOrganizationLogo"
| "showOrganizationName"
>;
}) {
const {
showOrganizationName,
organizationName,
showOrganizationLogo,
organizationLogoUrl,
} = form;
return (
<header className="border-b bg-white">
<div className=" flex items-center justify-start gap-3 p-3 lg:container">
{showOrganizationLogo && organizationLogoUrl && (
<Image
alt="Organization Logo"
src={organizationLogoUrl}
width={30}
height={30}
/>
)}
{showOrganizationName && organizationName && (
<h1 className="text-xl lg:text-2xl">{organizationName}</h1>
)}
</div>
</header>
);
}
30 changes: 4 additions & 26 deletions apps/web/src/app/(formSubmissionPage)/view/[formId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Metadata } from "next";
import Image from "next/image";
import { notFound } from "next/navigation";

import { FormViewer } from "@/components/formViewer";
import { FormViewer } from "@/components/formViewer/formViewer";
import { api } from "@/trpc/server";
import { FormSubmissionPageHeader } from "./_components/header";

interface FormViewerPageProps {
params: { formId: string };
Expand All @@ -20,34 +20,12 @@ export default async function FormViewPage({ params }: FormViewerPageProps) {
notFound();
}

const {
showOrganizationName,
organizationName,
showOrganizationLogo,
organizationLogoUrl,
} = formData;

const { showOrganizationName, showOrganizationLogo } = formData;
const showHeader = showOrganizationName || showOrganizationLogo;

return (
<div className="flex min-h-screen flex-col">
{showHeader && (
<header className="border-b bg-white">
<div className=" flex items-center justify-start gap-3 p-3 lg:container">
{showOrganizationLogo && organizationLogoUrl && (
<Image
alt="Organization Logo"
src={organizationLogoUrl}
width={30}
height={30}
/>
)}
{showOrganizationName && organizationName && (
<h1 className="text-xl lg:text-2xl">{organizationName}</h1>
)}
</div>
</header>
)}
{showHeader && <FormSubmissionPageHeader form={formData} />}

<div className="flex flex-grow items-center justify-center">
<FormViewer form={formData} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {

import BrowserWindow from "@/components/common/browserWindow";
import Spinner from "@/components/common/spinner";
import { FormViewer } from "@/components/formViewer";
import { FormViewer } from "@/components/formViewer/formViewer";
import { getFrontendBaseUrl } from "@/lib/url";
import { api } from "@/trpc/react";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import BrandName from "../../../../../components/common/brandName";
import BrandName from "../common/brandName";

type Props = {
endScreenMessage: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { useChat } from "ai/react";

import { CONVERSATION_START_MESSAGE } from "@/lib/constants";
import { isRateLimitErrorResponse } from "@/lib/errorHandlers";
import { EndScreen } from "../app/(formSubmissionPage)/view/[formId]/_components/endScreen";
import { FormFieldsViewer } from "../app/(formSubmissionPage)/view/[formId]/_components/formFields";
import { WelcomeScreen } from "../app/(formSubmissionPage)/view/[formId]/_components/welcomeScreen";
import { EndScreen } from "./endScreen";
import { FormFieldsViewer } from "./formFields";
import { WelcomeScreen } from "./welcomeScreen";

type Props = {
form: Form;
Expand Down

0 comments on commit f658846

Please sign in to comment.