-
Notifications
You must be signed in to change notification settings - Fork 48
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
Fix fetching of company contacts in joblisting editor #4599
base: master
Are you sure you want to change the base?
Fix fetching of company contacts in joblisting editor #4599
Conversation
form.change('joblistingEditor', { | ||
label: 'Ingen', | ||
value: null, | ||
}); | ||
form.change('responsible', { | ||
label: 'Ingen', | ||
value: null, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea why this was here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need the 'responsible' one. If you change the company, there will be a different set of responsible persons (Kontaktpersoner) to choose from. So if we have selected a responsible person from company A and then change to company B we need to clear the clear the field to ensure that the responsible person is from the correct company.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes that actually makes sense haha
return dispatch( | ||
fetchCompanyContacts({ | ||
companyId: company.id, | ||
companyId: 'value' in company ? company.value : company.id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When tyring to save changes, I get the following error: right-hand side of 'in' should be an object, got number
. According to Google, you have to do something like this instead:(Object.values(companyj).indexOf('value') > -1)
).then((action) => { | ||
const responsibleOptions = action.payload.map((contact) => ({ | ||
).then((res) => { | ||
const responsibleOptions = res.payload.results.map((contact) => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get a TypeScript error here. The payload is given the CompanyContact[]
-type even though the type should really be given to .results
.
Description
Two issues fixed here. When creating a new joblisting, the company contacts would not be fetched since the company id would be in
company.value
instead ofcompany.id
. Secondly, once you've managed to fetch, you would also get an error since it was trying to map over the payload instead of the results.Also,
Result
No visual changes.
Testing
Editing and creating joblistings now work without any errors.