Skip to content

Commit

Permalink
Merge pull request #758 from wri/feat/TM-1576-site-report-banner
Browse files Browse the repository at this point in the history
[TM-1576] Update form header content for site reports.
  • Loading branch information
roguenet authored Dec 18, 2024
2 parents 5227a43 + 19b9898 commit 94605d6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/components/extensive/WizardForm/FormHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ export interface WizardFormHeaderProps {
errorMessage?: string;
onClickSaveAndCloseButton?: () => void;
title?: string;
subtitle?: string;
}

export const WizardFormHeader = (props: WizardFormHeaderProps) => {
const t = useT();

const subtitle =
props.subtitle ?? t("Progress: {number} steps complete", { number: `${props.currentStep}/${props.numberOfSteps}` });

return (
<div className="sticky top-[74px] z-40 flex border-neutral-150 bg-treesHeaderWithOverlay bg-cover bg-no-repeat px-10 py-3 md:py-8">
<div className="mx-auto flex w-full min-w-0 max-w-[82vw] items-center gap-8">
Expand All @@ -27,9 +31,9 @@ export const WizardFormHeader = (props: WizardFormHeaderProps) => {
)}
<div className="flex">
<Text variant="text-14-light" className="overflow-hidden text-ellipsis whitespace-nowrap">
<T _str="Progress: {number} steps complete" number={`${props.currentStep}/${props.numberOfSteps}`} />
{subtitle}
</Text>
<Text variant="text-14-light">
<Text variant="text-14-light" className="pl-1">
<Switch>
<Case condition={!props.formStatus}>{t("Unsaved")}</Case>
<Case condition={props.formStatus === "saving"}>{t("Saving…")}</Case>
Expand Down
2 changes: 2 additions & 0 deletions src/components/extensive/WizardForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface WizardFormProps {

formStatus?: "saving" | "saved";
title?: string;
subtitle?: string;
errors?: ErrorWrapper<null>;
summaryOptions?: FormSummaryOptions & {
downloadButtonText?: string;
Expand Down Expand Up @@ -267,6 +268,7 @@ function WizardForm(props: WizardFormProps) {
errorMessage={props.errors && t("Something went wrong")}
onClickSaveAndCloseButton={!props.hideSaveAndCloseButton ? onClickSaveAndClose : undefined}
title={props.title}
subtitle={props.subtitle}
/>
</When>
<div className={twMerge("mx-auto mt-0 max-w-[82vw] px-6 py-10 xl:px-0", props.className)}>
Expand Down
8 changes: 7 additions & 1 deletion src/pages/entity/[entityName]/edit/[uuid]/EditEntityForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ const EditEntityForm = ({ entityName, entityUUID, entity, formData }: EditEntity
);

const reportingWindow = useReportingWindow(entity?.due_at);
const formTitle = `${formData.form?.title} ${isReport ? reportingWindow : ""}`;
const formTitle =
entityName === "site-reports"
? t("{siteName} Site Report", { siteName: entity.site.name })
: `${formData.form?.title} ${isReport ? reportingWindow : ""}`;
const formSubtitle =
entityName === "site-reports" ? t("Reporting Period: {reportingWindow}", { reportingWindow }) : undefined;

const saveAndCloseModalMapping: any = {
projects: t(
Expand Down Expand Up @@ -117,6 +122,7 @@ const EditEntityForm = ({ entityName, entityUUID, entity, formData }: EditEntity
submitButtonDisable={isSubmitting}
defaultValues={defaultValues}
title={formTitle}
subtitle={formSubtitle}
tabOptions={{
markDone: true,
disableFutureTabs: true
Expand Down

0 comments on commit 94605d6

Please sign in to comment.