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

Move temporary records functionality to crashes list #1654

Open
wants to merge 6 commits into
base: nextjs
Choose a base branch
from
Open
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
30 changes: 29 additions & 1 deletion app/app/crashes/page.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,53 @@
"use client";
import { useState, useCallback } from "react";
import Card from "react-bootstrap/Card";
import Button from "react-bootstrap/Button";
import AlignedLabel from "@/components/AlignedLabel";
import AppBreadCrumb from "@/components/AppBreadCrumb";
import CreateCrashRecordModal from "@/components/CreateCrashRecordModal";
import { FaCirclePlus } from "react-icons/fa6";
import { crashesListViewColumns } from "@/configs/crashesListViewColumns";
import { crashesListViewQueryConfig } from "@/configs/crashesListViewTable";
import TableWrapper from "@/components/TableWrapper";
const localStorageKey = "crashesListViewQueryConfig";

export default function Crashes() {
const [refetch, setRefetch] = useState(false);
const [showNewUserModal, setShowNewUserModal] = useState(false);
const onCloseModal = () => setShowNewUserModal(false);

const onSaveCallback = useCallback(() => {
setRefetch((prev) => !prev);
setShowNewUserModal(false);
}, [setRefetch]);

return (
<>
<AppBreadCrumb />
<Card>
<Card.Header className="fs-5 fw-bold">Crashes</Card.Header>
<Card.Header className="fs-5 fw-bold d-flex justify-content-between">
Crashes
<Button className="me-2" onClick={() => setShowNewUserModal(true)}>
<AlignedLabel>
<FaCirclePlus className="me-2" />
<span>Create crash record</span>
</AlignedLabel>
</Button>
</Card.Header>
<Card.Body>
<TableWrapper
columns={crashesListViewColumns}
initialQueryConfig={crashesListViewQueryConfig}
localStorageKey={localStorageKey}
refetch={refetch}
/>
</Card.Body>
</Card>
<CreateCrashRecordModal
onClose={onCloseModal}
show={showNewUserModal}
onSubmitCallback={onSaveCallback}
/>
</>
);
}
54 changes: 0 additions & 54 deletions app/app/create-crash-record/page.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion app/components/CrashIsTemporaryBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function CrashIsTemporaryBanner({
)
) {
await mutate({ id: crashId, updated_by: user?.email });
router.push("/create-crash-record");
router.push("/crashes");
}
}}
disabled={isMutating}
Expand Down
8 changes: 0 additions & 8 deletions app/components/SidebarLayout.tsx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is totally outside the scope of this PR, but while I was reviewing it, a typo jumped out at me in this file. Would you mind adding a space to the comment /** Check local storage for initialsidebar state */ on line 42? No big if not!!

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
FaAngleRight,
FaUserGroup,
FaCloudArrowUp,
FaFileCirclePlus,
} from "react-icons/fa6";
import AppNavBar from "./AppNavBar";
import SideBarListItem from "./SideBarListItem";
Expand Down Expand Up @@ -117,13 +116,6 @@ export default function SidebarLayout({ children }: { children: ReactNode }) {
label="Locations"
href="/locations"
/>
<SideBarListItem
isCollapsed={isCollapsed}
isCurrentPage={segments.includes("create-crash-record")}
Icon={FaFileCirclePlus}
label="Create crash"
href="/create-crash-record"
/>
<SideBarListItem
isCollapsed={isCollapsed}
isCurrentPage={segments.includes("upload-non-cr3")}
Expand Down
17 changes: 16 additions & 1 deletion app/configs/crashesListViewTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ const crashesListViewfilterCards: FilterGroup[] = [
{
id: "internal_filters",
label: "Internal",
groupOperator: "_or",
// because one of the filters is enabled and inverted we need to join using the "_and" operator
groupOperator: "_and",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 🙏

filterGroups: [
{
id: "private_drive",
Expand All @@ -220,6 +221,20 @@ const crashesListViewfilterCards: FilterGroup[] = [
},
],
},
{
id: "is_temp_record",
label: "Temporary records",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you think about adding the word "Only" to the label here, so it reads "Only temporary records?" The idea being that the two internal filters have a very different interaction to the existing set.

"Include private drive crashes" adds to the existing set by allowing in more crashes, and "Temporary records" is unclear if it's going to limit to just temporary records or allow the temporary records to be added to the existing set being shown.

Because it ends up doing a different operation (limit as opposed to add-to) as the previous option, I think adding a verb to the label can help the user get the right expectation.

I feel like I've done a really poor job in explaining my rational - LMK if i can help explain any of this better.


Edit: I was reading more of this as I reviewed, and you pointed out how the one above is _and and this one is still an _or. They are the right operations, of course -- we just need to broadcast that nuance in the labels to the user.

groupOperator: "_and",
enabled: false,
filters: [
{
id: "is_temp_record",
column: "is_temp_record",
operator: "_eq",
value: true,
},
],
},
],
},
];
Expand Down