Skip to content

Commit

Permalink
[TM-1559] edit sidebar add text nowrap (#770)
Browse files Browse the repository at this point in the history
* [TM-1527] Update the defaults.

* [TM-1425] fix error color tag in table monitored (#766)

* [TM-1425] fix error color tag in table monitored

* [TM-1425] fix error table link

* [TM-1562] update terrafund report landing pages with new fields (#769)

* [TM-1559] fix error texct nowrap width

---------

Co-authored-by: Nathan Curtis <[email protected]>
Co-authored-by: Limber Mamani <[email protected]>
  • Loading branch information
3 people authored Dec 19, 2024
1 parent 4182272 commit 63eb149
Show file tree
Hide file tree
Showing 10 changed files with 337 additions and 97 deletions.
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-[92%] !text-nowrap"
defaultValue={[selectPolygonVersion?.uuid ?? selectedPolygon?.uuid] as string[]}
onChange={e => {
const polygonVersionData = (data as SitePolygonsDataResponse)?.find(item => item.uuid === e[0]);
Expand Down
139 changes: 139 additions & 0 deletions src/admin/components/Tables/TreeSpeciesTableTF.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import { Card, Divider, Typography } from "@mui/material";
import { Box, Stack } from "@mui/system";
import { DataGrid, GridColDef } from "@mui/x-data-grid";
import { useT } from "@transifex/react";
import { FC } from "react";
import { Else, If, Then } from "react-if";

import Text from "@/components/elements/Text/Text";
import Icon, { IconNames } from "@/components/extensive/Icon/Icon";
import { EstablishmentEntityType } from "@/connections/EstablishmentTrees";
import { useGetV2TreeSpeciesEntityUUID } from "@/generated/apiComponents";

type TreeSpeciesTableTFProps = {
uuid: string;
entity: EstablishmentEntityType;
total?: number;
totalText?: string;
title?: string;
countColumnName?: string;
collection?: string;
};

const TreeSpeciesTableTF: FC<TreeSpeciesTableTFProps> = ({
uuid,
entity,
total,
totalText,
title,
countColumnName,
collection = "tree-planted"
}) => {
const t = useT();
const { data: rows } = useGetV2TreeSpeciesEntityUUID({
pathParams: {
uuid,
entity: entity?.replace("Report", "-report")!
}
});

const columns: GridColDef[] = [
{
field: "name",
headerName: "SPECIES NAME",
flex: 1,
sortable: false,
filterable: false
},
{
field: "amount",
headerName: countColumnName ?? "TREE COUNT",
type: "number",
flex: 1,
headerAlign: "left",
align: "left",
sortable: false,
filterable: false
}
];

if (!rows || !rows.data) return null;

return (
<Card className="!shadow-none">
<Stack>
<Box paddingX={3} paddingY={2}>
<Text variant="text-24-bold" className="text-darkCustom">
{title ?? "N/A"}
</Text>
</Box>
<Box paddingX={3} paddingY={2}>
<div className="flex items-center gap-1">
<div className="flex h-10 w-10 items-center justify-center rounded-full bg-[#00000008]">
<Icon name={IconNames.TREE_DASHABOARD} className="text-primary" />
</div>
<Text variant="text-16-semibold" className="text-grey-500">
{totalText}:
</Text>
<Text variant="text-24-bold" className="text-black">
{new Intl.NumberFormat("en-US").format(total!) ?? "N/A"}
</Text>
</div>
</Box>

<Divider />

<If condition={rows.data.length > 0}>
<Then>
<DataGrid
rows={rows?.data.filter(row => row.collection == collection) as any}
columns={columns.map(column =>
column.field === "name"
? {
...column,
renderCell: params => (
<div className="flex items-center gap-1">
<Text variant="text-14-light" className="text-black">
{params?.row?.name}
</Text>
<div title={t("Non-Scientific Name")}>
<Icon
name={IconNames.NON_SCIENTIFIC_NAME_CUSTOM}
className="min-h-8 min-w-8 h-8 w-8 text-[#092C3C80]"
/>
</div>
</div>
)
}
: column
)}
getRowId={row => row.uuid}
sx={{
border: "none",
"& .MuiDataGrid-columnHeader": {
paddingX: 3
},
"& .MuiDataGrid-cell": {
paddingX: 3
}
}}
pageSizeOptions={[5, 10, 25, 50]}
initialState={{
pagination: {
paginationModel: { page: 0, pageSize: 5 }
}
}}
/>
</Then>
<Else>
<Box padding={3}>
<Typography>No {title} Recorded</Typography>
</Box>
</Else>
</If>
</Stack>
</Card>
);
};

export default TreeSpeciesTableTF;
8 changes: 8 additions & 0 deletions src/assets/icons/assisted-natural-regeneration.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/icons/non-scientific name custom.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/tree-dashboard.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions src/components/elements/Field/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ import { DetailedHTMLProps, FC, HTMLAttributes } from "react";

import Text from "@/components/elements/Text/Text";
import { withFrameworkShow } from "@/context/framework.provider";
import { TextVariants } from "@/types/common";

import BaseField from "./BaseField";

export interface TextFieldProps extends DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
label: string;
value: string;
variantLabel?: TextVariants;
}

const TextField: FC<TextFieldProps> = ({ label, value, className, ...rest }) => (
const TextField: FC<TextFieldProps> = ({ label, value, variantLabel = "text-16-bold", className, ...rest }) => (
<BaseField {...rest} className={className}>
<div className="flex items-center justify-between">
<Text variant="text-16-bold">{label}</Text>
<Text variant={variantLabel!}>{label}</Text>
<Text variant="text-16-light">{value || "N/A"}</Text>
</div>
</BaseField>
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
5 changes: 4 additions & 1 deletion src/components/extensive/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ export enum IconNames {
TRASH_TA = "trash-ta",
EDIT_TA = "edit-ta",
NON_SCIENTIFIC_NAME = "non-scientific name",
NEW_TAG_TREE_SPECIES = "new-tag-tree-species"
NEW_TAG_TREE_SPECIES = "new-tag-tree-species",
NON_SCIENTIFIC_NAME_CUSTOM = "non-scientific name custom",
TREE_DASHABOARD = "tree-dashboard",
ASSISTED_NATURAL_REGENERATION = "assisted-natural-regeneration"
}

export interface IconProps {
Expand Down
Loading

0 comments on commit 63eb149

Please sign in to comment.