From 3ef5fa32afc767bcddbdd6e5e7159acb00a90bf2 Mon Sep 17 00:00:00 2001 From: padamsen_fisker Date: Tue, 2 Jul 2024 10:38:40 -0400 Subject: [PATCH] CEC-6084 - Car Update search bar --- src/components/Cars/Status/CarUpdatesTab.jsx | 14 ++++- .../__snapshots__/CarUpdatesTab.test.jsx.snap | 54 +++++++++++++++++++ .../Controls/CarUpdatesTable/index.jsx | 5 +- 3 files changed, 69 insertions(+), 4 deletions(-) diff --git a/src/components/Cars/Status/CarUpdatesTab.jsx b/src/components/Cars/Status/CarUpdatesTab.jsx index 17823ed..848acd4 100644 --- a/src/components/Cars/Status/CarUpdatesTab.jsx +++ b/src/components/Cars/Status/CarUpdatesTab.jsx @@ -1,15 +1,18 @@ -import { Typography } from "@material-ui/core"; +import { Grid, Typography } from "@material-ui/core"; import clsx from "clsx"; import React from "react"; import { useUserContext } from "../../Contexts/UserContext"; import { VehicleProvider } from "../../Contexts/VehicleContext"; +import { useLocalStorage } from "../../useLocalStorage"; import CarUpdatesTable from "../../Controls/CarUpdatesTable"; import CarVersionLogTable from "../../Controls/CarVersionLogTable"; import FlashpackInfoTable from "../../Controls/FlashpackInfoTable"; +import SearchField from "../../Controls/SearchField"; import useStyles from "../../useStyles"; const MainForm = ({ vin }) => { + const [search, setSearch] = useLocalStorage("CAR_UPDATES_SEARCH", ""); const classes = useStyles(); const { token: { @@ -17,10 +20,17 @@ const MainForm = ({ vin }) => { }, } = useUserContext(); + const handleSearch = (query) => { + setSearch(query); + }; + return (
Car Updates - + + + + Version Log Flashpack Version Progress diff --git a/src/components/Cars/Status/__snapshots__/CarUpdatesTab.test.jsx.snap b/src/components/Cars/Status/__snapshots__/CarUpdatesTab.test.jsx.snap index 9bc45de..29dcaaa 100644 --- a/src/components/Cars/Status/__snapshots__/CarUpdatesTab.test.jsx.snap +++ b/src/components/Cars/Status/__snapshots__/CarUpdatesTab.test.jsx.snap @@ -19,6 +19,60 @@ exports[`CarUpdatesTab Render 1`] = ` > Car Updates +
+
+ +
+ +
+ +
+
+
+
diff --git a/src/components/Controls/CarUpdatesTable/index.jsx b/src/components/Controls/CarUpdatesTable/index.jsx index ae46859..23a0226 100644 --- a/src/components/Controls/CarUpdatesTable/index.jsx +++ b/src/components/Controls/CarUpdatesTable/index.jsx @@ -63,7 +63,7 @@ const tableColumns = [ const PAGE_SIZE = "CAR_UPDATES_TABLE_PAGE_SIZE"; -const MainForm = ({ vin, token }) => { +const MainForm = ({ vin, token, search }) => { const classes = useStyles(); const [pageSize, setPageSize] = useLocalStorage(PAGE_SIZE, 10); const [pageIndex, setPageIndex] = useState(0); @@ -89,6 +89,7 @@ const MainForm = ({ vin, token }) => { await getCarUpdates( { vin, + search, limit: pageSize, offset: pageSize * pageIndex, order: `${orderBy} ${order}`, @@ -101,7 +102,7 @@ const MainForm = ({ vin, token }) => { } })(); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [vin, token, pageIndex, pageSize, orderBy, order]); + }, [vin, token, search, pageIndex, pageSize, orderBy, order]); useEffect(() => { try {