-
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 adding new company through interest form #4162
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -322,8 +322,18 @@ const requiredIfEventType = (eventType: string) => | |||||||||
return event && event.checked; | ||||||||||
}); | ||||||||||
|
||||||||||
const validateCompany = (value) => { | ||||||||||
if (!value) { | ||||||||||
return [false, 'Du må velge en bedrift'] as const; | ||||||||||
} else if (value['__isNew__'] || !value.value) { | ||||||||||
return [!!value.label, 'Ny bedrift må ha et navn'] as const; | ||||||||||
} else { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary else |
||||||||||
return [typeof value?.value !== 'number', 'Ugyldig bedrift'] as const; | ||||||||||
} | ||||||||||
}; | ||||||||||
|
||||||||||
const validate = createValidator({ | ||||||||||
company: [required()], | ||||||||||
company: [validateCompany], | ||||||||||
contactPerson: [required()], | ||||||||||
mail: [required(), isEmail()], | ||||||||||
phone: [required()], | ||||||||||
|
@@ -348,8 +358,10 @@ const CompanyInterestPage = (props: Props) => { | |||||||||
|
||||||||||
const onSubmit = (data) => { | ||||||||||
const { company } = data; | ||||||||||
const companyId = company['value'] ? Number(company['value']) : null; | ||||||||||
const companyName = companyId === null ? company['label'] : ''; | ||||||||||
const nameOnly = company['__isNew__'] || !company.value; | ||||||||||
const companyId = nameOnly ? null : company['value']; | ||||||||||
const companyName = nameOnly ? company['label'] : ''; | ||||||||||
Comment on lines
+362
to
+363
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Any specific reason for using squared brackets? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not really, just didn't change it |
||||||||||
|
||||||||||
const [range_start, range_end] = data.participantRange | ||||||||||
? PARTICIPANT_RANGE_MAP[data.participantRange] | ||||||||||
: [null, null]; | ||||||||||
|
@@ -447,6 +459,7 @@ const CompanyInterestPage = (props: Props) => { | |||||||||
filter={['companies.company']} | ||||||||||
fieldClassName={styles.metaField} | ||||||||||
component={SelectInput.AutocompleteField} | ||||||||||
creatable | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not set the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assumed the |
||||||||||
required | ||||||||||
/> | ||||||||||
<Field | ||||||||||
|
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.
Picky, but might as well destruct it from props as well like the others