Skip to content

Commit

Permalink
feat: Added the check only make template if file exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayur committed Jan 28, 2025
1 parent e8c1e50 commit bb3520e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
1 change: 0 additions & 1 deletion apps/api/src/app/shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,5 @@ export const CRON_SCHEDULE = {
CRON_TIME: '45 23 * * *',
};

export const SAMPLE_IMPORT_NAME = 'Product Data Import';
export const TYPE_CHECK_SAMPLE = 10;
export const MAX_FILE_SIZE = 10 * 1024 * 1024;
18 changes: 10 additions & 8 deletions apps/api/src/app/template/template.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,16 @@ export class TemplateController {
importIntegration: body.integration as IntegrationEnum,
})
);
await this.updateTemplateColumns.execute(
body.columns.map((columnData) => ({
_templateId: template._id,
...columnData,
})),
template._id,
user.email
);
if (body.columns) {
await this.updateTemplateColumns.execute(
body.columns.map((columnData) => ({
_templateId: template._id,
...columnData,
})),
template._id,
user.email
);
}

return template;
}
Expand Down
1 change: 1 addition & 0 deletions apps/web/config/constants.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const CONSTANTS = {
'An error occurred with the payment. No amount has been deducted. Please try again later or contact the support team.',
SUBSCRIPTION_ACTIVATED_TITLE: 'Subscription activated',
SUBSCRIPTION_FAILED_TITLE: 'Payment failed',
SAMPLE_IMPORT_NAME: 'Product Data Import',
};

export const VARIABLES = {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/pages/auth/onboarding/OnboardImportForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CreateImportForm } from './CreateImportForm';
import { useForm } from 'react-hook-form';
import { useTemplateSchema } from '@hooks/useTemplateSchema';
import { useAppState } from 'store/app.context';
import { sampleColumns } from '@config';
import { CONSTANTS, sampleColumns } from '@config';

export default function OnboardImportForm() {
const { profileInfo } = useAppState();
Expand All @@ -28,7 +28,7 @@ export default function OnboardImportForm() {
const handleCreateImportFormSubmit = async (createImportFormData: CreateOnboardImportFormData) => {
if (createImportFormData.onboardCreateTemplateMode === OnboardCreateTemplateModeEnum.SAMPLE_COLUMN) {
createOnboardTemplateSample({
name: createImportFormData.importName,
name: CONSTANTS.SAMPLE_IMPORT_NAME,
_projectId: profileInfo!._projectId,
columns: sampleColumns as IColumn[],
});
Expand Down

0 comments on commit bb3520e

Please sign in to comment.