Skip to content

Refactor mission crew#1107

Open
lwih wants to merge 1 commit intomainfrom
refactor-mission-crew
Open

Refactor mission crew#1107
lwih wants to merge 1 commit intomainfrom
refactor-mission-crew

Conversation

@lwih
Copy link
Copy Markdown
Collaborator

@lwih lwih commented Dec 17, 2025

No description provided.

@tristanrobert
Copy link
Copy Markdown

tristanrobert commented Dec 17, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@lwih lwih force-pushed the refactor-mission-crew branch from 104d112 to 859dc31 Compare January 19, 2026 17:54
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 19, 2026

Coverage Report for frontend

Status Category Percentage Covered / Total
🔵 Lines 62.33% (🎯 40%) 2827 / 4535
🔵 Statements 60.78% (🎯 40%) 3053 / 5023
🔵 Functions 51.83% (🎯 40%) 959 / 1850
🔵 Branches 58.02% (🎯 40%) 1319 / 2273
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
frontend/src/v2/features/auth/components/auth-guard.tsx 100% 100% 100% 100%
frontend/src/v2/features/common/components/ui/formik-date-range-picker.tsx 83.33% 62.5% 100% 85.71% 43-44
frontend/src/v2/features/common/hooks/use-mission-dates.tsx 100% 100% 100% 100%
frontend/src/v2/features/common/schemas/dates-schema.ts 94.11% 81.25% 100% 100% 14
frontend/src/v2/features/common/services/query-keys.ts 71.87% 100% 59.09% 71.87% 12, 24, 32, 36, 45-47, 51-52
frontend/src/v2/features/common/services/use-prefetch-static-data.tsx 0% 0% 0% 0% 8-36
frontend/src/v2/features/common/types/crew-type.ts 100% 100% 100% 100%
frontend/src/v2/features/common/types/mission-types.ts 100% 100% 100% 100%
frontend/src/v2/features/mission-action/hooks/use-mission-action-generic-control.tsx 0% 0% 0% 0% 21-76
frontend/src/v2/features/mission-action/hooks/use-mission-action-generic-date-observation.tsx 0% 0% 0% 0% 18-67
frontend/src/v2/features/mission-action/hooks/use-mission-action-illegal-immigration.tsx 0% 0% 0% 0% 19-102
frontend/src/v2/features/mission-action/hooks/use-mission-action-nav-control.tsx 0% 0% 0% 0% 20-98
frontend/src/v2/features/mission-action/hooks/use-mission-action-rescue.tsx 0% 0% 0% 0% 20-127
frontend/src/v2/features/mission-action/validation-schema/date-validation.ts 100% 80% 100% 100%
frontend/src/v2/features/mission-general-infos/components/mission-general-information-crew-no-comment.tsx 5.55% 0% 0% 7.69% 33-98
frontend/src/v2/features/mission-general-infos/ui/mission-crew-form-no-comment.tsx 20% 0% 0% 26.31% 19-23, 25-30, 33, 39-50, 69-125
frontend/src/v2/features/mission-general-infos/ui/mission-crew-list-no-comment.tsx 25% 100% 0% 25% 20-29
frontend/src/v2/features/mission-general-infos/ui/mission-crew-list.tsx 100% 87.5% 100% 100%
frontend/src/v2/features/pam/components/element/general-info/mission-general-information-form-pam.tsx 100% 100% 100% 100%
frontend/src/v2/features/pam/components/element/general-info/mission-general-information-pam-body.tsx 71.42% 50% 50% 66.66% 15, 19
frontend/src/v2/features/pam/components/element/general-info/crew/crew-absence-form.tsx 68% 72.72% 64.28% 73.33% 56, 72-90, 96, 173
frontend/src/v2/features/pam/components/element/general-info/crew/crew-full-mission-absence-form.tsx 100% 100% 100% 100%
frontend/src/v2/features/pam/components/element/general-info/crew/crew-temporary-absence-form-item.tsx 100% 100% 83.33% 100%
frontend/src/v2/features/pam/components/element/general-info/crew/mission-general-information-crew-pam-absence-modal.tsx 100% 100% 100% 100%
frontend/src/v2/features/pam/components/element/general-info/crew/mission-general-information-crew-pam.tsx 73.91% 70.83% 81.25% 75% 57-77, 190-192
frontend/src/v2/features/pam/components/element/general-info/passengers/mission-general-information-passenger-pam.tsx 54.16% 72.22% 70% 56.52% 35-55, 128-129
frontend/src/v2/features/pam/components/ui/crew-absence-tag.tsx 100% 100% 100% 100%
frontend/src/v2/features/pam/components/ui/mission-crew-list-item-pam.tsx 100% 84.31% 100% 100%
frontend/src/v2/features/pam/components/ui/mission-passenger-list-item-pam.tsx 100% 100% 100% 100%
frontend/src/v2/features/pam/hooks/use-crew-absence-reason.tsx 100% 100% 100% 100%
frontend/src/v2/features/pam/hooks/use-crew-absence.tsx 100% 100% 100% 100%
frontend/src/v2/features/pam/hooks/use-pam-mission-general-information-form.tsx 84.84% 83.33% 88.23% 87.09% 32-37, 48-49
Generated in workflow #4065 for commit 543876a by the Vitest Coverage Report Action

@MTES-MCT MTES-MCT deleted a comment from github-actions bot Jan 19, 2026
@lwih lwih force-pushed the refactor-mission-crew branch 2 times, most recently from c224e35 to 829228b Compare January 21, 2026 14:10
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Jan 21, 2026
@lwih lwih force-pushed the refactor-mission-crew branch from 829228b to c989e8b Compare January 21, 2026 14:57
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Jan 21, 2026
@lwih lwih force-pushed the refactor-mission-crew branch from c989e8b to 49aad89 Compare January 22, 2026 09:46
@lwih lwih marked this pull request as ready for review January 22, 2026 15:40
@lwih lwih force-pushed the refactor-mission-crew branch 2 times, most recently from 612670e to 4872ee4 Compare January 28, 2026 12:05
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Jan 28, 2026
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Jan 28, 2026
@lwih lwih force-pushed the refactor-mission-crew branch 4 times, most recently from c2d9097 to ea2c567 Compare February 5, 2026 15:03
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Feb 12, 2026
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Feb 12, 2026
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Feb 12, 2026
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Feb 12, 2026
@lwih lwih force-pushed the refactor-mission-crew branch from ea2c567 to 753e6ea Compare February 12, 2026 09:54
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Feb 12, 2026
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Feb 12, 2026
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Feb 12, 2026
@lwih lwih force-pushed the refactor-mission-crew branch 3 times, most recently from 01e9c3d to 1652f46 Compare February 16, 2026 18:05
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Feb 24, 2026
@lwih lwih force-pushed the refactor-mission-crew branch 4 times, most recently from 8b85a99 to 3f22f66 Compare February 25, 2026 09:10
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Feb 25, 2026
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Feb 25, 2026
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Feb 25, 2026
@lwih lwih force-pushed the refactor-mission-crew branch 3 times, most recently from 1ee9656 to 8014c5b Compare February 25, 2026 10:11
@github-actions
Copy link
Copy Markdown
Contributor

Overall Project 76.07% -0.79%
Files changed 21.18%

File Coverage
GetCrewByServiceId.kt 100% 🍏
MissionCrew.kt 76.54% -9.23%
JPAMissionCrewRepository.kt 66% 🍏
MissionCrewModel.kt 65% -9.5%
MissionCrewEntity.kt 59.04% -18.08%
ExportMissionPatrolSingle.kt 1.71% -2.23%
MissionCrewAbsenceModel.kt 0%
MissionCrewAbsenceEntity.kt 0% -94.39%
MissionCrewAbsence.kt 0% -97.27%

@lwih lwih requested a review from xtiannyeto February 25, 2026 10:26
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Feb 25, 2026
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Feb 25, 2026
Comment on lines +24 to +27
var startDate: LocalDate? = null,

@Column(name = "end_date", nullable = true)
var endDate: LocalDate? = null,
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je me demande si je suis pas un peu trop souple sur les dates

BEGIN
CREATE TABLE IF NOT EXISTS public.mission_crew_absence (
id SERIAL PRIMARY KEY,
mission_crew_id INTEGER NOT NULL REFERENCES public.mission_crew(id) ON DELETE CASCADE,
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La table Absence est liée à la table MissionCrew avec un delete cascade.
En théorie, on ne delete pas de row de MissionCrew donc le delete cascade est pas si dangereux mais est ce que pour des soucis d'archivage, il faudrait pas mieux virer le delete cascade ? T'as un avis ?

Comment on lines +5 to +11
export function useMissionDates(missionId?: string): [string | undefined, string | undefined] {
const queryClient = useQueryClient()

const mission: Mission2 | undefined = missionId ? queryClient.getQueryData(missionsKeys.byId(missionId)) : undefined

return [mission?.data?.startDateTimeUtc, mission?.data?.endDateTimeUtc]
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ici dans le frontend, après avoir déjà codé ce fichier, j'ai vu que t'as un use-mission avec quelques utils dedans. T'as un avis entre laisser ce hook ou le migrer dans use-mission ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on peut merger plus tard

Comment on lines +43 to +52
// if a temporary absence matches the whole length of the mission
// set it as full mission absence instead of just temporary
const isAbsentFullMission =
value.isAbsentFullMission ||
(missionStartDateTimeUtc &&
missionEndDateTimeUtc &&
startDate &&
endDate &&
isSameDay(new Date(startDate), new Date(missionStartDateTimeUtc)) &&
isSameDay(new Date(endDate), new Date(missionEndDateTimeUtc)))
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ça, ça pourrait être fait dans le backend aussi

fieldArray: FieldArrayRenderProps
}

const MissionGeneralInformationCrewPam: React.FC<MissionGeneralInformationCrewPamProps> = ({
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ce fichier il a pas vraiment changé mais au lieu d'un move, git m'a fait un delete/create

Comment on lines +37 to +47
// Local state for "new/unsaved" temporary absences
// Initialize with one empty absence so the user sees a form immediately
const [localAbsences, setLocalAbsences] = useState<MissionCrewAbsence[]>(absences.length === 0 ? [EMPTY_ABSENCE] : [])

// Track validity and values for each form row
const formStatesRef = React.useRef<Record<number, FormState>>({})
const [, forceUpdate] = useState(0)

// Display absences: committed ones first, then local ones
const displayAbsences = [...absences, ...localAbsences]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai bien galéré avec Formik pour gérer des form temporaraires dans d'autres components dans des Modal

Comment on lines +62 to +67
const allFormsValid =
displayAbsences.length > 0 &&
displayAbsences.every((_, index) => {
const state = formStatesRef.current[index]
return state?.isValid === true
})
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pour disable le bouton "valider" dans la modal si une des form rows est pas valide

@lwih lwih force-pushed the refactor-mission-crew branch 3 times, most recently from 82e9918 to a3aba6f Compare March 2, 2026 18:52
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Mar 3, 2026
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Mar 3, 2026
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Mar 3, 2026
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Mar 3, 2026
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Mar 3, 2026
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Mar 3, 2026
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Mar 3, 2026
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Mar 3, 2026
@lwih lwih force-pushed the refactor-mission-crew branch from 40dc21d to 543876a Compare March 9, 2026 11:48
crewModel.agent = agent
}
// if (crew.agent != null && crew.agent.id != null) {
// val agent = dbAgentRepository.findById(crew.agent.id).orElseThrow()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comments

DO
$$
BEGIN
CREATE TABLE IF NOT EXISTS public.mission_crew_absence (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming, peut etre juste crew_absence

Comment on lines +5 to +11
export function useMissionDates(missionId?: string): [string | undefined, string | undefined] {
const queryClient = useQueryClient()

const mission: Mission2 | undefined = missionId ? queryClient.getQueryData(missionsKeys.byId(missionId)) : undefined

return [mission?.data?.startDateTimeUtc, mission?.data?.endDateTimeUtc]
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on peut merger plus tard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants