Skip to content

Commit

Permalink
[TM-1563] Audit Log [Site, Nursery, Project Admin Views]: Extend the …
Browse files Browse the repository at this point in the history
…width of the audit log (#757)
  • Loading branch information
dottyy authored Dec 17, 2024
1 parent 1ebedd9 commit efcec32
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 29 deletions.
31 changes: 31 additions & 0 deletions src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { NURSERY_REPORT, PROJECT_REPORT, SITE_REPORT } from "@/constants/entitie
import useAuditLogActions from "@/hooks/AuditStatus/useAuditLogActions";

import AuditLogSiteTabSelection from "./components/AuditLogSiteTabSelection";
import AuditLogTable from "./components/AuditLogTable";
import SiteAuditLogEntityStatus from "./components/SiteAuditLogEntityStatus";
import SiteAuditLogEntityStatusSide from "./components/SiteAuditLogEntityStatusSide";
import SiteAuditLogProjectStatus from "./components/SiteAuditLogProjectStatus";
Expand Down Expand Up @@ -58,6 +59,10 @@ const AuditLogTab: FC<IProps> = ({ label, entity, ...rest }) => {
loadEntityList();
}, [buttonToggle]);

const isSite = buttonToggle === AuditLogButtonStates.SITE;
const redirectTo = `${basename}/${modules.site.ResourceName}/${selected?.uuid}/show/6`;
const title = () => selected?.title ?? selected?.name;

const verifyEntity = ["reports", "nursery"].some(word => ReverseButtonStates2[entity!].includes(word));

const verifyEntityReport = () => {
Expand Down Expand Up @@ -133,6 +138,32 @@ const AuditLogTab: FC<IProps> = ({ label, entity, ...rest }) => {
/>
</Grid>
</Grid>
<div className="px-2 py-2">
<When condition={buttonToggle === AuditLogButtonStates.PROJECT && !record?.project}>
<Text variant="text-16-bold" className="mb-6">
History and Discussion for {record && record?.name}
</Text>
{auditLogData && <AuditLogTable auditLogData={auditLogData} auditData={auditData} refresh={refetch} />}
</When>
<When condition={buttonToggle !== AuditLogButtonStates.PROJECT || verifyEntity}>
<>
<div className="mb-6">
{!isSite && !verifyEntity && <Text variant="text-16-bold">History and Discussion for {title()}</Text>}
{(isSite || verifyEntity) && (
<Text variant="text-16-bold">
History and Discussion for{" "}
<Link className="text-16-bold !text-[#000000DD]" to={redirectTo}>
{title()}
</Link>
</Text>
)}
</div>
<When condition={!!auditLogData}>
<AuditLogTable auditLogData={auditLogData!} auditData={auditData} refresh={refetch} />
</When>
</>
</When>
</div>
</TabbedShowLayout.Tab>
</When>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,26 @@ const SiteAuditLogEntityStatus: FC<SiteAuditLogEntityStatusProps> = ({
</Text>
<CommentarySection record={record} entity={entityType} refresh={refresh} viewCommentsList={false} />
</div>
<div>
{!isSite && !verifyEntity && <Text variant="text-16-bold">History and Discussion for {title()}</Text>}
{(isSite || verifyEntity) && (
<Text variant="text-16-bold">
History and Discussion for{" "}
{viewPD ? (
<Link className="text-16-bold !text-[#000000DD]" href={redirectTo}>
{title()}
</Link>
) : (
<RaLink className="text-16-bold !text-[#000000DD]" to={redirectTo}>
{title()}
</RaLink>
)}
</Text>
)}
</div>
<When condition={!!auditLogData}>
<When condition={viewPD}>
<div>
{!isSite && !verifyEntity && <Text variant="text-16-bold">History and Discussion for {title()}</Text>}
{(isSite || verifyEntity) && (
<Text variant="text-16-bold">
History and Discussion for{" "}
{viewPD ? (
<Link className="text-16-bold !text-[#000000DD]" href={redirectTo}>
{title()}
</Link>
) : (
<RaLink className="text-16-bold !text-[#000000DD]" to={redirectTo}>
{title()}
</RaLink>
)}
</Text>
)}
</div>
</When>
<When condition={!!auditLogData && viewPD}>
<AuditLogTable auditLogData={auditLogData!} auditData={auditData} refresh={refresh} />
</When>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FC } from "react";
import { When } from "react-if";

import Text from "@/components/elements/Text/Text";
import { AuditStatusResponse, ProjectLiteRead } from "@/generated/apiSchemas";
Expand All @@ -10,13 +11,15 @@ export interface SiteAuditLogProjectStatusProps {
auditLogData?: { data: AuditStatusResponse[] };
auditData?: { entity: string; entity_uuid: string };
refresh?: () => void;
viewPD?: boolean;
}

const SiteAuditLogProjectStatus: FC<SiteAuditLogProjectStatusProps> = ({
record,
auditLogData,
auditData,
refresh
refresh,
viewPD = false
}) => (
<div className="flex flex-col gap-6">
<div>
Expand All @@ -27,8 +30,10 @@ const SiteAuditLogProjectStatus: FC<SiteAuditLogProjectStatusProps> = ({
Update the project status, view updates, or add comments
</Text>
</div>
<Text variant="text-16-bold">History and Discussion for {record && record?.name}</Text>
{auditLogData && <AuditLogTable auditLogData={auditLogData} auditData={auditData} refresh={refresh} />}
<When condition={viewPD}>
<Text variant="text-16-bold">History and Discussion for {record && record?.name}</Text>
{auditLogData && <AuditLogTable auditLogData={auditLogData} auditData={auditData} refresh={refresh} />}
</When>
</div>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ const DataCard = ({
hidden: selected.includes("6")
})}
optionsClassName="!w-max right-0"
className="w-max"
className="!h-8 w-max"
options={polygonOptions}
defaultValue={["0"]}
onChange={option => setSelectedPolygonUuid(option[0])}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ const EcoRegionDoughnutChart: React.FC<EcoRegionDoughnutChartProps> = ({ data })
};

return (
<div className="relative flex h-80 w-full items-center justify-center">
<div className="relative flex h-[380px] w-full flex-col items-center justify-center p-4 pt-0">
<h2 className="text-14 w-full pl-10 uppercase text-darkCustom">Hectares Under Restoration By WWF EcoRegion</h2>
<ResponsiveContainer width="100%" height="100%">
<PieChart>
<Tooltip content={<CustomTooltip />} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,12 @@ const MonitoredCharts = ({
case "5":
return (
<ChartContainer isLoading={isLoadingIndicator} hasNoData={!landUseData?.graphicTargetLandUseTypes?.length}>
<div className="w-full pt-[38px]">
<GraphicIconDashboard data={landUseData.graphicTargetLandUseTypes} maxValue={totalHectaresRestoredGoal} />
<div className="w-full">
<GraphicIconDashboard
title="Hectares Under Restoration By Target Land Use System"
data={landUseData.graphicTargetLandUseTypes}
maxValue={totalHectaresRestoredGoal}
/>
</div>
</ChartContainer>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const TreeLossBarChart = ({ data, className = "" }: TreeLossBarChartProps) => {
};

return (
<div className={`h-[500px] w-full p-4 ${className} pt-2.5`}>
<h2 className="text-12 mb-1 pl-10">Tree Loss Retrospective (ha)</h2>
<div className={`h-[500px] w-full p-4 ${className} pt-0`}>
<h2 className="text-14 mb-3 pl-10 uppercase text-darkCustom">Tree Loss Retrospective (ha)</h2>
<h3 className="text-14-semibold mb-4 pl-10">2015-2024</h3>
<ResponsiveContainer width="100%" height="100%">
<BarChart
Expand Down
15 changes: 14 additions & 1 deletion src/pages/dashboard/components/GraphicIconDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ import { getPercentage } from "@/utils/dashboardUtils";

import { DashboardTableDataProps } from "../index.page";

const GraphicIconDashboard = ({ data, maxValue }: { data: DashboardTableDataProps[]; maxValue: number }) => {
const GraphicIconDashboard = ({
data,
maxValue,
title
}: {
data: DashboardTableDataProps[];
maxValue: number;
title?: string;
}) => {
const t = useT();
const [tooltip, setTooltip] = useState<{
text: string | null;
Expand Down Expand Up @@ -67,6 +75,11 @@ const GraphicIconDashboard = ({ data, maxValue }: { data: DashboardTableDataProp

return (
<div className="relative grid w-full gap-4">
<When condition={title}>
<Text variant="text-14" className="text-14 mb-1 uppercase text-darkCustom">
{title}
</Text>
</When>
<When condition={data.length > 0}>
<div className="relative flex h-9 w-full rounded bg-blueCustom-30 first:rounded-l first-of-type:rounded-l lg:h-10">
{data.map((item, index) => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/project/[uuid]/tabs/AuditLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const AuditLog = ({ label, project, refresh: refreshProject, enableChangeStatus,
<div className="grid w-[64%] gap-6">
<AuditLogSiteTabSelection buttonToggle={buttonToggle} setButtonToggle={setButtonToggle} />
<When condition={buttonToggle === ButtonStates.PROJECTS}>
<SiteAuditLogProjectStatus record={project} auditLogData={auditLogData} />
<SiteAuditLogProjectStatus viewPD={true} record={project} auditLogData={auditLogData} />
</When>
<When condition={buttonToggle !== ButtonStates.PROJECTS}>
<SiteAuditLogEntityStatus
Expand Down

0 comments on commit efcec32

Please sign in to comment.