Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat manual entry #821

Merged
merged 32 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7f82b2c
feat: Basic layout setup
chavda-bhavik Sep 26, 2024
00737ab
feat: Removed selected file item from dropzone
chavda-bhavik Sep 30, 2024
b985477
feat: Added Divider component
chavda-bhavik Sep 30, 2024
6a767db
feat: Added ManualEntryView Component
chavda-bhavik Sep 30, 2024
171e318
feat: Removed Submit Button on Upload Step
chavda-bhavik Sep 30, 2024
bb30e27
feat: Improved Phase1 View
chavda-bhavik Sep 30, 2024
5e27297
refactor: Widget
chavda-bhavik Sep 30, 2024
923c362
refactor: Layout and Phase1 styles
chavda-bhavik Sep 30, 2024
40b2545
refactor: Stepper & FileDropdown
chavda-bhavik Sep 30, 2024
5be1a6f
refactor: Modal
chavda-bhavik Sep 30, 2024
708ecbb
feat: Renamed update-cell to update-record
chavda-bhavik Oct 2, 2024
93dd7d1
feat: Handled creating empty import
chavda-bhavik Oct 2, 2024
786695d
feat: Refactored review types
chavda-bhavik Oct 2, 2024
b7c2226
feat: Added Types
chavda-bhavik Oct 2, 2024
5b8ee8b
feat: Rename update record
chavda-bhavik Oct 2, 2024
518bf01
feat: Updated Table component to handle navigation, spareRows and row…
chavda-bhavik Oct 2, 2024
9c34f41
feat: Updated headings for table
chavda-bhavik Oct 2, 2024
8c0ea2b
feat: Create Manual Entry Component and added types
chavda-bhavik Oct 2, 2024
24ae186
feat: Texts, Style, Icon streamline
chavda-bhavik Oct 2, 2024
7be1d80
feat: Added update-records route and handled empty headings on manual…
chavda-bhavik Oct 3, 2024
7482573
feat: Streamlined manual entry flow
chavda-bhavik Oct 3, 2024
a448721
feat: Optimized rendering
chavda-bhavik Oct 3, 2024
c0e1241
feat: Updated update records command
chavda-bhavik Oct 3, 2024
6ae0b69
refactor: Data import confirmation logic into seperate hook
chavda-bhavik Oct 3, 2024
176b1b2
feat: Leveraged css-variables for styling mapping item
chavda-bhavik Oct 3, 2024
c3b67cd
feat: Leveraged CSS variables for styling dropzone
chavda-bhavik Oct 3, 2024
a44c0eb
feat: Refreshed uploadInfo on review and used reusable hook
chavda-bhavik Oct 3, 2024
483d298
feat: Made button compatible with tooltip
chavda-bhavik Oct 3, 2024
fa005e4
feat: Updated grid icon and texts
chavda-bhavik Oct 3, 2024
55356be
feat: Removed unused key from add-upload-entry-command
chavda-bhavik Oct 3, 2024
5e2b0e0
feat: Leveraged css variables to implement visual customization
chavda-bhavik Oct 3, 2024
df20a46
feat: Applied modal styling on root
chavda-bhavik Oct 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/api/src/app/review/dtos/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './delete-records.dto';
export * from './update-cell.dto';
export * from './update-record.dto';
export * from './replace.dto';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsDefined } from 'class-validator';

export class UpdateCellDto {
export class UpdateRecordDto {
@ApiProperty({
description: 'Record index',
})
Expand Down
33 changes: 29 additions & 4 deletions apps/api/src/app/review/review.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { ApiOperation, ApiTags, ApiSecurity, ApiQuery, ApiOkResponse } from '@nestjs/swagger';
import { BadRequestException, Body, Controller, Get, Param, Post, Put, Query, UseGuards } from '@nestjs/common';
import {
BadRequestException,
Body,
Controller,
Get,
Param,
ParseArrayPipe,
Post,
Put,
Query,
UseGuards,
} from '@nestjs/common';

import { APIMessages } from '@shared/constants';
import { JwtAuthGuard } from '@shared/framework/auth.gaurd';
Expand All @@ -15,11 +26,12 @@ import {
StartProcess,
DeleteRecord,
GetUploadData,
UpdateRecords,
} from './usecases';

import { UserSession } from '@shared/framework/user.decorator';
import { validateNotFound } from '@shared/helpers/common.helper';
import { DeleteRecordsDto, UpdateCellDto, ReplaceDto } from './dtos';
import { DeleteRecordsDto, UpdateRecordDto, ReplaceDto } from './dtos';
import { PaginationResponseDto } from '@shared/dtos/pagination-response.dto';
import { ValidateMongoId } from '@shared/validations/valid-mongo-id.validation';

Expand All @@ -35,6 +47,7 @@ export class ReviewController {
private deleteRecord: DeleteRecord,
private startProcess: StartProcess,
private updateRecord: UpdateRecord,
private updateRecords: UpdateRecords,
private getFileInvalidData: GetUploadData
) {}

Expand Down Expand Up @@ -131,8 +144,20 @@ export class ReviewController {
@ApiOperation({
summary: 'Update review record for ongoing import',
})
async updateReviewData(@Param('uploadId', ValidateMongoId) _uploadId: string, @Body() body: UpdateCellDto) {
await this.updateRecord.execute(_uploadId, body);
async updateReviewData(@Param('uploadId') _uploadId: string, @Body() body: UpdateRecordDto) {
return this.updateRecord.execute(_uploadId, body);
}

@Put(':uploadId/records')
@UseGuards(JwtAuthGuard)
@ApiOperation({
summary: 'Delete review records for ongoing import',
})
async updateRecordsRoute(
@Param('uploadId') _uploadId: string,
@Body(new ParseArrayPipe({ items: UpdateRecordDto })) body: UpdateRecordDto[]
) {
await this.updateRecords.execute(_uploadId, body);
}

@Post(':uploadId/delete-records')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
DalService,
TemplateEntity,
TemplateRepository,
RecordEntity,
} from '@impler/dal';

interface ISaveResults {
Expand All @@ -28,7 +29,7 @@ interface ISaveResults {

@Injectable()
export class DoReview extends BaseReview {
private _modal: Model<unknown>;
private _modal: Model<RecordEntity>;

constructor(
private templateRepository: TemplateRepository,
Expand All @@ -44,7 +45,7 @@ export class DoReview extends BaseReview {
}

async execute(_uploadId: string) {
this._modal = await this.dalService.createRecordCollection(_uploadId);
this._modal = this.dalService.getRecordCollection(_uploadId);
const userEmail = await this.uploadRepository.getUserEmailFromUploadId(_uploadId);

const uploadInfo = await this.uploadRepository.getUploadWithTemplate(_uploadId, ['name']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ export class DoReReview extends BaseReview {
});
let result: ISaveResults = {
uploadId: _uploadId,
totalRecords: uploadInfo.totalRecords,
validRecords: uploadInfo.validRecords,
invalidRecords: uploadInfo.invalidRecords,
totalRecords: uploadInfo.totalRecords || 0,
validRecords: uploadInfo.validRecords || 0,
invalidRecords: uploadInfo.invalidRecords || 0,
};

if (validations && validations.onBatchInitialize) {
Expand Down Expand Up @@ -223,8 +223,8 @@ export class DoReReview extends BaseReview {
const response: ISaveResults = {
uploadId,
totalRecords: 0,
validRecords: result.validRecords,
invalidRecords: result.invalidRecords,
validRecords: result.validRecords || 0,
invalidRecords: result.invalidRecords || 0,
};

for await (const record of this._modal.find({ updated: { $ne: {}, $exists: true } })) {
Expand Down
7 changes: 5 additions & 2 deletions apps/api/src/app/review/usecases/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { PaymentAPIService } from '@impler/services';
import { Replace } from './replace/replace.usecase';
import { DoReview } from './do-review/do-review.usecase';
import { UpdateRecord } from './update-cell/update-cell.usecase';
import { DeleteRecord } from './delete-record/delete-record.usecase';
import { DoReReview } from './do-review/re-review-data.usecase';
import { UpdateRecord } from './update-record/update-record.usecase';
import { UpdateRecords } from './update-records/update-records.usecase';
import { DeleteRecord } from './delete-record/delete-record.usecase';
import { StartProcess } from './start-process/start-process.usecase';
import { GetUploadData } from './get-upload-data/get-upload-data.usecase';
import { GetUpload } from '@shared/usecases/get-upload/get-upload.usecase';
Expand All @@ -16,6 +17,7 @@ export const USE_CASES = [
DeleteRecord,
UpdateRecord,
StartProcess,
UpdateRecords,
GetUploadData,
PaymentAPIService,
];
Expand All @@ -29,5 +31,6 @@ export {
UpdateRecord,
StartProcess,
GetUploadData,
UpdateRecords,
PaymentAPIService,
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export class UpdateCellCommand {
export class UpdateRecordCommand {
index: number;

record: Record<string, any>;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Injectable } from '@nestjs/common';
import { DalService } from '@impler/dal';
import { UpdateRecordCommand } from './update-record.command';

@Injectable()
export class UpdateRecord {
constructor(private dalService: DalService) {}

async execute(_uploadId: string, data: UpdateRecordCommand) {
return this.dalService.updateRecord(_uploadId, data.index, data.record, data.updated);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Injectable } from '@nestjs/common';
import { DalService, UploadRepository } from '@impler/dal';
import { UpdateRecordCommand } from '../update-record/update-record.command';

@Injectable()
export class UpdateRecords {
constructor(
private dalService: DalService,
private uploadRepository: UploadRepository
) {}

async execute(_uploadId: string, data: UpdateRecordCommand[]) {
const result = await this.dalService.updateRecords(_uploadId, data);
await this.uploadRepository.update(
{
_id: _uploadId,
},
{
$inc: {
totalRecords: result.upsertedCount,
invalidRecords: result.upsertedCount,
},
}
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { FileNotValidError } from '../exceptions/file-not-valid.exception';
@Injectable()
export class ValidImportFile implements PipeTransform<Express.Multer.File> {
transform(value: Express.Multer.File) {
if (!SupportedFileMimeTypes.includes(value.mimetype)) {
if (value && !SupportedFileMimeTypes.includes(value.mimetype)) {
throw new FileNotValidError();
}

Expand Down
16 changes: 8 additions & 8 deletions apps/api/src/app/upload/dtos/upload-request.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,59 @@ export class UploadRequestDto {
type: 'file',
required: true,
})
file: Express.Multer.File;
file?: Express.Multer.File;

@ApiProperty({
description: 'Auth header value to send during webhook call',
required: false,
})
@IsOptional()
@IsString()
authHeaderValue: string;
authHeaderValue?: string;

@ApiProperty({
description: 'Custom schema if wants to override default schema',
required: false,
})
@IsOptional()
@IsJSON()
schema: string;
schema?: string;

@ApiProperty({
description: 'Custom output if wants to modify how schema values are sent',
required: false,
})
@IsOptional()
@IsJSON()
output: string;
output?: string;

@ApiProperty({
description: 'Payload to send during webhook call',
required: false,
})
@IsOptional()
@IsJSON()
extra: string;
extra?: string;

@ApiProperty({
description: 'Name of the excel sheet to Import',
})
@IsOptional()
@IsString()
selectedSheetName: string;
selectedSheetName?: string;

@ApiProperty({
description: 'ID of the import if already created',
})
@IsOptional()
@IsMongoId()
importId: string;
importId?: string;

@ApiProperty({
description: 'Image schema for importing excel with images',
required: false,
})
@IsOptional()
@IsJSON()
imageSchema: string;
imageSchema?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export class AddUploadEntryCommand {

_allDataFileId?: string;

_uploadedFileId: string;
_uploadedFileId?: string;

uploadId: string;

Expand All @@ -13,15 +13,13 @@ export class AddUploadEntryCommand {

headings?: string[];

totalRecords?: number;

schema?: string;

originalFileName: string;
originalFileName?: string;

originalFileType: string;
originalFileType?: string;

customRecordFormat?: string;
customRecordFormat: string;

customChunkFormat?: string;
customChunkFormat: string;
}
Loading
Loading