Skip to content

Commit

Permalink
some guard rails - projects.new and projects.service, first pass
Browse files Browse the repository at this point in the history
  • Loading branch information
horatiorosa committed Jan 3, 2025
1 parent a34d218 commit 580bb36
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion client/app/components/projects/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ export default class ProjectsNewFormComponent extends Component {
console.debug(`LOGGER: POST request in the client controller to took ${requestEndTime - requestStartTime} ms`);
console.debug('response in client controller: ', response, 'response status: ', response.status);

this.args.package.saveAttachedFiles(project.attributes['dcp-artifactsid']);
const artifactsId = project.attributes['dcp-artifactsid'];
if (artifactsId === undefined) {
throw new Error('failed to create project with artifact');
}

await this.args.package.saveAttachedFiles(artifactsId);

this.router.transitionTo('projects');
} catch {
Expand Down
13 changes: 13 additions & 0 deletions server/src/projects/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,19 @@ export class ProjectsService {
// 'dcp_projects',
// data,
// );
const crmResponse = await this.crmService.get(
'dcp_projects',
// 3e5 = created within 5 minutes

`
$filter=
dcp_projectname eq '${data.dcp_projectname}'
and createdon ge '${new Date(Date.now() - 3e5).toISOString()}'
`
)

console.debug('HELLO??: crm response', crmResponse);

const project = await this.crmService.create(
'dcp_projects',
data,
Expand Down

0 comments on commit 580bb36

Please sign in to comment.