From 95b43a1d3c26681ca51dcffaae25cab98398ca51 Mon Sep 17 00:00:00 2001 From: Youllou Date: Tue, 17 Dec 2024 16:28:46 -0500 Subject: [PATCH] prettier --- src/app/api/inspections/route.ts | 2 +- src/app/dashboard/page.tsx | 129 +++++++++++------- .../InspectionList/InspectionList.tsx | 62 +++++---- .../__tests__/InspectionElement.test.tsx | 10 +- .../__tests__/InspectionList.test.tsx | 10 +- src/types/InspectionPreview.ts | 14 +- 6 files changed, 135 insertions(+), 92 deletions(-) diff --git a/src/app/api/inspections/route.ts b/src/app/api/inspections/route.ts index 98a4d377..f3a9aa04 100644 --- a/src/app/api/inspections/route.ts +++ b/src/app/api/inspections/route.ts @@ -29,7 +29,7 @@ export async function POST(request: Request) { }); } -export async function GET(request: Request){ +export async function GET(request: Request) { const authHeader = request.headers.get("Authorization"); if (!authHeader) { return new Response( diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx index 91d3dea1..5d918ebb 100644 --- a/src/app/dashboard/page.tsx +++ b/src/app/dashboard/page.tsx @@ -1,66 +1,97 @@ -"use client" +"use client"; import FertilizerList from "@/components/InspectionList/InspectionList"; -import { Grid2 as Grid, InputAdornment, TextField, Typography } from "@mui/material"; +import { + Grid2 as Grid, + InputAdornment, + TextField, + Typography, +} from "@mui/material"; import { Search, LocationOn } from "@mui/icons-material"; import { useState } from "react"; const Dashboard = () => { - const [search, setSearch] = useState(""); - return + + - - - - Username + + + Username + + + + Mail: + + User email + + Role: + + User role + + + : + + + User location - Mail:User email - Role:User role - :User location - - - - Number of inspections + + + + Number of inspections + + - - - - - My inspections - - - setSearch(e.target.value)} - fullWidth - slotProps={{ - htmlInput: { - className: "!p-0 after:!transition-none " - }, - input: { - className:"p-2", - startAdornment:( - - - - ) - } - }} - /> - -
- - + + + + + My inspections + + + + setSearch(e.target.value)} + fullWidth + slotProps={{ + htmlInput: { + className: "!p-0 after:!transition-none ", + }, + input: { + className: "p-2", + startAdornment: ( + + + + ), + }, + }} + /> + +
+ + +
-
+ ); }; export default Dashboard; diff --git a/src/components/InspectionList/InspectionList.tsx b/src/components/InspectionList/InspectionList.tsx index 7977b135..adf4b333 100644 --- a/src/components/InspectionList/InspectionList.tsx +++ b/src/components/InspectionList/InspectionList.tsx @@ -1,4 +1,4 @@ -"use client" +"use client"; import { Stack } from "@mui/material"; import InspectionPreview from "@/types/InspectionPreview"; import InspectionElement from "@/components/InspectionList/InspectionElement"; @@ -11,41 +11,53 @@ interface InspectionListProps { search: string; } -const InspectionList = ({search}:InspectionListProps)=>{ - - const [inspectList, setInspectList] = useState([] as InspectionPreview[]) - const [shownList, setShownList] = useState([] as InspectionPreview[]) +const InspectionList = ({ search }: InspectionListProps) => { + const [inspectList, setInspectList] = useState([] as InspectionPreview[]); + const [shownList, setShownList] = useState([] as InspectionPreview[]); const router = useRouter(); const handleInspectionClick = (id: string) => { router.push(`/label-data-validation/${id}`); - } + }; useEffect(() => { const username = atob(Cookies.get("token") ?? ""); const password = ""; const authHeader = "Basic " + btoa(`${username}:${password}`); - axios.get("/api/inspections", - { - headers: { - Authorization: authHeader - }, - }).then((response) => { - setInspectList(response.data); - setShownList(response.data); - }); + axios + .get("/api/inspections", { + headers: { + Authorization: authHeader, + }, + }) + .then((response) => { + setInspectList(response.data); + setShownList(response.data); + }); }, []); useEffect(() => { - setShownList(inspectList.filter((inspection) => { - return inspection.product_name!.toLowerCase().includes(search.toLowerCase()); - })); + setShownList( + inspectList.filter((inspection) => { + return inspection + .product_name!.toLowerCase() + .includes(search.toLowerCase()); + }), + ); }, [inspectList, search]); - return - {shownList.map((inspection) => { - return handleInspectionClick(inspection.id)}/> - })} - -} + return ( + + {shownList.map((inspection) => { + return ( + handleInspectionClick(inspection.id)} + /> + ); + })} + + ); +}; -export default InspectionList \ No newline at end of file +export default InspectionList; diff --git a/src/components/InspectionList/__tests__/InspectionElement.test.tsx b/src/components/InspectionList/__tests__/InspectionElement.test.tsx index b9d15db5..d8ab6fd6 100644 --- a/src/components/InspectionList/__tests__/InspectionElement.test.tsx +++ b/src/components/InspectionList/__tests__/InspectionElement.test.tsx @@ -1,5 +1,5 @@ -describe('InspectionElement', () => { - it('TODO', () => { - expect(false).toBe(true) - }) -}) \ No newline at end of file +describe("InspectionElement", () => { + it("TODO", () => { + expect(false).toBe(true); + }); +}); diff --git a/src/components/InspectionList/__tests__/InspectionList.test.tsx b/src/components/InspectionList/__tests__/InspectionList.test.tsx index b7221486..bbd866bd 100644 --- a/src/components/InspectionList/__tests__/InspectionList.test.tsx +++ b/src/components/InspectionList/__tests__/InspectionList.test.tsx @@ -1,5 +1,5 @@ -describe('InspectionList', () => { - it('TODO', () => { - expect(false).toBe(true) - }) -}) \ No newline at end of file +describe("InspectionList", () => { + it("TODO", () => { + expect(false).toBe(true); + }); +}); diff --git a/src/types/InspectionPreview.ts b/src/types/InspectionPreview.ts index 53004ff6..212e54e9 100644 --- a/src/types/InspectionPreview.ts +++ b/src/types/InspectionPreview.ts @@ -36,12 +36,12 @@ type InspectionPreview = { id: string; upload_date: string; updated_at: string; - sample_id: string|null; - picture_set_id: string|null; + sample_id: string | null; + picture_set_id: string | null; label_info_id: string; - product_name: string|null; - manufacturer_info_id: string|null; + product_name: string | null; + manufacturer_info_id: string | null; company_info_id: string; - company_name: string|null; -} -export default InspectionPreview; \ No newline at end of file + company_name: string | null; +}; +export default InspectionPreview;