Skip to content

Commit

Permalink
cherrypick changes from ty/1254/upload-documents
Browse files Browse the repository at this point in the history
  • Loading branch information
horatiorosa committed Jan 8, 2025
1 parent 247514f commit 99a7ccc
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 41 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jobs:
- uses: actions/checkout@v4
with:
sparse-checkout: server
- name: 'Install Heroku CLI'
run: curl https://cli-assets.heroku.com/install.sh | sh
- uses: akhileshns/[email protected]
name: Deploy server to Heroku
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
with:
ref: 'main'
sparse-checkout: server
- name: 'Install Heroku CLI'
run: curl https://cli-assets.heroku.com/install.sh | sh
- uses: akhileshns/[email protected]
name: Deploy server to Heroku
with:
Expand Down
24 changes: 15 additions & 9 deletions client/app/components/projects/new.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,23 @@
<saveableProjectsNewForm.SubmitButton @isEnabled={{saveableProjectsNewForm.isSubmittable}} data-test-save-button />
</saveableProjectsNewForm.PageNav>
<Messages::Assistance class="large-margin-top" />
<saveableProjectsNewForm.ConfirmationModal @action={{component saveableProjectsNewForm.SubmitButton
isEnabled=saveableProjectsNewForm.isSubmittable onClick=this.submitProject class="no-margin" }}
<saveableProjectsNewForm.ConfirmationModal @action={{component saveableProjectsNewForm.SubmitButton onClick=this.submitProject class="no-margin" }}
disabled={{or (not saveableProjectsNewForm.isSubmittable) this.submissionError}}
@continueButtonTitle="Continue Editing" data-test-confirm-submit-button={{true}}>
<h6>Confirm New Project Submission</h6>
<p class="header-large medium-margin-top small-margin-bottom">
Are you sure?
</p>
<p>
Before submitting, ensure that your answers are accurate and complete, and that necessary attachments have been uploaded. If NYC Planning does not receive enough accurate information to provide guidance, the Lead Planner will notify you and request that this form be resubmitted with necessary materials, corrections, or
clarifications.
</p>
{{#if this.submissionError}}
<p class="header-large medium-marin-top small-margin-bottom">Error while creating project. Lorem Ipsum.....</p>
{{else}}
<p class="header-large medium-margin-top small-margin-bottom">
Are you sure?
</p>
<p>
Before submitting, ensure that your answers are accurate and complete, and that necessary attachments have been
uploaded. If NYC Planning does not receive enough accurate information to provide guidance, the Lead Planner will
notify you and request that this form be resubmitted with necessary materials, corrections, or
clarifications.
</p>
{{/if}}
</saveableProjectsNewForm.ConfirmationModal>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions client/app/components/projects/new.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
import SubmittableProjectsNewForm from '../../validations/submittable-projects-new-form';
import { optionset } from '../../helpers/optionset';
Expand All @@ -11,6 +12,8 @@ export default class ProjectsNewFormComponent extends Component {
SubmittableProjectsNewForm,
};

@tracked submissionError = false;

requestCounter = 0;

@service
Expand All @@ -29,6 +32,7 @@ export default class ProjectsNewFormComponent extends Component {

@action
async submitProject() {
this.submissionError = false;
const requestStartTime = Date.now();
this.requestCounter++;
console.log(`LOGGER: [Total Requests Made in the client controller] ${this.requestCounter}`);
Expand Down Expand Up @@ -134,6 +138,7 @@ export default class ProjectsNewFormComponent extends Component {

this.router.transitionTo('projects');
} catch {
this.submissionError = true;
/* eslint-disable-next-line no-console */
console.error('Error while creating project');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,4 @@
The size limit for each file is 50 MB. You can upload up to 1 GB of files.
</p>
</fieldset>
</div>
</div>
8 changes: 7 additions & 1 deletion server/src/projects/projects.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ import { ArtifactService } from '../artifacts/artifacts.service';
import { SharepointModule } from '../sharepoint/sharepoint.module';

@Module({
imports: [CrmModule, SharepointModule, ConfigModule, ContactModule, AuthModule],
imports: [
CrmModule,
SharepointModule,
ConfigModule,
ContactModule,
AuthModule,
],
providers: [ProjectsService, ArtifactService],
exports: [ProjectsService],
controllers: [ProjectsController, ProjectApplicantController],
Expand Down
45 changes: 15 additions & 30 deletions server/src/projects/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,56 +128,41 @@ export class ProjectsService {
// 'dcp_projects',
// data,
// );
const crmResponse = await this.crmService.get(
const { records } = await this.crmService.get(
'dcp_projects',
// 3e5 = created within 5 minutes

`
$filter=
dcp_projectname eq '${data.dcp_projectname}'
dcp_projectname eq '${encodeURIComponent(data.dcp_projectname)}'
and createdon ge '${new Date(Date.now() - 3e5).toISOString()}'
`
)
const { records } = crmResponse;
console.debug('LOGGER: crm response', crmResponse);
try {
if (records.length > 0) {
console.log('Project already exists');
throw new Error('Project already exists');
}
} catch (e) {

}

console.debug('LOGGER: crm records', records);
if (records.length > 0) throw new Error('Project already exists');

const project = await this.crmService.create(
'dcp_projects',
data,
);
const project = await this.crmService.create('dcp_projects', data);
// console.debug("LOGGER: (service) project", project);
const { dcp_projectid } = project;

// const { dcp_artifactsid } =
// await this.artifactService.createProjectInitiationArtifacts(
// dcp_projectid,
// );
const dcpProjectId = project['dcp_projectid'];
if (dcpProjectId === undefined) throw new Error('Failed to create project');

const artifact =
await this.artifactService.createProjectInitiationArtifacts(
dcp_projectid,
);
await this.artifactService.createProjectInitiationArtifacts(dcpProjectId);

// console.debug('LOGGER: (service) artifact', artifact);
const { dcp_artifactsid } = artifact;
const dcpArtifactsId = artifact['dcp_artifactsid'];
if (dcpArtifactsId === undefined) throw new Error('Failed to create artifact for project');

const requestEndTime = Date.now();
console.debug(`LOGGER: POST (service) request in the service to took ${requestEndTime - requestStartTime} ms`);
requestCounter++;
console.log(`LOGGER: [Total Requests Made in the service] ${requestCounter}`);
return {
dcp_projectid,
dcp_artifactsid,
dcp_projectid: dcpProjectId,
dcp_artifactsid: dcpArtifactsId,
};
} catch (e) {
console.debug('(service) error creating project', e);
console.error('(service) error creating project', e);
throw new HttpException(
'Unable to create project',
HttpStatus.INTERNAL_SERVER_ERROR,
Expand Down

0 comments on commit 99a7ccc

Please sign in to comment.