- Upload File (File format: PDF max. 5MB)
+ Upload File (File format: PDF max. 10MB)
Date: Fri, 24 May 2024 09:18:17 -0700
Subject: [PATCH 12/27] [TM-929] Turn it into a real hook and reduce duplicated
code.
---
.../components/Fields/FrameworkField.tsx | 15 ++--------
.../components/ProjectReportsList.tsx | 29 ++-----------------
.../projects/components/ProjectsList.tsx | 28 ++----------------
.../components/SiteReportsList.tsx | 28 ++----------------
.../modules/sites/components/SitesList.tsx | 29 ++-----------------
.../modules/tasks/components/TasksList.tsx | 27 ++---------------
src/constants/options/frameworks.ts | 23 +++++++++++++--
7 files changed, 37 insertions(+), 142 deletions(-)
diff --git a/src/admin/components/Fields/FrameworkField.tsx b/src/admin/components/Fields/FrameworkField.tsx
index 78dd95679..0086a9733 100644
--- a/src/admin/components/Fields/FrameworkField.tsx
+++ b/src/admin/components/Fields/FrameworkField.tsx
@@ -1,22 +1,11 @@
-import { FC, useEffect, useState } from "react";
+import { FC } from "react";
import { FunctionField } from "react-admin";
import { useFrameworkChoices } from "@/constants/options/frameworks";
const FrameworkField: FC = () => {
- const [frameworkChoices, setFrameworkChoices] = useState([]);
- const fetchData = async () => {
- try {
- const choices = await useFrameworkChoices();
- setFrameworkChoices(choices);
- } catch (error) {
- console.error("Error fetching framework choices:", error);
- }
- };
+ const frameworkChoices = useFrameworkChoices();
- useEffect(() => {
- fetchData();
- }, []);
return (
{
- const [frameworkChoices, setFrameworkChoices] = useState([]);
- const fetchData = async () => {
- try {
- const choices = await useFrameworkChoices();
- setFrameworkChoices(choices);
- } catch (error) {
- console.error("Error fetching framework choices:", error);
- }
- };
+ const frameworkChoices = useFrameworkChoices();
- useEffect(() => {
- fetchData();
- }, []);
return (
}>
@@ -75,19 +64,7 @@ const ProjectReportDataGrid: FC = () => {
export const ProjectReportsList: FC = () => {
const [exportModalOpen, setExportModalOpen] = useState(false);
const [exporting, setExporting] = useState(false);
- const [frameworkChoices, setFrameworkChoices] = useState([]);
- const fetchData = async () => {
- try {
- const choices = await useFrameworkChoices();
- setFrameworkChoices(choices);
- } catch (error) {
- console.error("Error fetching framework choices:", error);
- }
- };
-
- useEffect(() => {
- fetchData();
- }, []);
+ const frameworkChoices = useFrameworkChoices();
const filters = [
,
{
- const [frameworkChoices, setFrameworkChoices] = useState([]);
- const fetchData = async () => {
- try {
- const choices = await useFrameworkChoices();
- setFrameworkChoices(choices);
- } catch (error) {
- console.error("Error fetching framework choices:", error);
- }
- };
+ const frameworkChoices = useFrameworkChoices();
- useEffect(() => {
- fetchData();
- }, []);
return (
}>
@@ -90,19 +79,8 @@ const ProjectDataGrid = () => {
export const ProjectsList: FC = () => {
const [exportModalOpen, setExportModalOpen] = useState(false);
const [exporting, setExporting] = useState(false);
- const [frameworkChoices, setFrameworkChoices] = useState([]);
- const fetchData = async () => {
- try {
- const choices = await useFrameworkChoices();
- setFrameworkChoices(choices);
- } catch (error) {
- console.error("Error fetching framework choices:", error);
- }
- };
+ const frameworkChoices = useFrameworkChoices();
- useEffect(() => {
- fetchData();
- }, []);
const filters = [
,
,
diff --git a/src/admin/modules/siteReports/components/SiteReportsList.tsx b/src/admin/modules/siteReports/components/SiteReportsList.tsx
index 6259efe3a..ad58cada3 100644
--- a/src/admin/modules/siteReports/components/SiteReportsList.tsx
+++ b/src/admin/modules/siteReports/components/SiteReportsList.tsx
@@ -1,5 +1,5 @@
import { Divider, Stack, Typography } from "@mui/material";
-import { FC, useEffect, useState } from "react";
+import { FC, useState } from "react";
import {
AutocompleteInput,
Datagrid,
@@ -29,19 +29,8 @@ import { optionToChoices } from "@/utils/options";
import modules from "../..";
const SiteReportDataGrid: FC = () => {
- const [frameworkChoices, setFrameworkChoices] = useState([]);
- const fetchData = async () => {
- try {
- const choices = await useFrameworkChoices();
- setFrameworkChoices(choices);
- } catch (error) {
- console.error("Error fetching framework choices:", error);
- }
- };
+ const frameworkChoices = useFrameworkChoices();
- useEffect(() => {
- fetchData();
- }, []);
return (
}>
@@ -75,19 +64,8 @@ const SiteReportDataGrid: FC = () => {
export const SiteReportsList: FC = () => {
const [exportModalOpen, setExportModalOpen] = useState(false);
const [exporting, setExporting] = useState(false);
- const [frameworkChoices, setFrameworkChoices] = useState([]);
- const fetchData = async () => {
- try {
- const choices = await useFrameworkChoices();
- setFrameworkChoices(choices);
- } catch (error) {
- console.error("Error fetching framework choices:", error);
- }
- };
+ const frameworkChoices = useFrameworkChoices();
- useEffect(() => {
- fetchData();
- }, []);
const filters = [
,
{
- const [frameworkChoices, setFrameworkChoices] = useState([]);
- const fetchData = async () => {
- try {
- const choices = await useFrameworkChoices();
- setFrameworkChoices(choices);
- } catch (error) {
- console.error("Error fetching framework choices:", error);
- }
- };
+ const frameworkChoices = useFrameworkChoices();
- useEffect(() => {
- fetchData();
- }, []);
return (
}>
@@ -90,19 +79,7 @@ const SiteDataGrid: FC = () => {
export const SitesList: FC = () => {
const [exportModalOpen, setExportModalOpen] = useState(false);
const [exporting, setExporting] = useState(false);
- const [frameworkChoices, setFrameworkChoices] = useState([]);
- const fetchData = async () => {
- try {
- const choices = await useFrameworkChoices();
- setFrameworkChoices(choices);
- } catch (error) {
- console.error("Error fetching framework choices:", error);
- }
- };
-
- useEffect(() => {
- fetchData();
- }, []);
+ const frameworkChoices = useFrameworkChoices();
const filters = [
,
,
diff --git a/src/admin/modules/tasks/components/TasksList.tsx b/src/admin/modules/tasks/components/TasksList.tsx
index ec3b59ecd..c2a30cab3 100644
--- a/src/admin/modules/tasks/components/TasksList.tsx
+++ b/src/admin/modules/tasks/components/TasksList.tsx
@@ -1,5 +1,5 @@
import { Divider, Stack, Typography } from "@mui/material";
-import { FC, useEffect, useState } from "react";
+import { FC } from "react";
import {
AutocompleteInput,
Datagrid,
@@ -18,17 +18,7 @@ import { optionToChoices } from "@/utils/options";
import modules from "../..";
const TaskDataGrid: FC = () => {
- const [frameworkChoices, setFrameworkChoices] = useState([]);
- const fetchData = async () => {
- try {
- setFrameworkChoices(await useFrameworkChoices());
- } catch (error) {
- console.error("Error fetching framework choices:", error);
- }
- };
- useEffect(() => {
- fetchData();
- }, []);
+ const frameworkChoices = useFrameworkChoices();
return (
@@ -51,18 +41,7 @@ const TaskDataGrid: FC = () => {
};
export const TasksList: FC = () => {
- const [frameworkChoices, setFrameworkChoices] = useState([]);
-
- const fetchData = async () => {
- try {
- setFrameworkChoices(await useFrameworkChoices());
- } catch (error) {
- console.error("Error fetching framework choices:", error);
- }
- };
- useEffect(() => {
- fetchData();
- }, []);
+ const frameworkChoices = useFrameworkChoices();
const filters = [
{
+async function getFrameworkChoices() {
const params: GetListParams = {
pagination: {
page: 0,
@@ -16,9 +17,25 @@ export const useFrameworkChoices = async () => {
};
const data = await reportingFrameworkDataProvider.getList("", params);
- const frameworkChoices: any = (data as any)?.data.map((framework: any) => ({
+ return (data as any)?.data.map((framework: any) => ({
id: framework.slug,
name: framework.name
}));
+}
+
+export function useFrameworkChoices() {
+ const [frameworkChoices, setFrameworkChoices] = useState([]);
+ const fetchFrameworkChoices = async function () {
+ try {
+ setFrameworkChoices(await getFrameworkChoices());
+ } catch (error) {
+ console.error("Error fetching framework choices", error);
+ }
+ };
+
+ useEffect(() => {
+ fetchFrameworkChoices();
+ }, []);
+
return frameworkChoices;
-};
+}
From ba3363e705938c0c1e74a8419599258b6ce7416a Mon Sep 17 00:00:00 2001
From: Nathan Curtis
Date: Fri, 24 May 2024 09:51:05 -0700
Subject: [PATCH 13/27] [TM-929] Reduce code duplication in managing the
framework selection dialog.
---
.../Dialogs/FrameworkSelectionDialog.tsx | 20 +++++++++++++++++-
.../components/ProjectReportsList.tsx | 21 +++++--------------
.../projects/components/ProjectsList.tsx | 21 +++++--------------
.../components/SiteReportsList.tsx | 21 +++++--------------
.../modules/sites/components/SitesList.tsx | 21 +++++--------------
5 files changed, 39 insertions(+), 65 deletions(-)
diff --git a/src/admin/components/Dialogs/FrameworkSelectionDialog.tsx b/src/admin/components/Dialogs/FrameworkSelectionDialog.tsx
index 8b3f7e642..a253dfcb7 100644
--- a/src/admin/components/Dialogs/FrameworkSelectionDialog.tsx
+++ b/src/admin/components/Dialogs/FrameworkSelectionDialog.tsx
@@ -1,6 +1,6 @@
import { CheckCircle, InfoOutlined } from "@mui/icons-material";
import { Button, Dialog, DialogActions, DialogContent, DialogProps, DialogTitle } from "@mui/material";
-import { FC, useMemo } from "react";
+import { FC, useCallback, useMemo, useState } from "react";
import { AutocompleteInput, Form } from "react-admin";
import { FieldValues } from "react-hook-form";
import * as yup from "yup";
@@ -57,6 +57,24 @@ const FrameworkSelectionDialogContent: FC
);
};
+export function useFrameworkSelection(handleExport: (framework: string) => void) {
+ const [modalOpen, setModalOpen] = useState(false);
+ return {
+ openExportDialog: useCallback(() => setModalOpen(true), []),
+ frameworkDialogProps: {
+ open: modalOpen,
+ onCancel: useCallback(() => setModalOpen(false), []),
+ onExport: useCallback(
+ (framework: string) => {
+ handleExport(framework);
+ setModalOpen(false);
+ },
+ [handleExport]
+ )
+ }
+ };
+}
+
interface FrameworkSelectionDialogProps extends DialogProps {
onExport: (framework: string) => void;
onCancel: () => void;
diff --git a/src/admin/modules/projectReports/components/ProjectReportsList.tsx b/src/admin/modules/projectReports/components/ProjectReportsList.tsx
index e18dc2a92..b842e987a 100644
--- a/src/admin/modules/projectReports/components/ProjectReportsList.tsx
+++ b/src/admin/modules/projectReports/components/ProjectReportsList.tsx
@@ -18,7 +18,7 @@ import {
import ListActions from "@/admin/components/Actions/ListActions";
import ExportProcessingAlert from "@/admin/components/Alerts/ExportProcessingAlert";
import CustomBulkDeleteWithConfirmButton from "@/admin/components/Buttons/CustomBulkDeleteWithConfirmButton";
-import FrameworkSelectionDialog from "@/admin/components/Dialogs/FrameworkSelectionDialog";
+import FrameworkSelectionDialog, { useFrameworkSelection } from "@/admin/components/Dialogs/FrameworkSelectionDialog";
import { getCountriesOptions } from "@/constants/options/countries";
import { useFrameworkChoices } from "@/constants/options/frameworks";
import { getChangeRequestStatusOptions, getReportStatusOptions } from "@/constants/options/status";
@@ -62,7 +62,6 @@ const ProjectReportDataGrid: FC = () => {
};
export const ProjectReportsList: FC = () => {
- const [exportModalOpen, setExportModalOpen] = useState(false);
const [exporting, setExporting] = useState(false);
const frameworkChoices = useFrameworkChoices();
const filters = [
@@ -90,15 +89,7 @@ export const ProjectReportsList: FC = () => {
];
- const handleExportOpen = () => {
- setExportModalOpen(true);
- };
-
- const handleExportClose = () => {
- setExportModalOpen(false);
- };
-
- const handleExport = (framework: string) => {
+ const { openExportDialog, frameworkDialogProps } = useFrameworkSelection((framework: string) => {
setExporting(true);
fetchGetV2AdminENTITYExportFRAMEWORK({
@@ -111,9 +102,7 @@ export const ProjectReportsList: FC = () => {
downloadFileBlob(response, `Project Reports - ${framework}.csv`);
})
.finally(() => setExporting(false));
-
- handleExportClose();
- };
+ });
return (
<>
@@ -123,11 +112,11 @@ export const ProjectReportsList: FC = () => {
-
} filters={filters}>
+
} filters={filters}>
-
+
>
diff --git a/src/admin/modules/projects/components/ProjectsList.tsx b/src/admin/modules/projects/components/ProjectsList.tsx
index bc1b739c4..ea957c63e 100644
--- a/src/admin/modules/projects/components/ProjectsList.tsx
+++ b/src/admin/modules/projects/components/ProjectsList.tsx
@@ -21,7 +21,7 @@ import ListActions from "@/admin/components/Actions/ListActions";
import ExportProcessingAlert from "@/admin/components/Alerts/ExportProcessingAlert";
import CustomBulkDeleteWithConfirmButton from "@/admin/components/Buttons/CustomBulkDeleteWithConfirmButton";
import CustomDeleteWithConfirmButton from "@/admin/components/Buttons/CustomDeleteWithConfirmButton";
-import FrameworkSelectionDialog from "@/admin/components/Dialogs/FrameworkSelectionDialog";
+import FrameworkSelectionDialog, { useFrameworkSelection } from "@/admin/components/Dialogs/FrameworkSelectionDialog";
import { getCountriesOptions } from "@/constants/options/countries";
import { useFrameworkChoices } from "@/constants/options/frameworks";
import { getChangeRequestStatusOptions, getStatusOptions } from "@/constants/options/status";
@@ -77,7 +77,6 @@ const ProjectDataGrid = () => {
};
export const ProjectsList: FC = () => {
- const [exportModalOpen, setExportModalOpen] = useState(false);
const [exporting, setExporting] = useState(false);
const frameworkChoices = useFrameworkChoices();
@@ -112,15 +111,7 @@ export const ProjectsList: FC = () => {
];
- const handleExportOpen = () => {
- setExportModalOpen(true);
- };
-
- const handleExportClose = () => {
- setExportModalOpen(false);
- };
-
- const handleExport = (framework: string) => {
+ const { openExportDialog, frameworkDialogProps } = useFrameworkSelection((framework: string) => {
setExporting(true);
fetchGetV2AdminENTITYExportFRAMEWORK({
@@ -133,9 +124,7 @@ export const ProjectsList: FC = () => {
downloadFileBlob(response, `Projects - ${framework}.csv`);
})
.finally(() => setExporting(false));
-
- handleExportClose();
- };
+ });
return (
<>
@@ -145,11 +134,11 @@ export const ProjectsList: FC = () => {
-
} filters={filters}>
+
} filters={filters}>
-
+
>
diff --git a/src/admin/modules/siteReports/components/SiteReportsList.tsx b/src/admin/modules/siteReports/components/SiteReportsList.tsx
index ad58cada3..4298f6408 100644
--- a/src/admin/modules/siteReports/components/SiteReportsList.tsx
+++ b/src/admin/modules/siteReports/components/SiteReportsList.tsx
@@ -18,7 +18,7 @@ import {
import ListActions from "@/admin/components/Actions/ListActions";
import ExportProcessingAlert from "@/admin/components/Alerts/ExportProcessingAlert";
import CustomBulkDeleteWithConfirmButton from "@/admin/components/Buttons/CustomBulkDeleteWithConfirmButton";
-import FrameworkSelectionDialog from "@/admin/components/Dialogs/FrameworkSelectionDialog";
+import FrameworkSelectionDialog, { useFrameworkSelection } from "@/admin/components/Dialogs/FrameworkSelectionDialog";
import { getCountriesOptions } from "@/constants/options/countries";
import { useFrameworkChoices } from "@/constants/options/frameworks";
import { getChangeRequestStatusOptions, getReportStatusOptions } from "@/constants/options/status";
@@ -62,7 +62,6 @@ const SiteReportDataGrid: FC = () => {
};
export const SiteReportsList: FC = () => {
- const [exportModalOpen, setExportModalOpen] = useState(false);
const [exporting, setExporting] = useState(false);
const frameworkChoices = useFrameworkChoices();
@@ -103,15 +102,7 @@ export const SiteReportsList: FC = () => {
];
- const handleExportOpen = () => {
- setExportModalOpen(true);
- };
-
- const handleExportClose = () => {
- setExportModalOpen(false);
- };
-
- const handleExport = (framework: string) => {
+ const { openExportDialog, frameworkDialogProps } = useFrameworkSelection((framework: string) => {
setExporting(true);
fetchGetV2AdminENTITYExportFRAMEWORK({
@@ -124,9 +115,7 @@ export const SiteReportsList: FC = () => {
downloadFileBlob(response, `Site Reports - ${framework}.csv`);
})
.finally(() => setExporting(false));
-
- handleExportClose();
- };
+ });
return (
<>
@@ -136,11 +125,11 @@ export const SiteReportsList: FC = () => {
-
} filters={filters}>
+
} filters={filters}>
-
+
>
diff --git a/src/admin/modules/sites/components/SitesList.tsx b/src/admin/modules/sites/components/SitesList.tsx
index fbb3e7b95..7a411b39d 100644
--- a/src/admin/modules/sites/components/SitesList.tsx
+++ b/src/admin/modules/sites/components/SitesList.tsx
@@ -21,7 +21,7 @@ import ListActions from "@/admin/components/Actions/ListActions";
import ExportProcessingAlert from "@/admin/components/Alerts/ExportProcessingAlert";
import CustomBulkDeleteWithConfirmButton from "@/admin/components/Buttons/CustomBulkDeleteWithConfirmButton";
import CustomDeleteWithConfirmButton from "@/admin/components/Buttons/CustomDeleteWithConfirmButton";
-import FrameworkSelectionDialog from "@/admin/components/Dialogs/FrameworkSelectionDialog";
+import FrameworkSelectionDialog, { useFrameworkSelection } from "@/admin/components/Dialogs/FrameworkSelectionDialog";
import { getCountriesOptions } from "@/constants/options/countries";
import { useFrameworkChoices } from "@/constants/options/frameworks";
import { getChangeRequestStatusOptions, getStatusOptions } from "@/constants/options/status";
@@ -77,7 +77,6 @@ const SiteDataGrid: FC = () => {
};
export const SitesList: FC = () => {
- const [exportModalOpen, setExportModalOpen] = useState(false);
const [exporting, setExporting] = useState(false);
const frameworkChoices = useFrameworkChoices();
const filters = [
@@ -123,15 +122,7 @@ export const SitesList: FC = () => {
/>
];
- const handleExportOpen = () => {
- setExportModalOpen(true);
- };
-
- const handleExportClose = () => {
- setExportModalOpen(false);
- };
-
- const handleExport = (framework: string) => {
+ const { openExportDialog, frameworkDialogProps } = useFrameworkSelection((framework: string) => {
setExporting(true);
fetchGetV2AdminENTITYExportFRAMEWORK({
@@ -144,9 +135,7 @@ export const SitesList: FC = () => {
downloadFileBlob(response, `Sites - ${framework}.csv`);
})
.finally(() => setExporting(false));
-
- handleExportClose();
- };
+ });
return (
<>
@@ -156,11 +145,11 @@ export const SitesList: FC = () => {
-
} filters={filters}>
+
} filters={filters}>
-
+
>
From 891b4f82014ad8dd10c2184a7650fa5c82387a7e Mon Sep 17 00:00:00 2001
From: Nathan Curtis
Date: Fri, 24 May 2024 10:11:02 -0700
Subject: [PATCH 14/27] [TM-929] This can be further optimized because they all
use the same API.
---
.../Dialogs/FrameworkSelectionDialog.tsx | 38 ++++++++++++++-----
.../components/ProjectReportsList.tsx | 22 ++---------
.../projects/components/ProjectsList.tsx | 22 ++---------
.../components/SiteReportsList.tsx | 22 ++---------
.../modules/sites/components/SitesList.tsx | 22 ++---------
5 files changed, 40 insertions(+), 86 deletions(-)
diff --git a/src/admin/components/Dialogs/FrameworkSelectionDialog.tsx b/src/admin/components/Dialogs/FrameworkSelectionDialog.tsx
index a253dfcb7..64162f3b2 100644
--- a/src/admin/components/Dialogs/FrameworkSelectionDialog.tsx
+++ b/src/admin/components/Dialogs/FrameworkSelectionDialog.tsx
@@ -1,13 +1,15 @@
import { CheckCircle, InfoOutlined } from "@mui/icons-material";
import { Button, Dialog, DialogActions, DialogContent, DialogProps, DialogTitle } from "@mui/material";
+import { capitalize, split } from "lodash";
import { FC, useCallback, useMemo, useState } from "react";
import { AutocompleteInput, Form } from "react-admin";
import { FieldValues } from "react-hook-form";
import * as yup from "yup";
import { validateForm } from "@/admin/utils/forms";
-import { useGetV2AdminReportingFrameworks } from "@/generated/apiComponents";
-import { Option } from "@/types/common";
+import { fetchGetV2AdminENTITYExportFRAMEWORK, useGetV2AdminReportingFrameworks } from "@/generated/apiComponents";
+import { EntityName, Option } from "@/types/common";
+import { downloadFileBlob } from "@/utils/network";
import { optionToChoices } from "@/utils/options";
interface FrameworkSelectionDialogContentProps {
@@ -57,20 +59,36 @@ const FrameworkSelectionDialogContent: FC
);
};
-export function useFrameworkSelection(handleExport: (framework: string) => void) {
+export function useFrameworkExport(entity: EntityName) {
+ const [exporting, setExporting] = useState(false);
const [modalOpen, setModalOpen] = useState(false);
+
+ const onExport = useCallback(
+ (framework: string) => {
+ setExporting(true);
+
+ const exportPrefix = split(entity, "-").map(capitalize).join(" ");
+
+ fetchGetV2AdminENTITYExportFRAMEWORK({
+ pathParams: { entity, framework }
+ })
+ .then((response: any) => {
+ downloadFileBlob(response, `${exportPrefix} - ${framework}.csv`);
+ })
+ .finally(() => setExporting(false));
+
+ setModalOpen(false);
+ },
+ [entity]
+ );
+
return {
+ exporting,
openExportDialog: useCallback(() => setModalOpen(true), []),
frameworkDialogProps: {
open: modalOpen,
onCancel: useCallback(() => setModalOpen(false), []),
- onExport: useCallback(
- (framework: string) => {
- handleExport(framework);
- setModalOpen(false);
- },
- [handleExport]
- )
+ onExport
}
};
}
diff --git a/src/admin/modules/projectReports/components/ProjectReportsList.tsx b/src/admin/modules/projectReports/components/ProjectReportsList.tsx
index b842e987a..9ad50a205 100644
--- a/src/admin/modules/projectReports/components/ProjectReportsList.tsx
+++ b/src/admin/modules/projectReports/components/ProjectReportsList.tsx
@@ -1,5 +1,5 @@
import { Divider, Stack, Typography } from "@mui/material";
-import { FC, useState } from "react";
+import { FC } from "react";
import {
AutocompleteInput,
Datagrid,
@@ -18,12 +18,10 @@ import {
import ListActions from "@/admin/components/Actions/ListActions";
import ExportProcessingAlert from "@/admin/components/Alerts/ExportProcessingAlert";
import CustomBulkDeleteWithConfirmButton from "@/admin/components/Buttons/CustomBulkDeleteWithConfirmButton";
-import FrameworkSelectionDialog, { useFrameworkSelection } from "@/admin/components/Dialogs/FrameworkSelectionDialog";
+import FrameworkSelectionDialog, { useFrameworkExport } from "@/admin/components/Dialogs/FrameworkSelectionDialog";
import { getCountriesOptions } from "@/constants/options/countries";
import { useFrameworkChoices } from "@/constants/options/frameworks";
import { getChangeRequestStatusOptions, getReportStatusOptions } from "@/constants/options/status";
-import { fetchGetV2AdminENTITYExportFRAMEWORK } from "@/generated/apiComponents";
-import { downloadFileBlob } from "@/utils/network";
import { optionToChoices } from "@/utils/options";
import modules from "../..";
@@ -62,7 +60,6 @@ const ProjectReportDataGrid: FC = () => {
};
export const ProjectReportsList: FC = () => {
- const [exporting, setExporting] = useState(false);
const frameworkChoices = useFrameworkChoices();
const filters = [
,
@@ -89,20 +86,7 @@ export const ProjectReportsList: FC = () => {
];
- const { openExportDialog, frameworkDialogProps } = useFrameworkSelection((framework: string) => {
- setExporting(true);
-
- fetchGetV2AdminENTITYExportFRAMEWORK({
- pathParams: {
- entity: "project-reports",
- framework
- }
- })
- .then((response: any) => {
- downloadFileBlob(response, `Project Reports - ${framework}.csv`);
- })
- .finally(() => setExporting(false));
- });
+ const { exporting, openExportDialog, frameworkDialogProps } = useFrameworkExport("project-reports");
return (
<>
diff --git a/src/admin/modules/projects/components/ProjectsList.tsx b/src/admin/modules/projects/components/ProjectsList.tsx
index ea957c63e..357448002 100644
--- a/src/admin/modules/projects/components/ProjectsList.tsx
+++ b/src/admin/modules/projects/components/ProjectsList.tsx
@@ -1,5 +1,5 @@
import { Divider, Stack, Typography } from "@mui/material";
-import { FC, useState } from "react";
+import { FC } from "react";
import {
AutocompleteInput,
BooleanField,
@@ -21,12 +21,10 @@ import ListActions from "@/admin/components/Actions/ListActions";
import ExportProcessingAlert from "@/admin/components/Alerts/ExportProcessingAlert";
import CustomBulkDeleteWithConfirmButton from "@/admin/components/Buttons/CustomBulkDeleteWithConfirmButton";
import CustomDeleteWithConfirmButton from "@/admin/components/Buttons/CustomDeleteWithConfirmButton";
-import FrameworkSelectionDialog, { useFrameworkSelection } from "@/admin/components/Dialogs/FrameworkSelectionDialog";
+import FrameworkSelectionDialog, { useFrameworkExport } from "@/admin/components/Dialogs/FrameworkSelectionDialog";
import { getCountriesOptions } from "@/constants/options/countries";
import { useFrameworkChoices } from "@/constants/options/frameworks";
import { getChangeRequestStatusOptions, getStatusOptions } from "@/constants/options/status";
-import { fetchGetV2AdminENTITYExportFRAMEWORK } from "@/generated/apiComponents";
-import { downloadFileBlob } from "@/utils/network";
import { optionToChoices } from "@/utils/options";
import modules from "../..";
@@ -77,7 +75,6 @@ const ProjectDataGrid = () => {
};
export const ProjectsList: FC = () => {
- const [exporting, setExporting] = useState(false);
const frameworkChoices = useFrameworkChoices();
const filters = [
@@ -111,20 +108,7 @@ export const ProjectsList: FC = () => {
];
- const { openExportDialog, frameworkDialogProps } = useFrameworkSelection((framework: string) => {
- setExporting(true);
-
- fetchGetV2AdminENTITYExportFRAMEWORK({
- pathParams: {
- entity: "projects",
- framework
- }
- })
- .then((response: any) => {
- downloadFileBlob(response, `Projects - ${framework}.csv`);
- })
- .finally(() => setExporting(false));
- });
+ const { exporting, openExportDialog, frameworkDialogProps } = useFrameworkExport("projects");
return (
<>
diff --git a/src/admin/modules/siteReports/components/SiteReportsList.tsx b/src/admin/modules/siteReports/components/SiteReportsList.tsx
index 4298f6408..6eacb997c 100644
--- a/src/admin/modules/siteReports/components/SiteReportsList.tsx
+++ b/src/admin/modules/siteReports/components/SiteReportsList.tsx
@@ -1,5 +1,5 @@
import { Divider, Stack, Typography } from "@mui/material";
-import { FC, useState } from "react";
+import { FC } from "react";
import {
AutocompleteInput,
Datagrid,
@@ -18,12 +18,10 @@ import {
import ListActions from "@/admin/components/Actions/ListActions";
import ExportProcessingAlert from "@/admin/components/Alerts/ExportProcessingAlert";
import CustomBulkDeleteWithConfirmButton from "@/admin/components/Buttons/CustomBulkDeleteWithConfirmButton";
-import FrameworkSelectionDialog, { useFrameworkSelection } from "@/admin/components/Dialogs/FrameworkSelectionDialog";
+import FrameworkSelectionDialog, { useFrameworkExport } from "@/admin/components/Dialogs/FrameworkSelectionDialog";
import { getCountriesOptions } from "@/constants/options/countries";
import { useFrameworkChoices } from "@/constants/options/frameworks";
import { getChangeRequestStatusOptions, getReportStatusOptions } from "@/constants/options/status";
-import { fetchGetV2AdminENTITYExportFRAMEWORK } from "@/generated/apiComponents";
-import { downloadFileBlob } from "@/utils/network";
import { optionToChoices } from "@/utils/options";
import modules from "../..";
@@ -62,7 +60,6 @@ const SiteReportDataGrid: FC = () => {
};
export const SiteReportsList: FC = () => {
- const [exporting, setExporting] = useState(false);
const frameworkChoices = useFrameworkChoices();
const filters = [
@@ -102,20 +99,7 @@ export const SiteReportsList: FC = () => {
];
- const { openExportDialog, frameworkDialogProps } = useFrameworkSelection((framework: string) => {
- setExporting(true);
-
- fetchGetV2AdminENTITYExportFRAMEWORK({
- pathParams: {
- entity: "site-reports",
- framework
- }
- })
- .then((response: any) => {
- downloadFileBlob(response, `Site Reports - ${framework}.csv`);
- })
- .finally(() => setExporting(false));
- });
+ const { exporting, openExportDialog, frameworkDialogProps } = useFrameworkExport("site-reports");
return (
<>
diff --git a/src/admin/modules/sites/components/SitesList.tsx b/src/admin/modules/sites/components/SitesList.tsx
index 7a411b39d..1dd4aeed4 100644
--- a/src/admin/modules/sites/components/SitesList.tsx
+++ b/src/admin/modules/sites/components/SitesList.tsx
@@ -1,5 +1,5 @@
import { Divider, Stack, Typography } from "@mui/material";
-import { FC, useState } from "react";
+import { FC } from "react";
import {
AutocompleteInput,
BooleanField,
@@ -21,12 +21,10 @@ import ListActions from "@/admin/components/Actions/ListActions";
import ExportProcessingAlert from "@/admin/components/Alerts/ExportProcessingAlert";
import CustomBulkDeleteWithConfirmButton from "@/admin/components/Buttons/CustomBulkDeleteWithConfirmButton";
import CustomDeleteWithConfirmButton from "@/admin/components/Buttons/CustomDeleteWithConfirmButton";
-import FrameworkSelectionDialog, { useFrameworkSelection } from "@/admin/components/Dialogs/FrameworkSelectionDialog";
+import FrameworkSelectionDialog, { useFrameworkExport } from "@/admin/components/Dialogs/FrameworkSelectionDialog";
import { getCountriesOptions } from "@/constants/options/countries";
import { useFrameworkChoices } from "@/constants/options/frameworks";
import { getChangeRequestStatusOptions, getStatusOptions } from "@/constants/options/status";
-import { fetchGetV2AdminENTITYExportFRAMEWORK } from "@/generated/apiComponents";
-import { downloadFileBlob } from "@/utils/network";
import { optionToChoices } from "@/utils/options";
import modules from "../..";
@@ -77,7 +75,6 @@ const SiteDataGrid: FC = () => {
};
export const SitesList: FC = () => {
- const [exporting, setExporting] = useState(false);
const frameworkChoices = useFrameworkChoices();
const filters = [
,
@@ -122,20 +119,7 @@ export const SitesList: FC = () => {
/>
];
- const { openExportDialog, frameworkDialogProps } = useFrameworkSelection((framework: string) => {
- setExporting(true);
-
- fetchGetV2AdminENTITYExportFRAMEWORK({
- pathParams: {
- entity: "sites",
- framework
- }
- })
- .then((response: any) => {
- downloadFileBlob(response, `Sites - ${framework}.csv`);
- })
- .finally(() => setExporting(false));
- });
+ const { exporting, openExportDialog, frameworkDialogProps } = useFrameworkExport("sites");
return (
<>
From 40cff6c5241e6f171188712382043ba2bf14d159 Mon Sep 17 00:00:00 2001
From: Nathan Curtis
Date: Fri, 24 May 2024 10:22:42 -0700
Subject: [PATCH 15/27] [TM-929] Support framework key on nursery and nursery
report.
---
.../nurseries/components/NurseriesList.tsx | 40 ++++++++++---------
.../components/NurseryReportsList.tsx | 40 ++++++++++---------
2 files changed, 42 insertions(+), 38 deletions(-)
diff --git a/src/admin/modules/nurseries/components/NurseriesList.tsx b/src/admin/modules/nurseries/components/NurseriesList.tsx
index 0465fe5d2..17f64de3a 100644
--- a/src/admin/modules/nurseries/components/NurseriesList.tsx
+++ b/src/admin/modules/nurseries/components/NurseriesList.tsx
@@ -1,10 +1,11 @@
import { Divider, Stack, Typography } from "@mui/material";
-import { FC, useState } from "react";
+import { FC } from "react";
import {
AutocompleteInput,
Datagrid,
DateField,
EditButton,
+ FunctionField,
List,
ReferenceInput,
SearchInput,
@@ -19,15 +20,17 @@ import ListActions from "@/admin/components/Actions/ListActions";
import ExportProcessingAlert from "@/admin/components/Alerts/ExportProcessingAlert";
import CustomBulkDeleteWithConfirmButton from "@/admin/components/Buttons/CustomBulkDeleteWithConfirmButton";
import CustomDeleteWithConfirmButton from "@/admin/components/Buttons/CustomDeleteWithConfirmButton";
+import FrameworkSelectionDialog, { useFrameworkExport } from "@/admin/components/Dialogs/FrameworkSelectionDialog";
import { getCountriesOptions } from "@/constants/options/countries";
+import { useFrameworkChoices } from "@/constants/options/frameworks";
import { getChangeRequestStatusOptions, getStatusOptions } from "@/constants/options/status";
-import { fetchGetV2AdminENTITYExportFRAMEWORK } from "@/generated/apiComponents";
-import { downloadFileBlob } from "@/utils/network";
import { optionToChoices } from "@/utils/options";
import modules from "../..";
const NurseryDataGrid: FC = () => {
+ const frameworkChoices = useFrameworkChoices();
+
return (
}>
@@ -41,6 +44,15 @@ const NurseryDataGrid: FC = () => {
+
+ frameworkChoices.find((framework: any) => framework.id === record?.framework_key)?.name ??
+ record?.framework_key
+ }
+ sortable={false}
+ />
@@ -51,7 +63,7 @@ const NurseryDataGrid: FC = () => {
};
export const NurseriesList: FC = () => {
- const [exporting, setExporting] = useState(false);
+ const frameworkChoices = useFrameworkChoices();
const filters = [
,
@@ -68,6 +80,7 @@ export const NurseriesList: FC = () => {
>
,
+ ,
,
{
];
- const handleExport = () => {
- setExporting(true);
-
- fetchGetV2AdminENTITYExportFRAMEWORK({
- pathParams: {
- entity: "nurseries",
- framework: "terrafund"
- }
- })
- .then((response: any) => {
- downloadFileBlob(response, "Nurseries - terrafund.csv");
- })
- .finally(() => setExporting(false));
- };
+ const { exporting, openExportDialog, frameworkDialogProps } = useFrameworkExport("nurseries");
return (
<>
@@ -112,10 +112,12 @@ export const NurseriesList: FC = () => {
-
} filters={filters}>
+
} filters={filters}>
+
+
>
);
diff --git a/src/admin/modules/nurseryReports/components/NurseryReportsList.tsx b/src/admin/modules/nurseryReports/components/NurseryReportsList.tsx
index f4c14d185..15c08c148 100644
--- a/src/admin/modules/nurseryReports/components/NurseryReportsList.tsx
+++ b/src/admin/modules/nurseryReports/components/NurseryReportsList.tsx
@@ -1,10 +1,11 @@
import { Divider, Stack, Typography } from "@mui/material";
-import { FC, useState } from "react";
+import { FC } from "react";
import {
AutocompleteInput,
Datagrid,
DateField,
EditButton,
+ FunctionField,
List,
ReferenceInput,
SearchInput,
@@ -17,15 +18,17 @@ import {
import ListActions from "@/admin/components/Actions/ListActions";
import ExportProcessingAlert from "@/admin/components/Alerts/ExportProcessingAlert";
import CustomBulkDeleteWithConfirmButton from "@/admin/components/Buttons/CustomBulkDeleteWithConfirmButton";
+import FrameworkSelectionDialog, { useFrameworkExport } from "@/admin/components/Dialogs/FrameworkSelectionDialog";
import { getCountriesOptions } from "@/constants/options/countries";
+import { useFrameworkChoices } from "@/constants/options/frameworks";
import { getChangeRequestStatusOptions, getReportStatusOptions } from "@/constants/options/status";
-import { fetchGetV2AdminENTITYExportFRAMEWORK } from "@/generated/apiComponents";
-import { downloadFileBlob } from "@/utils/network";
import { optionToChoices } from "@/utils/options";
import modules from "../..";
const NurseryReportDataGrid: FC = () => {
+ const frameworkChoices = useFrameworkChoices();
+
return (
}>
@@ -41,6 +44,15 @@ const NurseryReportDataGrid: FC = () => {
+
+ frameworkChoices.find((framework: any) => framework.id === record?.framework_key)?.name ??
+ record?.framework_key
+ }
+ sortable={false}
+ />
@@ -48,7 +60,7 @@ const NurseryReportDataGrid: FC = () => {
};
export const NurseryReportsList: FC = () => {
- const [exporting, setExporting] = useState(false);
+ const frameworkChoices = useFrameworkChoices();
const filters = [
,
@@ -77,6 +89,7 @@ export const NurseryReportsList: FC = () => {
,
,
+ ,
,
{
/>
];
- const handleExport = () => {
- setExporting(true);
-
- fetchGetV2AdminENTITYExportFRAMEWORK({
- pathParams: {
- entity: "nursery-reports",
- framework: "terrafund"
- }
- })
- .then((response: any) => {
- downloadFileBlob(response, "Nursery Reports - terrafund.csv");
- })
- .finally(() => setExporting(false));
- };
+ const { exporting, openExportDialog, frameworkDialogProps } = useFrameworkExport("nursery-reports");
return (
<>
@@ -109,10 +109,12 @@ export const NurseryReportsList: FC = () => {
-
} filters={filters}>
+
} filters={filters}>
+
+
>
);
From e71ad72cd2fda6f15ea1cf6de4e994f184f6c5ab Mon Sep 17 00:00:00 2001
From: Nathan Curtis
Date: Mon, 27 May 2024 16:35:07 -0700
Subject: [PATCH 16/27] [TM-786] Handle some warnings in the codebase to help
clean up jest output.
---
.../Inputs/InputElements/InputLabel.tsx | 9 ++-
.../elements/Tabs/Default/TabButton.tsx | 72 +++++++++----------
src/components/elements/Text/Text.tsx | 9 +--
src/components/extensive/List/List.tsx | 2 +-
4 files changed, 44 insertions(+), 48 deletions(-)
diff --git a/src/components/elements/Inputs/InputElements/InputLabel.tsx b/src/components/elements/Inputs/InputElements/InputLabel.tsx
index 38e934669..3550727b8 100644
--- a/src/components/elements/Inputs/InputElements/InputLabel.tsx
+++ b/src/components/elements/Inputs/InputElements/InputLabel.tsx
@@ -1,6 +1,6 @@
import { useT } from "@transifex/react";
import classNames from "classnames";
-import { HTMLProps } from "react";
+import { forwardRef, HTMLProps, RefObject } from "react";
import { When } from "react-if";
import StatusPill from "@/components/elements/StatusPill/StatusPill";
@@ -12,7 +12,7 @@ export interface InputLabelProps extends HTMLProps {
feedbackRequired?: boolean;
}
-const InputLabel = (props: InputLabelProps) => {
+export default forwardRef(function InputLabel(props: InputLabelProps, ref) {
const t = useT();
const { feedbackRequired, required, children, className, ...labelProps } = props;
@@ -20,6 +20,7 @@ const InputLabel = (props: InputLabelProps) => {
{...labelProps}
+ ref={ref as RefObject}
as="label"
variant="text-bold-body-300"
className={classNames("mr-2 inline uppercase", className)}
@@ -34,6 +35,4 @@ const InputLabel = (props: InputLabelProps) => {
);
-};
-
-export default InputLabel;
+});
diff --git a/src/components/elements/Tabs/Default/TabButton.tsx b/src/components/elements/Tabs/Default/TabButton.tsx
index cdb96a69b..3980b1953 100644
--- a/src/components/elements/Tabs/Default/TabButton.tsx
+++ b/src/components/elements/Tabs/Default/TabButton.tsx
@@ -1,5 +1,5 @@
import classNames from "classnames";
-import { ButtonHTMLAttributes, DetailedHTMLProps } from "react";
+import { ButtonHTMLAttributes, DetailedHTMLProps, forwardRef } from "react";
import { When } from "react-if";
import Text from "@/components/elements/Text/Text";
@@ -16,40 +16,36 @@ export interface TabButtonProps extends DetailedHTMLProps {
- return (
-
-
- {item.title}
-
-
-
-
-
- );
-};
+export const TabButton = forwardRef(
+ ({ index, item, lastItem, selected, className, textVariant, ...buttonProps }: TabButtonProps, ref) => {
+ // @ts-ignore
+ buttonProps["ref"] = ref;
+ return (
+
+
+ {item.title}
+
+
+
+
+
+ );
+ }
+);
diff --git a/src/components/elements/Text/Text.tsx b/src/components/elements/Text/Text.tsx
index 1d36ee0f7..34298a0b7 100644
--- a/src/components/elements/Text/Text.tsx
+++ b/src/components/elements/Text/Text.tsx
@@ -1,6 +1,6 @@
import cn from "classnames";
import _ from "lodash";
-import { HTMLProps, ReactNode } from "react";
+import { ForwardedRef, forwardRef, HTMLProps, ReactElement, ReactNode, Ref } from "react";
import { TextVariants } from "@/types/common";
@@ -13,7 +13,7 @@ export type TextProps = HTMLProps & {
capitalize?: boolean;
};
-function Text(props: TextProps): JSX.Element {
+function Text(props: TextProps, ref: ForwardedRef): JSX.Element {
const { as: As, className, children, variant, capitalize, containHtml, ...rest } = props;
const Component = As || "p";
@@ -23,6 +23,7 @@ function Text(props: TextProps): JSX.Element {
return (
(props: TextProps): JSX.Element {
);
} else
return (
-
+
{typeof children === "string" ? _.unescape(children) : children}
);
}
-export default Text;
+export default forwardRef(Text) as (p: TextProps & { ref?: Ref }) => ReactElement;
diff --git a/src/components/extensive/List/List.tsx b/src/components/extensive/List/List.tsx
index 09bb7a9e7..3ccc82ef0 100644
--- a/src/components/extensive/List/List.tsx
+++ b/src/components/extensive/List/List.tsx
@@ -38,7 +38,7 @@ const List = , U>({
{startListElement ? {startListElement} : <>>}
{items.map((item, i, array) => (
-
+
{render(item, i, array)}
{dividerComponent}
From 3e9dd6727214668e2a3cec1e3974136a961ecb12 Mon Sep 17 00:00:00 2001
From: Nathan Curtis
Date: Mon, 27 May 2024 16:46:23 -0700
Subject: [PATCH 17/27] [TM-786] Set up test of github actions
---
.github/workflows/pull-request.yml | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 .github/workflows/pull-request.yml
diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml
new file mode 100644
index 000000000..b291ad262
--- /dev/null
+++ b/.github/workflows/pull-request.yml
@@ -0,0 +1,16 @@
+name: pull-request
+on: workflow_dispatch
+# pull_request:
+# branches: [main, staging, release/**]
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version-file: '.nvmrc'
+ - name: Install modules
+ run: yarn
+ - name: Test
+ run: yarn run jest --ci
From cb1a2a079f7faecaed187db6651a93cdc4eea8ad Mon Sep 17 00:00:00 2001
From: Nathan Curtis
Date: Mon, 27 May 2024 16:48:30 -0700
Subject: [PATCH 18/27] [TM-786] Add .nvmrc to match our node version on prod
---
.nvmrc | 1 +
1 file changed, 1 insertion(+)
create mode 100644 .nvmrc
diff --git a/.nvmrc b/.nvmrc
new file mode 100644
index 000000000..603606bc9
--- /dev/null
+++ b/.nvmrc
@@ -0,0 +1 @@
+18.17.0
From 4f549592469b1f9ad5a0c2cc07e2d4ffffa86011 Mon Sep 17 00:00:00 2001
From: Nathan Curtis
Date: Mon, 27 May 2024 16:51:17 -0700
Subject: [PATCH 19/27] [TM-786] Run test action on pull requests.
---
.github/workflows/pull-request.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml
index b291ad262..194b0c659 100644
--- a/.github/workflows/pull-request.yml
+++ b/.github/workflows/pull-request.yml
@@ -1,7 +1,7 @@
name: pull-request
-on: workflow_dispatch
-# pull_request:
-# branches: [main, staging, release/**]
+on:
+ pull_request:
+ branches: [main, staging, release/**]
jobs:
test:
runs-on: ubuntu-latest
From 4ba0d878ddeee6d7e3607ca698e43ffcecc07086 Mon Sep 17 00:00:00 2001
From: Nathan Curtis
Date: Mon, 27 May 2024 21:18:54 -0700
Subject: [PATCH 20/27] [TM-786] Fix some generic typing.
---
src/components/elements/Text/Text.tsx | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/components/elements/Text/Text.tsx b/src/components/elements/Text/Text.tsx
index 34298a0b7..0baac7c40 100644
--- a/src/components/elements/Text/Text.tsx
+++ b/src/components/elements/Text/Text.tsx
@@ -1,6 +1,6 @@
import cn from "classnames";
import _ from "lodash";
-import { ForwardedRef, forwardRef, HTMLProps, ReactElement, ReactNode, Ref } from "react";
+import { ForwardedRef, forwardRef, HTMLProps, LegacyRef, ReactElement, ReactNode } from "react";
import { TextVariants } from "@/types/common";
@@ -13,7 +13,7 @@ export type TextProps = HTMLProps & {
capitalize?: boolean;
};
-function Text(props: TextProps, ref: ForwardedRef): JSX.Element {
+function Text(props: TextProps, ref: ForwardedRef): JSX.Element {
const { as: As, className, children, variant, capitalize, containHtml, ...rest } = props;
const Component = As || "p";
@@ -37,4 +37,4 @@ function Text(props: TextProps, ref: ForwardedRef): JSX.Element {
);
}
-export default forwardRef(Text) as (p: TextProps & { ref?: Ref }) => ReactElement;
+export default forwardRef(Text) as (p: TextProps & { ref?: LegacyRef }) => ReactElement;
From 82af91801faa16234b4f213cc058a8774e08cd9e Mon Sep 17 00:00:00 2001
From: Nathan Curtis
Date: Mon, 27 May 2024 21:19:23 -0700
Subject: [PATCH 21/27] [TM-786] Fix a hook dependency warning.
---
src/components/extensive/WorkdayCollapseGrid/WorkdaySection.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/extensive/WorkdayCollapseGrid/WorkdaySection.tsx b/src/components/extensive/WorkdayCollapseGrid/WorkdaySection.tsx
index 7a303c49b..db64af006 100644
--- a/src/components/extensive/WorkdayCollapseGrid/WorkdaySection.tsx
+++ b/src/components/extensive/WorkdayCollapseGrid/WorkdaySection.tsx
@@ -68,7 +68,7 @@ const WorkdaySection = ({ demographics, type, variant, onChange }: WorkdaySectio
updatedDemographics.splice(index, 1);
onChange(updatedDemographics);
},
- [demographics, onChange, type]
+ [demographics, onChange]
);
// Tailwind doesn't supply classes for high row counts, so we apply this prop ourselves.
From 9c09232b6a8ef762e7a5c302d1c3e30156521818 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 28 May 2024 22:55:45 +0000
Subject: [PATCH 22/27] chore(deps): bump pug from 3.0.2 to 3.0.3
Bumps [pug](https://github.com/pugjs/pug) from 3.0.2 to 3.0.3.
- [Release notes](https://github.com/pugjs/pug/releases)
- [Commits](https://github.com/pugjs/pug/compare/pug@3.0.2...pug@3.0.3)
---
updated-dependencies:
- dependency-name: pug
dependency-type: indirect
...
Signed-off-by: dependabot[bot]
---
yarn.lock | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/yarn.lock b/yarn.lock
index 505c07800..c18015ffc 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -12798,17 +12798,17 @@ pug-attrs@^3.0.0:
js-stringify "^1.0.2"
pug-runtime "^3.0.0"
-pug-code-gen@^3.0.2:
- version "3.0.2"
- resolved "https://registry.yarnpkg.com/pug-code-gen/-/pug-code-gen-3.0.2.tgz#ad190f4943133bf186b60b80de483100e132e2ce"
- integrity sha512-nJMhW16MbiGRiyR4miDTQMRWDgKplnHyeLvioEJYbk1RsPI3FuA3saEP8uwnTb2nTJEKBU90NFVWJBk4OU5qyg==
+pug-code-gen@^3.0.3:
+ version "3.0.3"
+ resolved "https://registry.yarnpkg.com/pug-code-gen/-/pug-code-gen-3.0.3.tgz#58133178cb423fe1716aece1c1da392a75251520"
+ integrity sha512-cYQg0JW0w32Ux+XTeZnBEeuWrAY7/HNE6TWnhiHGnnRYlCgyAUPoyh9KzCMa9WhcJlJ1AtQqpEYHc+vbCzA+Aw==
dependencies:
constantinople "^4.0.1"
doctypes "^1.1.0"
js-stringify "^1.0.2"
pug-attrs "^3.0.0"
- pug-error "^2.0.0"
- pug-runtime "^3.0.0"
+ pug-error "^2.1.0"
+ pug-runtime "^3.0.1"
void-elements "^3.1.0"
with "^7.0.0"
@@ -12817,6 +12817,11 @@ pug-error@^2.0.0:
resolved "https://registry.yarnpkg.com/pug-error/-/pug-error-2.0.0.tgz#5c62173cb09c34de2a2ce04f17b8adfec74d8ca5"
integrity sha512-sjiUsi9M4RAGHktC1drQfCr5C5eriu24Lfbt4s+7SykztEOwVZtbFk1RRq0tzLxcMxMYTBR+zMQaG07J/btayQ==
+pug-error@^2.1.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/pug-error/-/pug-error-2.1.0.tgz#17ea37b587b6443d4b8f148374ec27b54b406e55"
+ integrity sha512-lv7sU9e5Jk8IeUheHata6/UThZ7RK2jnaaNztxfPYUY+VxZyk/ePVaNZ/vwmH8WqGvDz3LrNYt/+gA55NDg6Pg==
+
pug-filters@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/pug-filters/-/pug-filters-4.0.0.tgz#d3e49af5ba8472e9b7a66d980e707ce9d2cc9b5e"
@@ -12879,11 +12884,11 @@ pug-walk@^2.0.0:
integrity sha512-yYELe9Q5q9IQhuvqsZNwA5hfPkMJ8u92bQLIMcsMxf/VADjNtEYptU+inlufAFYcWdHlwNfZOEnOOQrZrcyJCQ==
pug@^3.0.2:
- version "3.0.2"
- resolved "https://registry.yarnpkg.com/pug/-/pug-3.0.2.tgz#f35c7107343454e43bc27ae0ff76c731b78ea535"
- integrity sha512-bp0I/hiK1D1vChHh6EfDxtndHji55XP/ZJKwsRqrz6lRia6ZC2OZbdAymlxdVFwd1L70ebrVJw4/eZ79skrIaw==
+ version "3.0.3"
+ resolved "https://registry.yarnpkg.com/pug/-/pug-3.0.3.tgz#e18324a314cd022883b1e0372b8af3a1a99f7597"
+ integrity sha512-uBi6kmc9f3SZ3PXxqcHiUZLmIXgfgWooKWXcwSGwQd2Zi5Rb0bT14+8CJjJgI8AB+nndLaNgHGrcc6bPIB665g==
dependencies:
- pug-code-gen "^3.0.2"
+ pug-code-gen "^3.0.3"
pug-filters "^4.0.0"
pug-lexer "^5.0.1"
pug-linker "^4.0.0"
From d18ae245e7518dd43664765544646d1ba6ab302a Mon Sep 17 00:00:00 2001
From: Nathan Curtis
Date: Wed, 29 May 2024 09:36:52 -0700
Subject: [PATCH 23/27] [TM-938] Include the self-reported numbers in the
project/site high level metrics.
---
.../components/ProjectInformationAside/HighLevelMetrics.tsx | 3 +++
.../components/SiteInformationAside/HighLevelMetrics.tsx | 3 +++
2 files changed, 6 insertions(+)
diff --git a/src/admin/components/ResourceTabs/InformationTab/components/ProjectInformationAside/HighLevelMetrics.tsx b/src/admin/components/ResourceTabs/InformationTab/components/ProjectInformationAside/HighLevelMetrics.tsx
index d7b65969d..5bb288d1d 100644
--- a/src/admin/components/ResourceTabs/InformationTab/components/ProjectInformationAside/HighLevelMetrics.tsx
+++ b/src/admin/components/ResourceTabs/InformationTab/components/ProjectInformationAside/HighLevelMetrics.tsx
@@ -29,6 +29,9 @@ const HighLevelMetics: FC = () => {
+
+
+
diff --git a/src/admin/components/ResourceTabs/InformationTab/components/SiteInformationAside/HighLevelMetrics.tsx b/src/admin/components/ResourceTabs/InformationTab/components/SiteInformationAside/HighLevelMetrics.tsx
index 6311dbeb2..551aaa8ff 100644
--- a/src/admin/components/ResourceTabs/InformationTab/components/SiteInformationAside/HighLevelMetrics.tsx
+++ b/src/admin/components/ResourceTabs/InformationTab/components/SiteInformationAside/HighLevelMetrics.tsx
@@ -27,6 +27,9 @@ const HighLevelMetics: FC = () => {
+
+
+
From 561bed4d3d0688d547579d628a45e4609155fac7 Mon Sep 17 00:00:00 2001
From: Nathan Curtis
Date: Wed, 29 May 2024 10:28:13 -0700
Subject: [PATCH 24/27] [TM-938] Update labels after product review.
---
.../ProjectInformationAside/HighLevelMetrics.tsx | 8 ++++----
.../components/SiteInformationAside/HighLevelMetrics.tsx | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/admin/components/ResourceTabs/InformationTab/components/ProjectInformationAside/HighLevelMetrics.tsx b/src/admin/components/ResourceTabs/InformationTab/components/ProjectInformationAside/HighLevelMetrics.tsx
index 5bb288d1d..ee72b1cfe 100644
--- a/src/admin/components/ResourceTabs/InformationTab/components/ProjectInformationAside/HighLevelMetrics.tsx
+++ b/src/admin/components/ResourceTabs/InformationTab/components/ProjectInformationAside/HighLevelMetrics.tsx
@@ -26,12 +26,12 @@ const HighLevelMetics: FC = () => {
-
-
-
-
+
+
+
+
diff --git a/src/admin/components/ResourceTabs/InformationTab/components/SiteInformationAside/HighLevelMetrics.tsx b/src/admin/components/ResourceTabs/InformationTab/components/SiteInformationAside/HighLevelMetrics.tsx
index 551aaa8ff..d6fa709eb 100644
--- a/src/admin/components/ResourceTabs/InformationTab/components/SiteInformationAside/HighLevelMetrics.tsx
+++ b/src/admin/components/ResourceTabs/InformationTab/components/SiteInformationAside/HighLevelMetrics.tsx
@@ -24,12 +24,12 @@ const HighLevelMetics: FC = () => {
-
-
-
-
+
+
+
+
From 0384387883877d8931415bfc436ad5ecc1e65a1c Mon Sep 17 00:00:00 2001
From: Limber Mamani Vallejos
Date: Wed, 29 May 2024 14:06:17 -0400
Subject: [PATCH 25/27] feat: TM-936 change HBF -> Harit Bharat Fund
---
src/pages/nursery/[uuid]/index.page.tsx | 2 +-
src/pages/project/[uuid]/index.page.tsx | 2 +-
src/pages/site/[uuid]/index.page.tsx | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/pages/nursery/[uuid]/index.page.tsx b/src/pages/nursery/[uuid]/index.page.tsx
index 2560abd40..364552260 100644
--- a/src/pages/nursery/[uuid]/index.page.tsx
+++ b/src/pages/nursery/[uuid]/index.page.tsx
@@ -96,7 +96,7 @@ const NurseryDetailPage = () => {
nursery.framework_key === "ppc"
? t("Priceless Planet Coalition")
: nursery.framework_key === "hbf"
- ? "HBF"
+ ? "Harit Bharat Fund"
: t("TerraFund")
]}
hasBackButton={false}
diff --git a/src/pages/project/[uuid]/index.page.tsx b/src/pages/project/[uuid]/index.page.tsx
index 4b9d7bce0..8036db1b8 100644
--- a/src/pages/project/[uuid]/index.page.tsx
+++ b/src/pages/project/[uuid]/index.page.tsx
@@ -109,7 +109,7 @@ const ProjectDetailPage = () => {
isPPC
? t("Priceless Planet Coalition")
: isHBF
- ? "HBF"
+ ? "Harit Bharat Fund"
: isTerrafund
? t("TerraFund")
: reportingFramework.name
diff --git a/src/pages/site/[uuid]/index.page.tsx b/src/pages/site/[uuid]/index.page.tsx
index f6904f40c..6debfea7c 100644
--- a/src/pages/site/[uuid]/index.page.tsx
+++ b/src/pages/site/[uuid]/index.page.tsx
@@ -81,7 +81,7 @@ const SiteDetailPage = () => {
const subtitles = [
`${t("Organisation")}: ${site.organisation?.name}`,
- isPPC ? t("Priceless Planet Coalition") : isHBF ? "HBF" : t("TerraFund")
+ isPPC ? t("Priceless Planet Coalition") : isHBF ? "Harit Bharat Fund" : t("TerraFund")
];
if (isPPC) {
subtitles.push(t("Site ID: {id}", { id: site.ppc_external_id }));
From 610c8e13f6a1ddb240d34f427d1794312f40e58c Mon Sep 17 00:00:00 2001
From: Limber Mamani Vallejos
Date: Thu, 30 May 2024 10:27:20 -0400
Subject: [PATCH 26/27] feat: TM-936 change hbf -> Harit Bharat Fund to my
projects page
---
.../elements/Cards/ProjectCard/ProjectCard.tsx | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/components/elements/Cards/ProjectCard/ProjectCard.tsx b/src/components/elements/Cards/ProjectCard/ProjectCard.tsx
index 1241271b6..cfc7d0f1a 100644
--- a/src/components/elements/Cards/ProjectCard/ProjectCard.tsx
+++ b/src/components/elements/Cards/ProjectCard/ProjectCard.tsx
@@ -56,6 +56,12 @@ const ProjectCard = ({ project, onDelete, title, children, className, ...rest }:
);
};
+ const frameworkNames: { [key: string]: string } = {
+ ppc: "Priceless Planet Coalition",
+ hbf: "Harit Bharat Fund",
+ terrafund: "TerraFund"
+ };
+
return (
@@ -72,11 +78,7 @@ const ProjectCard = ({ project, onDelete, title, children, className, ...rest }:
{t("Framework")}:
- {project.framework_key === "ppc"
- ? t("Priceless Planet Coalition")
- : project.framework_key === "terrafund"
- ? t("TerraFund")
- : project.framework_key}
+ {frameworkNames[project.framework_key] ? t(frameworkNames[project.framework_key]) : project.framework_key}
From 9da6aa6e7735069b6ce35d537a812541fe38aa15 Mon Sep 17 00:00:00 2001
From: Jose Carlos Laura Ramirez
Date: Thu, 30 May 2024 12:48:18 -0400
Subject: [PATCH 27/27] [TM-938] revert: change workdays_count to
self_reported_workdays_count (#226)
---
src/pages/project/[uuid]/tabs/Overview.tsx | 6 +++++-
src/pages/site/[uuid]/tabs/Overview.tsx | 6 +++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/pages/project/[uuid]/tabs/Overview.tsx b/src/pages/project/[uuid]/tabs/Overview.tsx
index a1c11230d..40556f5f4 100644
--- a/src/pages/project/[uuid]/tabs/Overview.tsx
+++ b/src/pages/project/[uuid]/tabs/Overview.tsx
@@ -52,7 +52,11 @@ const ProjectOverviewTab = ({ project }: ProjectOverviewTabProps) => {