-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add contaminant data and implementation ideas to cccv pdf
- Loading branch information
wtcarter-gw
committed
Jun 25, 2024
1 parent
44c961b
commit c48df9c
Showing
8 changed files
with
89 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 34 additions & 38 deletions
72
packages/cccv/src/components/Contaminants/Contaminants.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,54 @@ | ||
import React, {useState} from "react"; | ||
import {ContaminantList} from "@components/FreshwaterManagementUnit/utils.ts"; | ||
import {ChevronUpIcon, ChevronDownIcon} from '@heroicons/react/20/solid'; | ||
import React, { useState } from "react"; | ||
import { ContaminantList } from "@components/FreshwaterManagementUnit/utils.ts"; | ||
import { ChevronUpIcon, ChevronDownIcon } from '@heroicons/react/20/solid'; | ||
import { | ||
getObjectiveDescription, | ||
contaminantTitle, | ||
byWhen | ||
} from "@components/Contaminants/ContaminantObjectiveDescription"; | ||
|
||
|
||
export const Contaminants: React.FC<{ contaminants: ContaminantList }> = ({contaminants}) => { | ||
export const Contaminants: React.FC<{ contaminants: ContaminantList }> = ({ contaminants }) => { | ||
const [expandedRows, setExpandedRows] = useState<{ [key: string]: boolean }>({}); | ||
|
||
const handleRowClick = (title: string) => { | ||
setExpandedRows(prevState => ({...prevState, [title]: !prevState[title]})); | ||
setExpandedRows(prevState => ({ ...prevState, [title]: !prevState[title] })); | ||
}; | ||
|
||
return ( | ||
<div> | ||
{contaminants.map((contaminant, index) => ( | ||
<table className="min-w-full mb-4" key={index}> | ||
<thead> | ||
<tr className="pb-0"> | ||
<th colSpan={1} /> | ||
<th colSpan={2} className="px-4 text-left text-sm font-semibold">{contaminantTitle(contaminant)}</th> | ||
</tr> | ||
</thead> | ||
<tbody className="divide-y divide-gray-200"> | ||
<tr onClick={() => handleRowClick(contaminant.title)} className="cursor-pointer border-b border-gray-200"> | ||
<th className="px-1 text-left text-sm font-medium text-gray-600"> | ||
{expandedRows[contaminant.title] ? <ChevronUpIcon className="h-6 w-6 text-blue-500"/> : | ||
<ChevronDownIcon className="h-6 w-6 text-blue-500"/>} | ||
</th> | ||
<th className="px-4 text-left text-sm font-medium text-gray-600"> | ||
Base Rating (2018) <span className="font-bold">{contaminant.base || "None"}</span></th> | ||
<th className="px-4 text-left text-sm font-medium text-gray-600">Objective | ||
{contaminant.byWhen ? ` (${byWhen(contaminant)})` : ''} <span className="font-bold">{contaminant.objective || 'None'}</span></th> | ||
</tr> | ||
<div className={`min-w-full border-b border-gray-300 pb-3`} key={index}> | ||
<div className="grid mb-1 mt-3 items-center" style={{ gridTemplateColumns: "20px 4fr" }}> | ||
<div className="pl-0 text-left text-md font-medium text-gray-600 cursor-pointer" onClick={() => handleRowClick(contaminant.title)}> | ||
{expandedRows[contaminant.title] ? <ChevronUpIcon className="h-6 w-6 text-blue-500" /> : <ChevronDownIcon className="h-6 w-6 text-blue-500" />} | ||
</div> | ||
<div className="pl-4 text-left text-md font-semibold"> | ||
{index.toString()+" "+contaminants.length+" "+contaminantTitle(contaminant)} | ||
</div> | ||
<div></div> | ||
</div> | ||
<div className={`grid mb-2 items-top`} style={{ gridTemplateColumns: "20px 2fr 2fr" }}> | ||
<div className="pl-1"></div> | ||
<div className="pl-4 text-left text-sm font-medium text-gray-600"> | ||
Base Rating (2018) <span className="font-bold">{contaminant.base || "None"}</span> | ||
</div> | ||
<div className="pl-4 text-left text-sm font-medium text-gray-600"> | ||
Objective {contaminant.byWhen ? ` (${byWhen(contaminant)})` : ''} <span className="font-bold">{contaminant.objective || 'None'}</span> | ||
</div> | ||
</div> | ||
{expandedRows[contaminant.title] && ( | ||
<tr> | ||
<td className="px-0 pt-2 text-xs text-left align-text-top"> | ||
</td> | ||
<td className="px-4 pt-2 text-xs text-left align-text-top"> | ||
<div dangerouslySetInnerHTML={{__html: getObjectiveDescription(contaminant, contaminant.base) ?? ''}}/> | ||
</td> | ||
<td className="px-4 pt-2 text-xs text-left align-text-top"> | ||
<div | ||
dangerouslySetInnerHTML={{__html: getObjectiveDescription(contaminant, contaminant.objective) ?? ''}}/> | ||
</td> | ||
</tr> | ||
<div className="grid" style={{ gridTemplateColumns: "20px 2fr 2fr" }}> | ||
<div className="pl-1 text-xs text-left align-text-top"></div> | ||
<div className="pl-4 text-xs text-left align-text-top"> | ||
<div dangerouslySetInnerHTML={{ __html: getObjectiveDescription(contaminant, contaminant.base) ?? '' }} /> | ||
</div> | ||
<div className="pl-4 text-left text-xs align-text-top"> | ||
<div dangerouslySetInnerHTML={{ __html: getObjectiveDescription(contaminant, contaminant.objective) ?? '' }} /> | ||
</div> | ||
</div> | ||
)} | ||
</tbody> | ||
</table> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters