Skip to content

Commit

Permalink
feat: Added method in react hook for accessing imported data
Browse files Browse the repository at this point in the history
  • Loading branch information
chavda-bhavik committed Jul 15, 2024
1 parent 59d98ca commit b0ff1eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/react/src/hooks/useImpler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function useImpler({
onUploadComplete,
onWidgetClose,
onUploadStart,
onDataImported,
onUploadTerminate,
}: UseImplerProps) {
const [uuid] = useState(generateUuid());
Expand All @@ -30,7 +31,8 @@ export function useImpler({
if (onUploadTerminate) onUploadTerminate(eventData.value);
break;
case EventTypesEnum.UPLOAD_COMPLETED:
if (onUploadComplete) onUploadComplete(eventData.value);
if (onDataImported) onDataImported(eventData.value.importedData);
if (onUploadComplete) onUploadComplete(eventData.value.uploadInfo);
break;
case EventTypesEnum.CLOSE_WIDGET:
if (onWidgetClose) onWidgetClose();
Expand Down
7 changes: 5 additions & 2 deletions packages/react/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export type EventCalls =
}
| {
type: EventTypesEnum.UPLOAD_COMPLETED;
value: IUpload;
value: {
uploadInfo: IUpload;
importedData: Record<string, any>[];
};
}
| {
type: EventTypesEnum.CLOSE_WIDGET;
Expand All @@ -86,6 +89,6 @@ export interface UseImplerProps {
onUploadStart?: (value: UploadTemplateData) => void;
onUploadTerminate?: (value: UploadData) => void;
onUploadComplete?: (value: IUpload) => void;
onDataImported?: () => void;
onDataImported?: (importedData: Record<string, any>[]) => void;
onWidgetClose?: () => void;
}

0 comments on commit b0ff1eb

Please sign in to comment.