From 11fc810a0cf1d306a6ab542dec697d725918bb11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dorien=20Gr=C3=B6nwald?= Date: Mon, 7 Oct 2024 17:31:39 +0200 Subject: [PATCH 01/10] fix: forbidden extra non-null assertion --- frontend/src/routes/_protected/map/tree/new.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/routes/_protected/map/tree/new.tsx b/frontend/src/routes/_protected/map/tree/new.tsx index 01319f30..664b4d0e 100644 --- a/frontend/src/routes/_protected/map/tree/new.tsx +++ b/frontend/src/routes/_protected/map/tree/new.tsx @@ -22,9 +22,10 @@ function NewTree() { }); const handleSave = () => { + if (!treeLatLng) return; navigate({ to: "/tree/new", - search: { lat: treeLatLng!!.lat, lng: treeLatLng!!.lng }, + search: { lat: treeLatLng.lat, lng: treeLatLng.lng }, }); }; @@ -46,7 +47,7 @@ function NewTree() { {treeLatLng ? ( <>

Neuer Baum an folgendem Standort:

- {treeLatLng!!.lat}, {treeLatLng!!.lng} + {treeLatLng?.lat}, {treeLatLng?.lng} ) : (

Bitte wähle einen Standort für den neuen Baum.

From 79936d106f86026338998b2c8432565318d29ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dorien=20Gr=C3=B6nwald?= Date: Mon, 7 Oct 2024 17:39:12 +0200 Subject: [PATCH 02/10] chore: fix linting issues --- frontend/src/components/map/MapController.tsx | 2 +- frontend/src/components/map/MapMarker.tsx | 2 +- frontend/src/components/ui/button.tsx | 56 --- frontend/src/components/ui/calendar.tsx | 64 ---- frontend/src/components/ui/chart.tsx | 361 ------------------ frontend/src/hooks/useMapMouseSelect.ts | 2 +- frontend/src/routes/_protected/team.tsx | 145 ------- frontend/src/routes/_protected/vehicles.tsx | 159 -------- 8 files changed, 3 insertions(+), 788 deletions(-) delete mode 100644 frontend/src/components/ui/button.tsx delete mode 100644 frontend/src/components/ui/calendar.tsx delete mode 100644 frontend/src/components/ui/chart.tsx diff --git a/frontend/src/components/map/MapController.tsx b/frontend/src/components/map/MapController.tsx index 3aac6d58..3d387323 100644 --- a/frontend/src/components/map/MapController.tsx +++ b/frontend/src/components/map/MapController.tsx @@ -4,7 +4,7 @@ import useMapStore from "@/store/store"; export interface MapConrollerProps { path: string; -}; +} const MapConroller = ({path}: MapConrollerProps) => { const navigate = useNavigate({ from: path }); diff --git a/frontend/src/components/map/MapMarker.tsx b/frontend/src/components/map/MapMarker.tsx index c7c55a1e..6822915b 100644 --- a/frontend/src/components/map/MapMarker.tsx +++ b/frontend/src/components/map/MapMarker.tsx @@ -1,4 +1,4 @@ -// @ts-ignore because this image needs to be imported, but not found for some reason, but works. +// @ts-expect-error" because this image needs to be imported, but not found for some reason, but works. import defaultIconPng from "leaflet/dist/images/marker-icon.png"; import L, { DivIcon, Icon, IconOptions } from "leaflet"; import { Marker } from "react-leaflet"; diff --git a/frontend/src/components/ui/button.tsx b/frontend/src/components/ui/button.tsx deleted file mode 100644 index 0ba42773..00000000 --- a/frontend/src/components/ui/button.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import * as React from "react" -import { Slot } from "@radix-ui/react-slot" -import { cva, type VariantProps } from "class-variance-authority" - -import { cn } from "@/lib/utils" - -const buttonVariants = cva( - "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", - { - variants: { - variant: { - default: "bg-primary text-primary-foreground hover:bg-primary/90", - destructive: - "bg-destructive text-destructive-foreground hover:bg-destructive/90", - outline: - "border border-input bg-background hover:bg-accent hover:text-accent-foreground", - secondary: - "bg-secondary text-secondary-foreground hover:bg-secondary/80", - ghost: "hover:bg-accent hover:text-accent-foreground", - link: "text-primary underline-offset-4 hover:underline", - }, - size: { - default: "h-10 px-4 py-2", - sm: "h-9 rounded-md px-3", - lg: "h-11 rounded-md px-8", - icon: "h-10 w-10", - }, - }, - defaultVariants: { - variant: "default", - size: "default", - }, - } -) - -export interface ButtonProps - extends React.ButtonHTMLAttributes, - VariantProps { - asChild?: boolean -} - -const Button = React.forwardRef( - ({ className, variant, size, asChild = false, ...props }, ref) => { - const Comp = asChild ? Slot : "button" - return ( - - ) - } -) -Button.displayName = "Button" - -export { Button, buttonVariants } diff --git a/frontend/src/components/ui/calendar.tsx b/frontend/src/components/ui/calendar.tsx deleted file mode 100644 index b065f8e0..00000000 --- a/frontend/src/components/ui/calendar.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import * as React from "react" -import { ChevronLeft, ChevronRight } from "lucide-react" -import { DayPicker } from "react-day-picker" - -import { cn } from "@/lib/utils" -import { buttonVariants } from "@/components/ui/button" - -export type CalendarProps = React.ComponentProps - -function Calendar({ - className, - classNames, - showOutsideDays = true, - ...props -}: CalendarProps) { - return ( - , - IconRight: ({ ...props }) => , - }} - {...props} - /> - ) -} -Calendar.displayName = "Calendar" - -export { Calendar } diff --git a/frontend/src/components/ui/chart.tsx b/frontend/src/components/ui/chart.tsx deleted file mode 100644 index 82cc71cc..00000000 --- a/frontend/src/components/ui/chart.tsx +++ /dev/null @@ -1,361 +0,0 @@ -import * as React from "react" -import * as RechartsPrimitive from "recharts" - -import { cn } from "@/lib/utils" - -// Format: { THEME_NAME: CSS_SELECTOR } -const THEMES = { light: "", dark: ".dark" } as const - -export type ChartConfig = { - [k in string]: { - label?: React.ReactNode - icon?: React.ComponentType - } & ( - | { color?: string; theme?: never } - | { color?: never; theme: Record } - ) -} - -type ChartContextProps = { - config: ChartConfig -} - -const ChartContext = React.createContext(null) - -function useChart() { - const context = React.useContext(ChartContext) - - if (!context) { - throw new Error("useChart must be used within a ") - } - - return context -} - -const ChartContainer = React.forwardRef< - HTMLDivElement, - React.ComponentProps<"div"> & { - config: ChartConfig - children: React.ComponentProps< - typeof RechartsPrimitive.ResponsiveContainer - >["children"] - } ->(({ id, className, children, config, ...props }, ref) => { - const uniqueId = React.useId() - const chartId = `chart-${id || uniqueId.replace(/:/g, "")}` - - return ( - -
- - - {children} - -
-
- ) -}) -ChartContainer.displayName = "Chart" - -const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => { - const colorConfig = Object.entries(config).filter( - ([_, config]) => config.theme || config.color - ) - - if (!colorConfig.length) { - return null - } - - return ( -