Skip to content

Commit 116383f

Browse files
committed
feat/navigation
- fix test - fix backward compatibility
1 parent 10b15d9 commit 116383f

7 files changed

Lines changed: 20 additions & 21 deletions

File tree

src/components/ContinueButton.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@ import { Button, ModalFooter } from "@chakra-ui/react"
22

33
type ContinueButtonProps = {
44
onContinue: (val: any) => void
5-
onBack: () => void
5+
onBack?: () => void
66
title: string
7-
backTitle: string
7+
backTitle?: string
88
isLoading?: boolean
99
}
1010

1111
export const ContinueButton = ({ onContinue, onBack, title, backTitle, isLoading }: ContinueButtonProps) => (
12-
<ModalFooter justifyContent="space-between">
13-
<Button size="lg" w="21rem" onClick={onBack} isLoading={isLoading}>
14-
{backTitle}
15-
</Button>
12+
<ModalFooter justifyContent={onBack && "space-between"}>
13+
{onBack && (
14+
<Button size="lg" w="21rem" onClick={onBack} isLoading={isLoading}>
15+
{backTitle}
16+
</Button>
17+
)}
1618
<Button size="lg" w="21rem" onClick={onContinue} isLoading={isLoading}>
1719
{title}
1820
</Button>

src/steps/MatchColumnsStep/MatchColumnsStep.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type MatchColumnsProps<T extends string> = {
1717
data: RawData[]
1818
headerValues: RawData
1919
onContinue: (data: any[], rawData: RawData[], columns: Columns<T>) => void
20-
onBack: () => void
20+
onBack?: () => void
2121
}
2222

2323
export enum ColumnType {

src/steps/MatchColumnsStep/components/ColumnGrid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type ColumnGridProps<T extends string> = {
1111
userColumn: (column: Column<T>) => React.ReactNode
1212
templateColumn: (column: Column<T>) => React.ReactNode
1313
onContinue: (val: Record<string, string>[]) => void
14-
onBack: () => void
14+
onBack?: () => void
1515
isLoading: boolean
1616
}
1717

src/steps/SelectHeaderStep/SelectHeaderStep.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { RawData } from "../../types"
99
type SelectHeaderProps = {
1010
data: RawData[]
1111
onContinue: (headerValues: RawData, data: RawData[]) => Promise<void>
12-
onBack: () => void
12+
onBack?: () => void
1313
}
1414

1515
export const SelectHeaderStep = ({ data, onContinue, onBack }: SelectHeaderProps) => {

src/steps/SelectSheetStep/SelectSheetStep.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { themeOverrides } from "../../theme"
77
type SelectSheetProps = {
88
sheetNames: string[]
99
onContinue: (sheetName: string) => Promise<void>
10-
onBack: () => void
10+
onBack?: () => void
1111
}
1212

1313
export const SelectSheetStep = ({ sheetNames, onContinue, onBack }: SelectSheetProps) => {

src/steps/UploadFlow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export type StepState =
4343
interface Props {
4444
state: StepState
4545
onNext: (v: StepState) => void
46-
onBack: () => void
46+
onBack?: () => void
4747
}
4848

4949
export const UploadFlow = ({ state, onNext, onBack }: Props) => {

src/steps/ValidationStep/ValidationStep.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { RowsChangeData } from "react-data-grid"
1414
type Props<T extends string> = {
1515
initialData: Data<T>[]
1616
file: File
17-
onBack: () => void
17+
onBack?: () => void
1818
}
1919

2020
export const ValidationStep = <T extends string>({ initialData, file, onBack }: Props<T>) => {
@@ -51,15 +51,12 @@ export const ValidationStep = <T extends string>({ initialData, file, onBack }:
5151

5252
const updateRow = useCallback(
5353
(rows: typeof data, changedData?: RowsChangeData<(typeof data)[number]>) => {
54-
const changes = changedData?.indexes.reduce(
55-
(acc, index) => {
56-
// when data is filtered val !== actual index in data
57-
const realIndex = data.findIndex((value) => value.__index === rows[index].__index)
58-
acc[realIndex] = rows[index]
59-
return acc
60-
},
61-
{} as Record<number, (typeof data)[number]>,
62-
)
54+
const changes = changedData?.indexes.reduce((acc, index) => {
55+
// when data is filtered val !== actual index in data
56+
const realIndex = data.findIndex((value) => value.__index === rows[index].__index)
57+
acc[realIndex] = rows[index]
58+
return acc
59+
}, {} as Record<number, (typeof data)[number]>)
6360
const newData = Object.assign([], data, changes)
6461
updateData(newData)
6562
},

0 commit comments

Comments
 (0)