Skip to content

Commit

Permalink
Fix default daterange value for meeting create (#2534)
Browse files Browse the repository at this point in the history
  • Loading branch information
luisa-beerboom authored Jul 27, 2023
1 parent 90b6df3 commit f170890
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 9 additions & 0 deletions client/src/app/gateways/error-mapping/error-map-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';

import { MeetingAction } from '../repositories/meetings';
import { MotionAction } from '../repositories/motions';

export class MapError {
Expand Down Expand Up @@ -39,6 +40,12 @@ const VoteServiceErrorMap: ErrorMap = new ErrorMap([
]);

const MotionCreateForwardErrorMap: ErrorMap = new ErrorMap([[/(.*)/, input => new MapError(input)]]);
const MeetingCreateErrorMap: ErrorMap = new ErrorMap([
[
/Only one of start_time and end_time is not allowed./,
_(`Start and end time must either both be set or both be empty`)
]
]);

/**
* Finds the correct error map for an action response by the original requests action name
Expand All @@ -47,6 +54,8 @@ const MotionCreateForwardErrorMap: ErrorMap = new ErrorMap([[/(.*)/, input => ne
const getActionErrorMap: (data: any) => ErrorMap | null = data => {
const actionName = Array.isArray(data) && typeof data[0] === `object` ? data[0][`action`] : null;
switch (actionName) {
case MeetingAction.CREATE:
return MeetingCreateErrorMap;
case MotionAction.CREATE_FORWARDED:
return MotionCreateForwardErrorMap;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,12 @@ export class MeetingEditComponent extends BaseComponent implements OnInit {
const rawForm: { [key: string]: any } = {
name: [``, Validators.required],
location: [``],
daterange: {
start: [currentDate],
end: [currentDate]
},
daterange: [
{
start: currentDate,
end: currentDate
}
],
admin_ids: [[], Validators.minLength(1)],
organization_tag_ids: [[]],
external_id: [``]
Expand Down

0 comments on commit f170890

Please sign in to comment.