-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(front): component triggering REST call
- create Action control, create action status - unwind response + commit after call
- Loading branch information
1 parent
7f36dbe
commit 609ff13
Showing
17 changed files
with
118 additions
and
129 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
32 changes: 19 additions & 13 deletions
32
frontend/src/v2/features/common/hooks/use-mission-timeline.tsx
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 |
---|---|---|
@@ -1,27 +1,33 @@ | ||
import { ActionTypeEnum } from '@common/types/env-mission-types' | ||
import { ActionTypeEnum, MissionSourceEnum } from '@common/types/env-mission-types' | ||
import { MissionNavAction } from '../types/mission-action' | ||
|
||
type ActionRegistryInput = { [key in ActionTypeEnum]?: unknown } | ||
type Input = { missionId: number; startDateTimeUtc: Date } | ||
|
||
const ACTION_REGISTRY_INPUT: ActionRegistryInput = { | ||
[ActionTypeEnum.NOTE]: { endDateTimeUtc: new Date().toISOString() }, | ||
[ActionTypeEnum.RESCUE]: { isPersonRescue: false, isVesselRescue: true } | ||
} | ||
|
||
interface TimelineHook<T> { | ||
getBaseInput: () => Input | ||
getActionDataInput: (actionType: ActionTypeEnum) => unknown | ||
getActionInput: (actionType: ActionTypeEnum, moreData?: unknown) => MissionNavAction | ||
} | ||
|
||
export function useMissionTimeline<T>(missionId?: string): TimelineHook<T> { | ||
const getActionDataInput = (actionType: ActionTypeEnum) => { | ||
const data = ACTION_REGISTRY_INPUT[actionType] || {} | ||
return { | ||
...data, | ||
...getBaseInput(), | ||
endDateTimeUtc: new Date() | ||
} | ||
export function useMissionTimeline<T>(missionId?: number): TimelineHook<T> { | ||
const getActionInput = (actionType: ActionTypeEnum, moreData?: unknown): MissionNavAction => { | ||
const input = { | ||
missionId: Number(missionId), | ||
actionType, | ||
source: MissionSourceEnum.RAPPORTNAV, | ||
data: { | ||
...(moreData ?? {}), | ||
...(ACTION_REGISTRY_INPUT[actionType] ?? {}), | ||
startDateTimeUtc: new Date().toISOString() | ||
} | ||
} as MissionNavAction | ||
|
||
return input | ||
} | ||
const getBaseInput = (): Input => ({ startDateTimeUtc: new Date(), missionId: parseInt(missionId!, 10) }) | ||
|
||
return { getBaseInput, getActionDataInput } | ||
return { getActionInput } | ||
} |
6 changes: 3 additions & 3 deletions
6
frontend/src/v2/features/mission-action/components/elements/mission-action-header.tsx
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
8 changes: 4 additions & 4 deletions
8
frontend/src/v2/features/mission-action/components/layout/mission-action-wrapper.tsx
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
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
12 changes: 6 additions & 6 deletions
12
frontend/src/v2/features/pam/components/element/mission-timeline-pam.tsx
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
Oops, something went wrong.