-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
*remove api endpoint * add closed component ui * server action to pull from DB * update front facing form * move closed page out of preview * update strings Co-authored-by: Anik Brazeau <38330843+anikbrazeau@users.noreply.github.com>
- Loading branch information
1 parent
9768159
commit 2670aa8
Showing
29 changed files
with
362 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...orm administration)/form-builder/[id]/edit/translate/components/TranslateCustomizeSet.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
app/(gcforms)/[locale]/(form administration)/form-builder/[id]/preview/PreviewClosed.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
"use client"; | ||
|
||
import Brand from "@clientComponents/globals/Brand"; | ||
import { PreviewNavigation } from "./PreviewNavigation"; | ||
import { useTemplateStore } from "@lib/store/useTemplateStore"; | ||
import { defaultForm } from "@lib/store/defaults"; | ||
import { ClosedPage } from "@clientComponents/forms"; | ||
import { ClosedDetails, PublicFormRecord } from "@lib/types"; | ||
import { useSession } from "next-auth/react"; | ||
import { useTranslation } from "@i18n/client"; | ||
import { useIsFormClosed } from "@lib/hooks/useIsFormClosed"; | ||
import Skeleton from "react-loading-skeleton"; | ||
|
||
export const PreviewClosed = ({ closedDetails }: { closedDetails: ClosedDetails }) => { | ||
const { i18n } = useTranslation(["common", "confirmation"]); | ||
const { status } = useSession(); | ||
const { id, getIsPublished, getSecurityAttribute } = useTemplateStore((s) => ({ | ||
id: s.id, | ||
getIsPublished: s.getIsPublished, | ||
getSecurityAttribute: s.getSecurityAttribute, | ||
})); | ||
|
||
const { translationLanguagePriority, getLocalizationAttribute } = useTemplateStore((s) => ({ | ||
localizeField: s.localizeField, | ||
translationLanguagePriority: s.translationLanguagePriority, | ||
getLocalizationAttribute: s.getLocalizationAttribute, | ||
})); | ||
|
||
const language = translationLanguagePriority; | ||
|
||
const formRecord: PublicFormRecord = { | ||
id: id || "test0form00000id000asdf11", | ||
form: defaultForm, | ||
isPublished: getIsPublished(), | ||
securityAttribute: getSecurityAttribute(), | ||
closedDetails: closedDetails, | ||
}; | ||
|
||
const brand = formRecord?.form ? formRecord.form.brand : null; | ||
|
||
const isPastClosingDate = useIsFormClosed(); | ||
|
||
if (!isPastClosingDate) { | ||
// Force a hard refresh to the preview page if the form is not closed | ||
const refreshContent = `0;url=/${i18n.language}/form-builder/${id}/preview`; | ||
return ( | ||
<> | ||
<meta httpEquiv="refresh" content={refreshContent} /> | ||
<Skeleton count={4} height={40} className="mb-4" /> | ||
</> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="max-w-4xl"> | ||
<PreviewNavigation /> | ||
<div className="h-12"></div> | ||
<div | ||
className={`mb-8 border-3 border-dashed border-blue-focus bg-white p-4 ${ | ||
status !== "authenticated" && "" | ||
}`} | ||
{...getLocalizationAttribute()} | ||
> | ||
<div className="gc-formview"> | ||
<div className="mb-20 mt-0 border-b-4 border-blue-dark py-9"> | ||
<Brand brand={brand} lang={language} className="max-w-[360px]" /> | ||
</div> | ||
<ClosedPage language={language} formRecord={formRecord} /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
.../[locale]/(form administration)/form-builder/[id]/settings/manage/close/ClosedMessage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { useTranslation } from "@i18n/client"; | ||
import { ClosedDetails } from "@lib/types"; | ||
import { Editor } from "@formBuilder/[id]/edit/components/elements/lexical-editor/Editor"; | ||
import { LanguageLabel } from "@formBuilder/components/shared/LanguageLabel"; | ||
import { useRehydrate } from "@lib/store/useTemplateStore"; | ||
import Skeleton from "react-loading-skeleton"; | ||
import React from "react"; | ||
|
||
type ClosedMessageProps = { | ||
closedDetails?: ClosedDetails; | ||
setClosedDetails: (details: ClosedDetails) => void; | ||
}; | ||
|
||
export const ClosedMessage = ({ closedDetails, setClosedDetails }: ClosedMessageProps) => { | ||
const { t } = useTranslation("form-builder"); | ||
const hasHydrated = useRehydrate(); | ||
|
||
if (!hasHydrated) { | ||
// Don't show the rich text editor until the form has been hydrated | ||
return ( | ||
<div className="flex"> | ||
<div className="relative w-1/2 border-1 border-r-4 border-gray-100 border-r-black"> | ||
<div className="p-8"> | ||
<Skeleton className="w-full" count={3} /> | ||
</div> | ||
</div> | ||
<div className="relative w-1/2 border-1 border-gray-100"> | ||
<div className="p-8"> | ||
<Skeleton className="w-full" count={3} /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<p className="mb-2 font-bold">{t("closingDate.message.title")}</p> | ||
<p className="mb-4">{t("closingDate.message.text1")}</p> | ||
<div className="flex"> | ||
<div className="relative w-1/2 border-1 border-r-4 border-gray-100 border-r-black"> | ||
<label className="sr-only" htmlFor={`closed-en`}> | ||
{t("english")} | ||
</label> | ||
<LanguageLabel id="form-introduction-english-language" lang={"en"}> | ||
<>{t("english")}</> | ||
</LanguageLabel> | ||
<Editor | ||
id="closed-en" | ||
lang="en" | ||
content={closedDetails && closedDetails.messageEn ? closedDetails.messageEn : ""} | ||
onChange={(value: string) => { | ||
setClosedDetails({ ...closedDetails, messageEn: value }); | ||
}} | ||
/> | ||
</div> | ||
|
||
<div className="relative w-1/2 border-1 border-gray-100"> | ||
<label className="sr-only" htmlFor={`closed-fr`}> | ||
{t("french")} | ||
</label> | ||
|
||
<LanguageLabel id="form-introduction-english-language" lang={"fr"}> | ||
<>{t("french")}</> | ||
</LanguageLabel> | ||
<Editor | ||
id="closed-fr" | ||
lang="fr" | ||
content={closedDetails && closedDetails.messageFr ? closedDetails.messageFr : ""} | ||
onChange={(value: string) => setClosedDetails({ ...closedDetails, messageFr: value })} | ||
/> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; |
13 changes: 13 additions & 0 deletions
13
.../[locale]/(form administration)/form-builder/[id]/settings/manage/close/ClosedSuccess.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { useTranslation } from "@i18n/client"; | ||
|
||
export const ClosedSuccess = () => { | ||
const { t } = useTranslation("form-builder"); | ||
return ( | ||
<div className="w-full"> | ||
<h3 className="!mb-0 pb-0 text-xl font-semibold"> | ||
{t("closingDate.formClosedSuccessMessage.title")} | ||
</h3> | ||
<p className="mb-2 text-black">{t("closingDate.formClosedSuccessMessage.body")}</p> | ||
</div> | ||
); | ||
}; |
File renamed without changes.
Oops, something went wrong.