From 110f4ec3323ffaed1d2513faae0630df39c7d53a Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 19 Feb 2025 01:59:51 -0500 Subject: [PATCH] Shadcn conversion, more styling, sheet select step --- .../components/ColumnGrid.tsx | 28 +++++-- .../components/TemplateColumn.tsx | 14 +--- .../components/UserTableColumn.tsx | 55 +++++++++----- .../steps/SelectSheetStep/SelectSheetStep.tsx | 75 ++++++++++++------- 4 files changed, 109 insertions(+), 63 deletions(-) diff --git a/inventory/src/lib/react-spreadsheet-import/src/steps/MatchColumnsStep/components/ColumnGrid.tsx b/inventory/src/lib/react-spreadsheet-import/src/steps/MatchColumnsStep/components/ColumnGrid.tsx index 3fddb12..ac87cfa 100644 --- a/inventory/src/lib/react-spreadsheet-import/src/steps/MatchColumnsStep/components/ColumnGrid.tsx +++ b/inventory/src/lib/react-spreadsheet-import/src/steps/MatchColumnsStep/components/ColumnGrid.tsx @@ -1,8 +1,12 @@ import type React from "react" import type { Column, Columns } from "../MatchColumnsStep" +import { ColumnType } from "../MatchColumnsStep" import { useRsi } from "../../../hooks/useRsi" import { Button } from "@/components/ui/button" import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area" +import { Box } from "@/components/ui/box" +import { Text } from "@/components/ui/text" +import { FadingWrapper } from "@/components/ui/fading-wrapper" type ColumnGridProps = { columns: Columns @@ -22,9 +26,13 @@ export const ColumnGrid = ({ isLoading, }: ColumnGridProps) => { const { translations } = useRsi() - const columnWidth = 250 + const normalColumnWidth = 250 + const ignoredColumnWidth = 48 // 12 units = 3rem = 48px const gap = 16 - const totalWidth = columns.length * columnWidth + (columns.length - 1) * gap + const totalWidth = columns.reduce((acc, col) => + acc + (col.type === ColumnType.ignored ? ignoredColumnWidth : normalColumnWidth) + gap, + -gap // Subtract one gap since we need gaps between columns only + ) return (
@@ -44,18 +52,20 @@ export const ColumnGrid = ({
+ `${col.type === ColumnType.ignored ? ignoredColumnWidth : normalColumnWidth}px` + ).join(" "), }} > {columns.map((column, index) => ( -
+
{userColumn(column)}
))}
-
+
@@ -65,9 +75,11 @@ export const ColumnGrid = ({ {translations.matchColumnsStep.templateTitle}
+ `${col.type === ColumnType.ignored ? ignoredColumnWidth : normalColumnWidth}px` + ).join(" "), }} > {columns.map((column, index) => ( diff --git a/inventory/src/lib/react-spreadsheet-import/src/steps/MatchColumnsStep/components/TemplateColumn.tsx b/inventory/src/lib/react-spreadsheet-import/src/steps/MatchColumnsStep/components/TemplateColumn.tsx index a8db66d..db5f24c 100644 --- a/inventory/src/lib/react-spreadsheet-import/src/steps/MatchColumnsStep/components/TemplateColumn.tsx +++ b/inventory/src/lib/react-spreadsheet-import/src/steps/MatchColumnsStep/components/TemplateColumn.tsx @@ -49,15 +49,7 @@ export const TemplateColumn = ({ column, onChange, onSubChange selectOptions.find(({ value }: { value: string }) => "value" in column && column.value === value)?.value if (isIgnored) { - return ( - - -

- {translations.matchColumnsStep.ignoredColumnText} -

-
-
- ) + return null } return ( @@ -86,8 +78,8 @@ export const TemplateColumn = ({ column, onChange, onSubChange
{isChecked && ( -
- +
+
)} diff --git a/inventory/src/lib/react-spreadsheet-import/src/steps/MatchColumnsStep/components/UserTableColumn.tsx b/inventory/src/lib/react-spreadsheet-import/src/steps/MatchColumnsStep/components/UserTableColumn.tsx index 02405ad..95c7951 100644 --- a/inventory/src/lib/react-spreadsheet-import/src/steps/MatchColumnsStep/components/UserTableColumn.tsx +++ b/inventory/src/lib/react-spreadsheet-import/src/steps/MatchColumnsStep/components/UserTableColumn.tsx @@ -1,6 +1,6 @@ import { Button } from "@/components/ui/button" import { Card, CardContent, CardHeader } from "@/components/ui/card" -import { X, Undo2 } from "lucide-react" +import { X, RotateCcw } from "lucide-react" import type { Column } from "../MatchColumnsStep" import { ColumnType } from "../MatchColumnsStep" import type { RawData } from "../../../types" @@ -22,35 +22,52 @@ export const UserTableColumn = (props: UserTableColumnProps } = props const isIgnored = type === ColumnType.ignored + if (isIgnored) { + return ( + + + +
+ {header} +
+
+
+ ) + } + return ( - + -

+

{header} -

+

- {entries.slice(0, 3).map((entry, i) => ( -
( +

- {entry || ""} -

+ {entry} +

))}
diff --git a/inventory/src/lib/react-spreadsheet-import/src/steps/SelectSheetStep/SelectSheetStep.tsx b/inventory/src/lib/react-spreadsheet-import/src/steps/SelectSheetStep/SelectSheetStep.tsx index 8b9afee..b1723c8 100644 --- a/inventory/src/lib/react-spreadsheet-import/src/steps/SelectSheetStep/SelectSheetStep.tsx +++ b/inventory/src/lib/react-spreadsheet-import/src/steps/SelectSheetStep/SelectSheetStep.tsx @@ -1,8 +1,9 @@ -import { Heading, ModalBody, Radio, RadioGroup, Stack, useStyleConfig, Text } from "@chakra-ui/react" import { useCallback, useState } from "react" -import { ContinueButton } from "../../components/ContinueButton" import { useRsi } from "../../hooks/useRsi" -import type { themeOverrides } from "../../theme" +import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group" +import { Label } from "@/components/ui/label" +import { Button } from "@/components/ui/button" +import { ChevronLeft } from "lucide-react" type SelectSheetProps = { sheetNames: string[] @@ -14,9 +15,7 @@ export const SelectSheetStep = ({ sheetNames, onContinue, onBack }: SelectSheetP const [isLoading, setIsLoading] = useState(false) const { translations } = useRsi() const [value, setValue] = useState(sheetNames[0]) - const styles = useStyleConfig( - "SelectSheetStep", - ) as (typeof themeOverrides)["components"]["SelectSheetStep"]["baseStyle"] + const handleOnContinue = useCallback( async (data: typeof value) => { setIsLoading(true) @@ -27,26 +26,52 @@ export const SelectSheetStep = ({ sheetNames, onContinue, onBack }: SelectSheetP ) return ( - <> - - {translations.uploadStep.selectSheet.title} - setValue(value)} value={value}> - +
+
+
+
+

+ {translations.uploadStep.selectSheet.title} +

+
+ {sheetNames.map((sheetName) => ( - - {sheetName} - +
+ + +
))} - -
- - handleOnContinue(value)} - onBack={onBack} - title={translations.uploadStep.selectSheet.nextButtonTitle} - backTitle={translations.uploadStep.selectSheet.backButtonTitle} - /> - + +
+
+
+ {onBack && ( + + )} +
+ +
+
) }