diff --git a/src/components/CSVColumnMapper/CSVColumnMapper.stories.tsx b/src/components/CSVColumnMapper/CSVColumnMapper.stories.tsx index 92e7db00..27651e9f 100644 --- a/src/components/CSVColumnMapper/CSVColumnMapper.stories.tsx +++ b/src/components/CSVColumnMapper/CSVColumnMapper.stories.tsx @@ -10,6 +10,33 @@ const meta: Meta = { title: 'Components/CSVColumnMapper', component: CSVColumnMapper, tags: ['autodocs'], + args: { + importing: false, + importProgress: 0, + }, + argTypes: { + // Hide data props that are managed by interactive wrappers + columns: { table: { disable: true } }, + fieldOptions: { table: { disable: true } }, + childFieldOptions: { table: { disable: true } }, + // Hide callback props + onColumnChange: { table: { disable: true } }, + onIgnoreToggle: { table: { disable: true } }, + onBulkAction: { table: { disable: true } }, + onImport: { table: { disable: true } }, + // Hide className and labels (complex object) + className: { table: { disable: true } }, + labels: { table: { disable: true } }, + // Configure visible controls + importing: { + control: 'boolean', + description: 'Whether import is in progress', + }, + importProgress: { + control: { type: 'range', min: 0, max: 100, step: 1 }, + description: 'Import progress (0-100)', + }, + }, }; export default meta; @@ -59,7 +86,13 @@ const childFieldOptions = { }; // Wrapper for Default story with interactive state -function CSVColumnMapperWrapper() { +function CSVColumnMapperWrapper({ + importing, + importProgress, +}: { + importing?: boolean; + importProgress?: number; +}) { const [columns, setColumns] = useState(sampleColumns); const handleColumnChange = ( @@ -103,6 +136,8 @@ function CSVColumnMapperWrapper() { onIgnoreToggle={handleIgnoreToggle} onBulkAction={handleBulkAction} onImport={() => window.alert('Import triggered!')} + importing={importing} + importProgress={importProgress} /> ); } @@ -129,7 +164,12 @@ function FileUploadWrapper() { } export const Default: Story = { - render: () => , + render: (args) => ( + + ), }; export const WithPhoneMapping: Story = { diff --git a/src/components/CSVColumnMapper/CSVColumnMapper.tsx b/src/components/CSVColumnMapper/CSVColumnMapper.tsx index e1241b0d..ca1eac4a 100644 --- a/src/components/CSVColumnMapper/CSVColumnMapper.tsx +++ b/src/components/CSVColumnMapper/CSVColumnMapper.tsx @@ -2,6 +2,8 @@ import * as React from 'react'; import { cn } from '../../utils'; +import { Button } from '../Button'; +import { Select, type SelectOption } from '../Select'; export interface CSVColumn { /** Original column name from CSV */ @@ -62,10 +64,6 @@ export interface CSVColumnMapperProps { includeAll?: string; ignoreUncompleted?: string; import?: string; - ignore?: string; - include?: string; - incomingSample?: string; - fieldType?: string; ensureAccurateData?: string; ensureAccurateDataDescription?: string; instructions?: string; @@ -90,10 +88,6 @@ export function CSVColumnMapper({ includeAll = 'Include All', ignoreUncompleted = 'Ignore Uncompleted', import: importLabel = 'Import', - ignore = 'Ignore', - include = 'Include', - incomingSample = 'Incoming Sample', - fieldType = 'Field Type', ensureAccurateData = 'Ensure Accurate Employee Data', ensureAccurateDataDescription = 'Existing employee profiles will be automatically updated.', instructions = 'Map each column from your CSV to the corresponding employee field.', @@ -110,15 +104,15 @@ export function CSVColumnMapper({
{/* Import Progress Modal */} {importing && ( -
-
-
+
+
+

Processing Employees

-
+
@@ -132,35 +126,37 @@ export function CSVColumnMapper({ {/* Bulk Actions */}
- - - +
{/* Info Alert */} -
-

+
+

{ensureAccurateData}

-

{ensureAccurateDataDescription}

+

+ {ensureAccurateDataDescription} +

{instructions}

@@ -181,21 +177,15 @@ export function CSVColumnMapper({ } onIgnoreToggle={(ignored) => onIgnoreToggle?.(index, ignored)} formatHtmlId={formatHtmlId} - labels={{ ignore, include, incomingSample, fieldType }} /> ))}

{/* Import Button */}
- +
); @@ -209,12 +199,6 @@ interface CSVColumnCardProps { onMappingChange: (mappedTo: string, childField?: string) => void; onIgnoreToggle: (ignored: boolean) => void; formatHtmlId: (name: string, ...parts: string[]) => string; - labels: { - ignore: string; - include: string; - incomingSample: string; - fieldType: string; - }; } function CSVColumnCard({ @@ -225,130 +209,176 @@ function CSVColumnCard({ onMappingChange, onIgnoreToggle, formatHtmlId, - labels, }: CSVColumnCardProps) { const needsMapping = !column.ignored && !column.mappedTo; const hasError = column.hasError || needsMapping; + // Convert fieldOptions to SelectOption format + const selectOptions: SelectOption[] = fieldOptions.map((opt) => ({ + value: opt.value, + label: opt.label, + disabled: opt.disabled, + })); + + // Convert childFieldOptions to SelectOption format + const childSelectOptions: SelectOption[] | undefined = childFieldOptions?.map( + (opt) => ({ + value: opt.value, + label: opt.label, + disabled: opt.disabled, + }) + ); + + const isMapped = !!column.mappedTo && !column.ignored; + return (
{/* Card Header */} -
-
+
+ {!column.ignored && + (isMapped ? ( + + + + + + ) : ( + + + + + + + ))} +
{column.name}
{/* Card Body */} -
+
{/* Sample Value */} -
- - {labels.incomingSample} +
+ + Sample Data -
+
{column.sampleValue || ( Empty )}
-
- {/* Field Type Select */} -
- - + + + placeholder="Select sub-field..." + size="sm" + hideLabel + />
)} -
- {/* Card Footer */} -
+ {/* Ignore/Include Link */}
@@ -424,9 +454,7 @@ export function CSVFileUpload({
) : ( <> - +

{selectFile}