Skip to content

Commit

Permalink
[Mission] Suppression du message de mise à jour de mission dans le ba…
Browse files Browse the repository at this point in the history
…ndeau du bas (#1220)

Suppression du message de mise à jour de mission en vue de la mise en
prod de fix du 23/02/24

## Related Pull Requests & Issues

- Related #1159 

----

- [ ] Tests E2E (Cypress)
  • Loading branch information
claire2212 committed Feb 22, 2024
2 parents 64e062f + ec13f77 commit 2a974d8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ context('Side Window > Mission Form > Main Form', () => {

cy.get('*[data-cy="add-mission"]').click()

cy.get('div').contains('Mission non enregistrée.')
// cy.get('div').contains('Mission non enregistrée.')
cy.get('.Element-Tag').contains('Enregistrement auto. actif')
// When
cy.fill('Début de mission (UTC)', [2024, 5, 26, 12, 0])
Expand Down Expand Up @@ -73,8 +73,8 @@ context('Side Window > Mission Form > Main Form', () => {
)
.its('response.statusCode')
.should('eq', 200)
cy.get('div').contains('Mission créée par le')
cy.get('div').contains('Dernière modification enregistrée')
// cy.get('div').contains('Mission créée par le')
// cy.get('div').contains('Dernière modification enregistrée')
})

it('A mission should be created When auto-save is not enabled', () => {
Expand Down
10 changes: 0 additions & 10 deletions frontend/src/domain/use_cases/missions/saveMission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const saveMission =
reporting: { reportings },
sideWindow: { currentPath }
} = getState()
const selectedMissions = getState().missionForms.missions
const valuesToSave = omit(values, ['attachedReportings', 'detachedReportings'])
const routeParams = getMissionPageRoute(currentPath)
const missionIsNewMission = isNewMission(routeParams?.params?.id)
Expand Down Expand Up @@ -50,15 +49,6 @@ export const saveMission =
)
await dispatch(missionActions.setSelectedMissionIdOnMap(missionUpdated.id))
dispatch(sideWindowActions.setCurrentPath(nextPath))
} else {
// for a mission already created we want to update the `updatedAt` value with the new one
const mission = selectedMissions[values.id]
dispatch(
missionFormsActions.setMission({
...mission,
missionForm: response.data
})
)
}

if (reopen || !quitAfterSave) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Icon, Button, Accent, customDayjs } from '@mtes-mct/monitor-ui'
import { Icon, Button, Accent } from '@mtes-mct/monitor-ui'
import { isNewMission } from '@utils/isNewMission'
import { useFormikContext } from 'formik'
import { useMemo, type MouseEventHandler } from 'react'
import { type MouseEventHandler } from 'react'
import styled from 'styled-components'

import { AutoSaveTag } from './AutoSaveTag'
import { missionSourceEnum, type Mission } from '../../../domain/entities/missions'
import { type Mission } from '../../../domain/entities/missions'

type MissionFormBottomBarProps = {
allowClose: boolean
Expand Down Expand Up @@ -34,24 +34,6 @@ export function MissionFormBottomBar({
const { values } = useFormikContext<Mission>()
const missionIsNewMission = isNewMission(values?.id)

const formattedUpdatedDate = useMemo(() => {
const updatedDate = customDayjs(values.updatedAtUtc)
const updatedHour = customDayjs(updatedDate).utc().format('HH')
const updatedMinutes = customDayjs(updatedDate).utc().format('mm')
const updatedTime = `${updatedHour}h${updatedMinutes}`

if (customDayjs(updatedDate).isSame(customDayjs(), 'day')) {
return `aujourdhui à ${updatedTime} (UTC)`
}

const yesterday = customDayjs().subtract(1, 'day')
if (customDayjs(updatedDate).isSame(yesterday, 'day')) {
return `hier à ${updatedTime} (UTC)`
}

return `le ${customDayjs(updatedDate).utc().format('DD/MM/YYYY ')} à ${updatedTime} (UTC)`
}, [values.updatedAtUtc])

return (
<Footer>
{allowDelete && (
Expand All @@ -67,17 +49,6 @@ export function MissionFormBottomBar({
</StyledButton>
)}
<Separator />
<MissionInfos>
{!values?.createdAtUtc && <>Mission non enregistrée.</>}
{values?.createdAtUtc && (
<>
Mission créée par le {missionSourceEnum[values?.missionSource]?.label} le{' '}
{customDayjs(values.createdAtUtc).utc().format('DD/MM/YYYY à HH:mm')} (UTC).
</>
)}

{values?.updatedAtUtc && <> Dernière modification enregistrée {formattedUpdatedDate}.</>}
</MissionInfos>

<Separator />

Expand Down Expand Up @@ -128,11 +99,6 @@ const Separator = styled.div`
flex: 1;
`

const MissionInfos = styled.div`
color: ${p => p.theme.color.slateGray};
font-style: italic;
`

const Footer = styled.div`
align-items: center;
border-top: 1px solid ${p => p.theme.color.lightGray};
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/features/missions/MissionForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ export function MissionFormWrapper() {

return {}

// we want to have the `updatedAtUtc` in the dependency array to update the `formattedUpdatedDate` in `MissionFormBottomBar.tsx`
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [activeMissionId, selectedMission?.missionForm.updatedAtUtc])
}, [activeMissionId])

if (!missionValues || missionValues?.id !== activeMissionId || !activeMissionId) {
return <div>Chargement en cours</div>
Expand Down

0 comments on commit 2a974d8

Please sign in to comment.