Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incident details extra page bug #277

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const Dashboard = () => {
const { isConnected } = useSharedIsOnline();
const navigate = useNavigate();
const [formsData, setFormsData] = useState([]);
const [completedTableRows, setCompletedTableRows] = useState([]);
const [staticDataLoaded, setStaticDataLoaded] = useState(false);
const [userResource, setUserResource] = useRecoilState(userAtom);
const [agencyResource, setAgencyResource] = useRecoilState(
Expand Down Expand Up @@ -69,6 +70,16 @@ export const Dashboard = () => {
const [lastUpdatedDate, setLastUpdatedDate] = useState(null);
const [sortMode, setSortMode] = useState("DATE_DESC");

useEffect(() => {
async function sortRows() {
if (formsData && formsData.length > 0) {
const rows = await sortTableRows(formsData);
await setCompletedTableRows(rows);
}
}
sortRows();
}, [formsData, sortMode]);

const sortTableRows = (rows) => {
switch (sortMode) {
case "DATE_ASC":
Expand Down Expand Up @@ -421,7 +432,7 @@ export const Dashboard = () => {
</tr>
</thead>
<tbody>
{sortTableRows(formsData).map((data, index) => {
{completedTableRows.map((data, index) => {
return data["submitted"] ? (
<tr key={data["vehicle_vin_no"]}>
<td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const TestAdministered = (props) => {

useEffect(() => {
if (values["prescribed_test_used"] === "NO") {
values["reasonable_test_used_alcohol"] = "";
values["resonable_test_used_alcohol"] = "";
values["reasonable_test_used_drugs"] = "";
values["reasonable_asd_expiry_date"] = null;
values["reasonable_result_alcohol"] = "";
Expand All @@ -49,21 +49,22 @@ export const TestAdministered = (props) => {
}, [values["prescribed_test_used"]]);

useEffect(() => {
console.log("Values: ", values);
if (values["type_of_prohibition"] === "alcohol") {
// alco-sensor / instrument / PPCT
if (values["reasonable_test_used_alcohol"] !== "alco-sensor") {
if (values["resonable_test_used_alcohol"] !== "alco-sensor") {
values["reasonable_asd_expiry_date"] = null;
values["reasonable_result_alcohol"] = "";
}
if (values["reasonable_test_used_alcohol"] !== "instrument") {
if (values["resonable_test_used_alcohol"] !== "instrument") {
values["reasonable_bac_result_mg"] = null;
values["resonable_approved_instrument_used"] = "";
}
if (values["reasonable_test_used_alcohol"] !== "PPCT") {
if (values["resonable_test_used_alcohol"] !== "PPCT") {
values["reasonable_can_drive_alcohol"] = false;
}
}
}, [values["reasonable_test_used_alcohol"]]);
}, [values["resonable_test_used_alcohol"]]);

useEffect(() => {
if (values["type_of_prohibition"] === "drugs") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export const ViewPastEvent = () => {
if (form === "ILO" && values["vehicle_impounded"] === "NO") {
break;
}
// If our incident details fit on the first page, there is no reason to render the second page.
if (form === "DETAILS" && values["incident_details"].length < 500) {
break;
}
componentsToRender.push(
<SVGprint
key={item + form}
Expand Down
Loading