Skip to content
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 validation of existing company in interest form #4172

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/routes/companyInterest/components/CompanyInterestPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ const validateCompany = (value) => {
} else if (value['__isNew__'] || !value.value) {
return [!!value.label, 'Ny bedrift må ha et navn'] as const;
} else {
return [typeof value?.value !== 'number', 'Ugyldig bedrift'] as const;
return [!isNaN(Number(value?.value)), 'Ugyldig bedrift'] as const;
}
};

Expand Down Expand Up @@ -359,7 +359,7 @@ const CompanyInterestPage = (props: Props) => {
const onSubmit = (data) => {
const { company } = data;
const nameOnly = company['__isNew__'] || !company.value;
const companyId = nameOnly ? null : company['value'];
const companyId = nameOnly ? null : Number(company['value']);
const companyName = nameOnly ? company['label'] : '';

const [range_start, range_end] = data.participantRange
Expand Down