Skip to content

Commit

Permalink
feat: Added Facility to send daata to user on manual entry (#835)
Browse files Browse the repository at this point in the history
  • Loading branch information
chavda-bhavik authored Oct 7, 2024
2 parents 200388f + 437516e commit 80d651c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { useEffect, useRef, useState } from 'react';
import { PhasesEnum } from '@types';
import { Button } from '@ui/Button';
import { MANUAL_ENTRY_LIMIT } from '@config';
import { WIDGET_TEXTS } from '@impler/client';
import { Table } from 'components/Common/Table';
import { Footer } from 'components/Common/Footer';
import { LoadingOverlay } from '@ui/LoadingOverlay';
import { IUpload, WIDGET_TEXTS } from '@impler/client';
import { SegmentedControl } from '@ui/SegmentedControl';
import { useDataGrid } from '@hooks/DataGrid/useDataGrid';
import { useCompleteImport } from '@hooks/useCompleteImport';
Expand All @@ -18,8 +18,8 @@ import { useBatchedUpdateRecord } from '@hooks/DataGrid/useBatchUpdateRecords';

interface IPhase12Props {
onPrevClick: () => void;
onNextClick: () => void;
texts: typeof WIDGET_TEXTS;
onNextClick: (uploadData: IUpload, importedData?: Record<string, any>[]) => void;
}

export function DataGrid({ onNextClick, onPrevClick, texts }: IPhase12Props) {
Expand Down
11 changes: 9 additions & 2 deletions apps/widget/src/components/widget/Widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ export function Widget() {
resetAmplitude();
setPhase(PhasesEnum.VALIDATE);
};
const onComplete = (uploadData: IUpload, importedData?: Record<string, any>[]) => {
const onComplete = (uploadData: IUpload, importedData?: Record<string, any>[], doClose = false) => {
setDataCount(uploadData.totalRecords);
setPhase(PhasesEnum.COMPLETE);
ParentWindow.UploadCompleted(uploadData);
if (importedData) ParentWindow.DataImported(importedData);
if (doClose) closeWidget();
};
const onSuccess = useCallback(() => {
setImportConfig((configData: IImportConfig) => {
Expand All @@ -122,7 +123,13 @@ export function Widget() {
}
: flow === FlowsEnum.MANUAL_ENTRY
? {
[PhasesEnum.MANUAL_ENTRY]: <DataGrid texts={texts} onPrevClick={onUploadResetClick} onNextClick={onClose} />,
[PhasesEnum.MANUAL_ENTRY]: (
<DataGrid
texts={texts}
onPrevClick={onUploadResetClick}
onNextClick={(uploadData, importedData) => onComplete(uploadData, importedData, true)}
/>
),
}
: {
[PhasesEnum.IMAGE_UPLOAD]: <ImageUpload texts={texts} goToUpload={() => setPhase(PhasesEnum.UPLOAD)} />,
Expand Down

0 comments on commit 80d651c

Please sign in to comment.