Skip to content

Commit

Permalink
fix: filter resources without a member from values
Browse files Browse the repository at this point in the history
  • Loading branch information
IanFonzie committed Feb 23, 2024
1 parent 3dcb99e commit cdbcf0b
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,21 @@ export const update: component_.base.Update<State, Msg> = ({ state, msg }) => {
export type Values = CreateTWUProposalTeamMemberBody[];

export function getValues(state: Immutable<State>): Values {
return state.members.map((m) => ({
member: Select.getValue(m.member),
hourlyRate: FormField.getValue(m.hourlyRate) ?? 0,
resource: m.resource.id
}));
return state.members.reduce<Values>((acc, m) => {
const member = Select.getValue(m.member);
if (!member) {
return acc;
}

return [
...acc,
{
member,
hourlyRate: FormField.getValue(m.hourlyRate) ?? 0,
resource: m.resource.id
}
];
}, []);
}

export type Errors = CreateTWUProposalTeamMemberValidationErrors[];
Expand Down

0 comments on commit cdbcf0b

Please sign in to comment.