-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve event edit form dirty state detection
Type improvements around event edit
- Loading branch information
1 parent
aa17aed
commit c3989a9
Showing
9 changed files
with
78 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Generates a random color in hex format | ||
*/ | ||
export function randomColor() { | ||
return `#${Math.floor(Math.random() * 16777215).toString(16)}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {EventEditDto} from '../eventTypes'; | ||
import {EventEditFormType} from '../../../contexts/event/action/EventActionFormContext'; | ||
import {replaceNullWithEmpty, replaceNullWithUndefined} from '../../../utils/typesHelper'; | ||
|
||
/** | ||
* Converts a {@link EventEditDto} to the format {@link EventEditFormType expected by the form}. | ||
*/ | ||
export function convertDtoToFormEvent(dto: EventEditDto): EventEditFormType { | ||
const {dateTime, ...eventDto} = dto; | ||
replaceNullWithEmpty(eventDto, ['description', 'missionLength', 'missionType', 'pictureUrl']); | ||
replaceNullWithUndefined(eventDto, ['reserveParticipating']); | ||
const date = new Date(dateTime); | ||
return {...eventDto, date: date, startTime: date}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters