Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into merge/main-staging-po…
Browse files Browse the repository at this point in the history
…st-uu

# Conflicts:
#	src/pages/reports/site-report/[uuid].page.tsx
  • Loading branch information
roguenet committed Dec 20, 2024
2 parents f2becf1 + 348b037 commit f9009ef
Show file tree
Hide file tree
Showing 29 changed files with 1,828 additions and 328 deletions.
8 changes: 8 additions & 0 deletions openapi-codegen.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,39 @@ type EnvironmentName = (typeof ENVIRONMENT_NAMES)[number];
type Environment = {
apiBaseUrl: string;
userServiceUrl: string;
jobServiceUrl: string;
entityServiceUrl: string;
};

const ENVIRONMENTS: { [Property in EnvironmentName]: Environment } = {
local: {
apiBaseUrl: "http://localhost:8080",
userServiceUrl: "http://localhost:4010",
jobServiceUrl: "http://localhost:4020",
entityServiceUrl: "http://localhost:4050"
},
dev: {
apiBaseUrl: "https://api-dev.terramatch.org",
userServiceUrl: "https://api-dev.terramatch.org",
jobServiceUrl: "https://api-dev.terramatch.org",
entityServiceUrl: "https://api-dev.terramatch.org"
},
test: {
apiBaseUrl: "https://api-test.terramatch.org",
userServiceUrl: "https://api-test.terramatch.org",
jobServiceUrl: "https://api-test.terramatch.org",
entityServiceUrl: "https://api-test.terramatch.org"
},
staging: {
apiBaseUrl: "https://api-staging.terramatch.org",
userServiceUrl: "https://api-staging.terramatch.org",
jobServiceUrl: "https://api-staging.terramatch.org",
entityServiceUrl: "https://api-staging.terramatch.org"
},
prod: {
apiBaseUrl: "https://api.terramatch.org",
userServiceUrl: "https://api.terramatch.org",
jobServiceUrl: "https://api.terramatch.org",
entityServiceUrl: "https://api.terramatch.org"
}
};
Expand All @@ -66,6 +72,7 @@ if (!ENVIRONMENT_NAMES.includes(declaredEnv as EnvironmentName)) {
const DEFAULTS = ENVIRONMENTS[declaredEnv];
const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL ?? DEFAULTS.apiBaseUrl;
const userServiceUrl = process.env.NEXT_PUBLIC_USER_SERVICE_URL ?? DEFAULTS.userServiceUrl;
const jobServiceUrl = process.env.NEXT_PUBLIC_JOB_SERVICE_URL ?? DEFAULTS.jobServiceUrl;
const entityServiceUrl = process.env.NEXT_PUBLIC_ENTITY_SERVICE_URL ?? DEFAULTS.entityServiceUrl;

// The services defined in the v3 Node BE codebase. Although the URL path for APIs in the v3 space
Expand All @@ -74,6 +81,7 @@ const entityServiceUrl = process.env.NEXT_PUBLIC_ENTITY_SERVICE_URL ?? DEFAULTS.
// the associated BE code is for a given FE API integration.
const SERVICES = {
"user-service": userServiceUrl,
"job-service": jobServiceUrl,
"entity-service": entityServiceUrl
};

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"generate:api": "openapi-codegen gen api",
"generate:jobService": "openapi-codegen gen jobService",
"generate:userService": "openapi-codegen gen userService",
"generate:entityService": "openapi-codegen gen entityService",
"generate:services": "yarn generate:userService && yarn generate:entityService",
"generate:services": "yarn generate:userService && yarn generate:entityService && yarn generate:jobService",
"tx:push": "eval $(grep '^TRANSIFEX_TOKEN' .env) && eval $(grep '^TRANSIFEX_SECRET' .env) && txjs-cli push --key-generator=hash src/ --token=$TRANSIFEX_TOKEN --secret=$TRANSIFEX_SECRET",
"tx:pull": "eval $(grep '^TRANSIFEX_TOKEN' .env) && eval $(grep '^TRANSIFEX_SECRET' .env) && txjs-cli pull --token=$TRANSIFEX_TOKEN --secret=$TRANSIFEX_SECRET"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ const VersionHistory = ({
placeholder="Select Polygon Version"
options={polygonVersionData ?? []}
optionVariant="text-12-light"
titleClassname="one-line-text !w-[96%] !text-nowrap"
titleClassname="one-line-text !w-full !text-nowrap"
titleContainerClassName="!w-[calc(100%-25px)] !text-nowrap"
defaultValue={[selectPolygonVersion?.uuid ?? selectedPolygon?.uuid] as string[]}
onChange={e => {
const polygonVersionData = (data as SitePolygonsDataResponse)?.find(item => item.uuid === e[0]);
Expand Down
52 changes: 38 additions & 14 deletions src/admin/components/ResourceTabs/PolygonReviewTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,15 @@ const PolygonReviewTab: FC<IProps> = props => {
<div className="w-40 lg:w-48">
<Text variant="text-14" className="flex items-center gap-1 text-darkCustom">
Site Status
<ToolTip title={""} content={"Site Status"} width="" trigger="click">
<Icon name={IconNames.IC_INFO} className="h-3.5 w-3.5 text-darkCustom" />
<ToolTip
title={""}
content={
"Site status indicates the current status of the site. Active sites that have been approved by project managers will have the status: Restoration in Progress."
}
width="w-64 lg:w-72"
trigger="click"
>
<Icon name={IconNames.IC_INFO} className="h-3.5 w-3.5 text-darkCustom lg:h-4 lg:w-4" />
</ToolTip>
</Text>
<Text variant="text-14-bold" className="leading-[normal] text-black">
Expand All @@ -640,8 +647,15 @@ const PolygonReviewTab: FC<IProps> = props => {
<div className="w-full">
<Text variant="text-14" className="mb-2 flex items-center gap-1 text-darkCustom">
Polygon Overview
<ToolTip title={""} content={"Polygon Overview"} width="" trigger="click">
<Icon name={IconNames.IC_INFO} className="h-3.5 w-3.5 text-darkCustom" />
<ToolTip
title={""}
content={
"This graphic displays the breakdown of polygon statuses for this site. Approved Polygons are ready for monitoring, but all other statuses require polygon validation and approval. Use the “Check Polygon” and “Approve Polygon” features below to validate and approve the remaining polygons."
}
width="w-72 lg:w-80"
trigger="click"
>
<Icon name={IconNames.IC_INFO} className="h-3.5 w-3.5 text-darkCustom lg:h-4 lg:w-4" />
</ToolTip>
</Text>
<If condition={sitePolygonData.length < total}>
Expand All @@ -660,9 +674,6 @@ const PolygonReviewTab: FC<IProps> = props => {
<div className="mb-2">
<Text variant="text-16-bold" className="mb-2 flex items-center gap-1 text-darkCustom">
Add or Edit Polygons
<ToolTip title={""} content={"Add or Edit Polygons"} width="" trigger="click">
<Icon name={IconNames.IC_INFO} className="h-3.5 w-3.5 text-darkCustom" />
</ToolTip>
</Text>
<Text variant="text-14-light" className="text-darkCustom">
Add, remove or edit polygons that are associated to a site. Polygons may be edited in the map
Expand Down Expand Up @@ -742,7 +753,7 @@ const PolygonReviewTab: FC<IProps> = props => {
pagination: { pageSize: 10000000 }
}}
columns={[
{ header: "Polygon Name", accessorKey: "polygon-name" },
{ header: "Polygon Name", accessorKey: "polygon-name", meta: { style: { width: "14.63%" } } },
{
header: "Restoration Practice",
accessorKey: "restoration-practice",
Expand All @@ -751,15 +762,28 @@ const PolygonReviewTab: FC<IProps> = props => {
return (
<input
placeholder={placeholder}
className="w-[118px] px-[10px] outline-primary placeholder:text-[currentColor]"
className="text-14 w-full px-[10px] outline-primary placeholder:text-[currentColor]"
/>
);
}
},
meta: { style: { width: "17.63%" } }
},
{
header: "Target Land Use System",
accessorKey: "target-land-use-system",
meta: { style: { width: "20.63%" } }
},
{
header: "Tree Distribution",
accessorKey: "tree-distribution",
meta: { style: { width: "15.63%" } }
},
{
header: "Planting Start Date",
accessorKey: "planting-start-date",
meta: { style: { width: "17.63%" } }
},
{ header: "Target Land Use System", accessorKey: "target-land-use-system" },
{ header: "Tree Distribution", accessorKey: "tree-distribution" },
{ header: "Planting Start Date", accessorKey: "planting-start-date" },
{ header: "Source", accessorKey: "source" },
{ header: "Source", accessorKey: "source", meta: { style: { width: "10.63%" } } },
{
header: "",
accessorKey: "ellipse",
Expand Down
9 changes: 8 additions & 1 deletion src/components/elements/Inputs/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface DropdownProps {
onInternalError?: (error: ErrorOption) => void;
showSelectAll?: boolean;
titleClassname?: string;
titleContainerClassName?: string;
}
const otherKey = "other#value#key";
const getAllowedValues = (values: OptionValue[], options: Option[]) =>
Expand Down Expand Up @@ -206,7 +207,13 @@ const Dropdown = (props: PropsWithChildren<DropdownProps>) => {
)}
>
<When condition={!!props.prefix}>{props.prefix}</When>
<div className={tw("flex items-center gap-2", variant.titleContainerClassName)}>
<div
className={tw(
"flex items-center gap-2",
variant.titleContainerClassName,
props.titleContainerClassName
)}
>
<Text
variant={props.inputVariant ?? "text-14-light"}
className={tw("w-full", variant.titleClassname, props.titleClassname)}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { useT } from "@transifex/react";

import Button from "@/components/elements/Button/Button";
import TreeSpeciesModal from "@/components/elements/Inputs/TreeSpeciesInput/TreeSpeciesModal";
import { ModalId } from "@/components/extensive/Modal/ModalConst";
import { useModalContext } from "@/context/modal.provider";

const NonScientificConfirmationModal = ({ onConfirm }: { onConfirm: () => void }) => {
const t = useT();
const { closeModal } = useModalContext();

return (
<TreeSpeciesModal
title={t("Your input is a not a scientific name")}
content={t("You can add this species, but it will be pending review from Admin.")}
buttons={
<>
<Button variant="secondary" onClick={() => closeModal(ModalId.ERROR_MODAL)}>
{t("CANCEL")}
</Button>
<Button
variant="primary"
onClick={() => {
closeModal(ModalId.ERROR_MODAL);
onConfirm();
}}
>
{t("CONFIRM")}
</Button>
</>
}
/>
);
};

export default NonScientificConfirmationModal;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface RHFSeedingTableInputProps
UseControllerProps {
collection?: string;
onChangeCapture?: () => void;
formHook?: UseFormReturn;
formHook: UseFormReturn;
}

/**
Expand All @@ -19,12 +19,14 @@ export interface RHFSeedingTableInputProps
const RHFSeedingTableInput = (props: PropsWithChildren<RHFSeedingTableInputProps>) => {
const t = useT();
const {
field: { value, onChange }
field: { onChange }
} = useController(props);
const { formHook, collection } = props;

const value = formHook.watch(props.name);

const clearErrors = useCallback(() => {
formHook?.clearErrors(props.name);
formHook.clearErrors(props.name);
}, [formHook, props.name]);

return (
Expand All @@ -39,7 +41,7 @@ const RHFSeedingTableInput = (props: PropsWithChildren<RHFSeedingTableInputProps
collection={collection}
clearErrors={clearErrors}
onError={() =>
props.formHook?.setError(props.name, { message: t("One or more values are missing"), type: "required" })
props.formHook.setError(props.name, { message: t("One or more values are missing"), type: "required" })
}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import TreeSpeciesInput, { TreeSpeciesInputProps } from "./TreeSpeciesInput";
export interface RHFTreeSpeciesInputProps
extends Omit<TreeSpeciesInputProps, "value" | "onChange" | "clearErrors">,
UseControllerProps {
formHook?: UseFormReturn;
formHook: UseFormReturn;
}

/**
Expand All @@ -17,18 +17,20 @@ export interface RHFTreeSpeciesInputProps
const RHFTreeSpeciesInput = (props: PropsWithChildren<RHFTreeSpeciesInputProps>) => {
const t = useT();
const {
field: { value, onChange }
field: { onChange }
} = useController(props);
const { formHook, collection } = props;

const value = formHook.watch(props.name);

const clearErrors = useCallback(() => {
formHook?.clearErrors(props.name);
formHook.clearErrors(props.name);
}, [formHook, props.name]);

return (
<TreeSpeciesInput
{...props}
title={t("Tree Species")}
title={t("Species")}
buttonCaptionSuffix={t("Species")}
withPreviousCounts={true}
useTaxonomicBackbone={true}
Expand All @@ -37,7 +39,7 @@ const RHFTreeSpeciesInput = (props: PropsWithChildren<RHFTreeSpeciesInputProps>)
collection={collection}
clearErrors={clearErrors}
onError={() =>
props.formHook?.setError(props.name, { message: t("One or more values are missing"), type: "required" })
props.formHook.setError(props.name, { message: t("One or more values are missing"), type: "required" })
}
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { useT } from "@transifex/react";

import Button from "@/components/elements/Button/Button";
import TreeSpeciesModal from "@/components/elements/Inputs/TreeSpeciesInput/TreeSpeciesModal";
import { ModalId } from "@/components/extensive/Modal/ModalConst";
import { useModalContext } from "@/context/modal.provider";

const SpeciesAlreadyExistsModal = ({ speciesName }: { speciesName: string }) => {
const { closeModal } = useModalContext();
const t = useT();

return (
<TreeSpeciesModal
title={t("Species {name} already included", { name: speciesName })}
content={t("Please find species below to enter reported value.")}
buttons={
<>
<Button variant="secondary" onClick={() => closeModal(ModalId.ERROR_MODAL)}>
{t("CONTINUE")}
</Button>
</>
}
/>
);
};

export default SpeciesAlreadyExistsModal;
Loading

0 comments on commit f9009ef

Please sign in to comment.