Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TM-1576] Update form header content for site reports. #758

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading