Skip to content

related org append / remove#436

Merged
joffinjoy merged 7 commits intoELEVATE-Project:developfrom
adithyadinesh0412:working-branch
Mar 14, 2024
Merged

related org append / remove#436
joffinjoy merged 7 commits intoELEVATE-Project:developfrom
adithyadinesh0412:working-branch

Conversation

@adithyadinesh0412
Copy link
Collaborator

No description provided.

// update parent org related orgs
const parentOrganzationUpdate = await organizationQueries.update(
{
id: id,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a sylistic thing. you can simply mention this as {id} instead of { id:id}. Valid only when the key and variable from which the value is set are both with the same name.

)

// update child org related orgs
const childOrganzationUpdate = await organizationQueries.removeRelatedOrg(id, relatedOrgs, {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename this as relatedOrganizationsUpdate. There are no child organizations as of right now.

static async addRelatedOrg(id, relatedOrgs) {
try {
// fetch organization details before update
const orgDetailsBeforeUpdate = await organizationQueries.findOne({ id: id })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{id} should be enough

message: 'ORGANIZATION_NOT_FOUND',
})
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw an error the request tries to remove an organization that doesn't exist as a related org to the parent org.

// check if there are any addition to related_org
if (!_.isEqual(orgDetailsBeforeUpdate?.related_orgs, relatedOrganizations)) {
// update parent org related orgs
const parentOrganzationUpdate = await organizationQueries.update(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename this as currentOrganizationUpdate. parent and child can be confusing later on.

@joffinjoy joffinjoy merged commit ac85fd2 into ELEVATE-Project:develop Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants