Skip to content

Commit

Permalink
Merge branch 'staging' of https://github.com/wri/wri-terramatch-website
Browse files Browse the repository at this point in the history
… into epic/new_design
  • Loading branch information
dottyy committed Jun 3, 2024
2 parents 18ec8ac + f3ba18b commit 7c52f73
Show file tree
Hide file tree
Showing 42 changed files with 1,104 additions and 220 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: pull-request
on:
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
2 changes: 1 addition & 1 deletion .jest/setEnvVars.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
process.env.NODE_ENV = "test";
process.env.NEXT_PUBLIC_API_BASE_URL = "https://test.wrirestorationmarketplace.cubeapis.com";
process.env.NEXT_PUBLIC_API_BASE_URL = "https://new-wri-staging.wri-restoration-marketplace-api.com";
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.17.0
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ const HighLevelMetics: FC = () => {
</Labeled>
</When>
<When condition={record?.framework_key === "ppc"}>
<Labeled label="Workdays Created" sx={inlineLabelSx}>
<Labeled label="Workdays Created (Old Calculation)" sx={inlineLabelSx}>
<NumberField source="self_reported_workday_count" emptyText="0" />
</Labeled>
<Labeled label="Workdays Created (New Calculation)" sx={inlineLabelSx}>
<NumberField source="workday_count" emptyText="0" />
</Labeled>
</When>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ const HighLevelMetics: FC = () => {
<Box paddingX={3.75} paddingY={2}>
<Stack gap={3}>
<When condition={isPPC}>
<Labeled label="Total Number Of Workdays Created" sx={inlineLabelSx}>
<Labeled label="Workdays Created (Old Calculation)" sx={inlineLabelSx}>
<NumberField source="self_reported_workday_count" emptyText="0" />
</Labeled>
<Labeled label="Workdays Created (New Calculation)" sx={inlineLabelSx}>
<NumberField source="workday_count" emptyText="0" />
</Labeled>
</When>
Expand Down
40 changes: 21 additions & 19 deletions src/admin/modules/nurseries/components/NurseriesList.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 (
<Datagrid bulkActionButtons={<CustomBulkDeleteWithConfirmButton source="name" />}>
<TextField source="name" label="Nursery Name" />
Expand All @@ -41,6 +44,15 @@ const NurseryDataGrid: FC = () => {
<TextField source="project.name" label="Project Name" />
<TextField source="organisation.name" label="Organization" />
<DateField source="start_date" label="Establishment" locales="en-GB" />
<FunctionField
source="framework_key"
label="Framework"
render={(record: any) =>
frameworkChoices.find((framework: any) => framework.id === record?.framework_key)?.name ??
record?.framework_key
}
sortable={false}
/>
<ShowButton />
<EditButton />
<WrapperField>
Expand All @@ -51,7 +63,7 @@ const NurseryDataGrid: FC = () => {
};

export const NurseriesList: FC = () => {
const [exporting, setExporting] = useState<boolean>(false);
const frameworkChoices = useFrameworkChoices();

const filters = [
<SearchInput key="search" source="search" alwaysOn />,
Expand All @@ -68,6 +80,7 @@ export const NurseriesList: FC = () => {
>
<AutocompleteInput optionText="name" label="Organization" />
</ReferenceInput>,
<SelectInput key="framework_key" label="Framework" source="framework_key" choices={frameworkChoices} />,
<SelectInput key="status" label="Status" source="status" choices={optionToChoices(getStatusOptions())} />,
<SelectInput
key="update_request_status"
Expand All @@ -89,20 +102,7 @@ export const NurseriesList: FC = () => {
</ReferenceInput>
];

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 (
<>
Expand All @@ -112,10 +112,12 @@ export const NurseriesList: FC = () => {
<Divider />
</Stack>

<List actions={<ListActions onExport={handleExport} />} filters={filters}>
<List actions={<ListActions onExport={openExportDialog} />} filters={filters}>
<NurseryDataGrid />
</List>

<FrameworkSelectionDialog {...frameworkDialogProps} />

<ExportProcessingAlert show={exporting} />
</>
);
Expand Down
40 changes: 21 additions & 19 deletions src/admin/modules/nurseryReports/components/NurseryReportsList.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 (
<Datagrid bulkActionButtons={<CustomBulkDeleteWithConfirmButton source="title" />}>
<TextField source="nursery.name" label="Nursery Name" sortable={false} />
Expand All @@ -41,14 +44,23 @@ const NurseryReportDataGrid: FC = () => {
<DateField source="due_at" label="Due Date" locales="en-GB" />
<DateField source="updated_at" label="Last Updated" locales="en-GB" />
<DateField source="submitted_at" label="Date Submitted" locales="en-GB" />
<FunctionField
source="framework_key"
label="Framework"
render={(record: any) =>
frameworkChoices.find((framework: any) => framework.id === record?.framework_key)?.name ??
record?.framework_key
}
sortable={false}
/>
<ShowButton />
<EditButton />
</Datagrid>
);
};

export const NurseryReportsList: FC = () => {
const [exporting, setExporting] = useState<boolean>(false);
const frameworkChoices = useFrameworkChoices();

const filters = [
<SearchInput key="search" source="search" alwaysOn />,
Expand Down Expand Up @@ -77,6 +89,7 @@ export const NurseryReportsList: FC = () => {
<AutocompleteInput optionText="name" label="Nursery" />
</ReferenceInput>,
<SelectInput key="country" label="Country" source="country" choices={optionToChoices(getCountriesOptions())} />,
<SelectInput key="framework_key" label="Framework" source="framework_key" choices={frameworkChoices} />,
<SelectInput key="status" label="Status" source="status" choices={optionToChoices(getReportStatusOptions())} />,
<SelectInput
key="update_request_status"
Expand All @@ -86,20 +99,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 (
<>
Expand All @@ -109,10 +109,12 @@ export const NurseryReportsList: FC = () => {
<Divider />
</Stack>

<List actions={<ListActions onExport={handleExport} />} filters={filters}>
<List actions={<ListActions onExport={openExportDialog} />} filters={filters}>
<NurseryReportDataGrid />
</List>

<FrameworkSelectionDialog {...frameworkDialogProps} />

<ExportProcessingAlert show={exporting} />
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ exports[`Storyshots Components/Elements/Cards/FundingCard Default 1`] = `
Location:
</p>
<p
className="text-light-caption-200"
className="max-h-10 overflow-hidden text-light-caption-200"
data-testid="txt"
>
London, United Kingdom
Expand All @@ -54,10 +54,10 @@ exports[`Storyshots Components/Elements/Cards/FundingCard Default 1`] = `
The funding application is designed for restoration projects in Africa. This application provides an opportunity for project developers to seek financial support for their restoration initiatives across the African continent.
</p>
<div
className="mt-8 flex gap-3"
className="mt-4 flex flex-col gap-3 sm:flex-row"
>
<a
className="flex-1 bg-white border border-neutral-1000 hover:border-primary-500 disabled:border-neutral-1000 py-1.75 rounded-md px-10 uppercase disabled:bg-neutral-300 disabled:text-neutral-800 transition whitespace-nowrap text-black h-8 flex items-center justify-center gap-1.5 tracking-wide w-fit-content"
className="w-full flex-1 bg-white border border-neutral-1000 hover:border-primary-500 disabled:border-neutral-1000 py-1.75 rounded-md px-10 uppercase disabled:bg-neutral-300 disabled:text-neutral-800 transition whitespace-nowrap text-black h-8 flex items-center justify-center gap-1.5 tracking-wide w-fit-content"
disabled={false}
href="#"
onClick={[Function]}
Expand All @@ -80,7 +80,7 @@ exports[`Storyshots Components/Elements/Cards/FundingCard Default 1`] = `
</span>
</a>
<a
className="flex-1 bg-primary-500 hover:bg-primary-400 py-2 rounded-md px-10 uppercase disabled:bg-neutral-300 disabled:text-neutral-800 transition whitespace-nowrap text-black h-8 flex items-center justify-center gap-1.5 tracking-wide w-fit-content"
className="w-full flex-1 bg-primary-500 hover:bg-primary-400 py-2 rounded-md px-10 uppercase disabled:bg-neutral-300 disabled:text-neutral-800 transition whitespace-nowrap text-black h-8 flex items-center justify-center gap-1.5 tracking-wide w-fit-content"
disabled={false}
href="#"
onClick={[Function]}
Expand Down
12 changes: 7 additions & 5 deletions src/components/elements/Cards/ProjectCard/ProjectCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Paper {...rest} className={classNames(className, "p-0")}>
<div className="flex items-center gap-4 border-b border-neutral-100 px-8 py-6">
Expand All @@ -72,11 +78,7 @@ const ProjectCard = ({ project, onDelete, title, children, className, ...rest }:
<div className="flex">
<Text variant="text-bold-subtitle-500">{t("Framework")}:&#160;</Text>
<Text variant="text-light-subtitle-400" className="capitalize">
{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}
</Text>
</div>
<div className="flex">
Expand Down
Loading

0 comments on commit 7c52f73

Please sign in to comment.