Skip to content

Commit

Permalink
Replace LogbookMessagePNOPurposeType constant with PriorNotification …
Browse files Browse the repository at this point in the history
…one in Frontend
  • Loading branch information
ivangabriele committed Mar 26, 2024
1 parent d98a91d commit 0066a3f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { PriorNotification } from '@features/PriorNotification/PriorNotification.types'
import { useMemo } from 'react'

import { SpecyCatch } from './common/SpecyCatch'
import { CatchDetails } from './FARMessage/CatchDetails'
import { getCodeWithNameOrDash, getDatetimeOrDash } from './utils'
import { LogbookMessagePNOPurposeType } from '../../../../constants'
import { buildCatchArray, getTotalPNOWeight } from '../../../../utils'
import { WeightType } from '../constants'
import { NoValue, Table, TableBody, TableKey, TableRow, TableValue, Zone, SpeciesList } from '../styles'

import type { PNOMessageValue } from '../../../../Logbook.types'

type PNOMessageProps = {
type PNOMessageProps = Readonly<{
message: PNOMessageValue
}
}>
export function PNOMessage({ message }: PNOMessageProps) {
const catchesWithProperties = useMemo(() => {
if (!message?.catchOnboard) {
Expand Down Expand Up @@ -54,7 +54,7 @@ export function PNOMessage({ message }: PNOMessageProps) {
<TableValue>
{message.purpose ? (
<>
{LogbookMessagePNOPurposeType[message.purpose]} ({message.purpose})
{PriorNotification.PURPOSE_LABEL[message.purpose]} ({message.purpose})
</>
) : (
<NoValue>-</NoValue>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { PriorNotification } from '@features/PriorNotification/PriorNotification.types'
import styled from 'styled-components'

import { getCodeWithNameOrDash, getDatetimeOrDash } from './utils'
import { COLORS } from '../../../../../../constants/constants'
import { LogbookMessagePNOPurposeType } from '../../../../constants'
import { NoValue, Table, TableBody, TableKey, TableRow, TableValue, Zone } from '../styles'

import type { RTPMessageValue } from '../../../../Logbook.types'

type RTPMessageProps = {
type RTPMessageProps = Readonly<{
message: RTPMessageValue
}
}>
export function RTPMessage({ message }: RTPMessageProps) {
return (
<>
Expand All @@ -31,7 +31,7 @@ export function RTPMessage({ message }: RTPMessageProps) {
<TableValue>
{message.reasonOfReturn ? (
<>
{LogbookMessagePNOPurposeType[message.reasonOfReturn]} ({message.reasonOfReturn})
{PriorNotification.PURPOSE_LABEL[message.reasonOfReturn]} ({message.reasonOfReturn})
</>
) : (
<NoValue>-</NoValue>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { PriorNotification } from '@features/PriorNotification/PriorNotification.types'
import { useEffect, useRef, useState } from 'react'
import styled from 'styled-components'

import { SpeciesAndWeightChart } from './common/SpeciesAndWeightChart'
import { getDateTime } from '../../../../../../utils'
import { LogbookMessagePNOPurposeType, LogbookMessageType as LogbookMessageTypeEnum } from '../../../../constants'
import { LogbookMessageType as LogbookMessageTypeEnum } from '../../../../constants'
import { getCodeWithNameOrDash, getDatetimeOrDash } from '../../LogbookMessages/messages/utils'
import { LogbookMessageResumeHeader } from '../LogbookMessageResumeHeader'

import type { SpeciesInsight, SpeciesToSpeciesInsight } from '../../../../types'

type PNOMessageResumeProps = {
type PNOMessageResumeProps = Readonly<{
hasNoMessage?: boolean
id: string
isDeleted: boolean
Expand All @@ -33,7 +34,7 @@ type PNOMessageResumeProps = {
speciesToWeightOfPNO: SpeciesToSpeciesInsight | undefined
totalFARAndDEPWeight: number
totalPNOWeight: number
}
}>
export function PNOMessageResume({
hasNoMessage = false,
id,
Expand Down Expand Up @@ -160,7 +161,7 @@ export function PNOMessageResume({
<Value>
{pnoMessage.message.purpose ? (
<>
{LogbookMessagePNOPurposeType[pnoMessage.message.purpose]} ({pnoMessage.message.purpose})
{PriorNotification.PURPOSE_LABEL[pnoMessage.message.purpose]} ({pnoMessage.message.purpose})
</>
) : (
<NoValue>-</NoValue>
Expand All @@ -179,11 +180,11 @@ export function PNOMessageResume({
setChartHeight={setChartHeight}
speciesAndWeightArray={speciesAndWeightArray}
/>
{speciesNotLandedArray && speciesNotLandedArray.length ? (
{!!speciesNotLandedArray && speciesNotLandedArray.length > 0 ? (
<SpeciesNotLanded>
Poids des captures non débarquées ({getPercentOfTotalWeight(totalWeightNotLanded, totalFARAndDEPWeight)}
%)
{speciesNotLandedArray && speciesNotLandedArray.length ? (
{!!speciesNotLandedArray && speciesNotLandedArray.length > 0 ? (
speciesNotLandedArray.map(speciesCatch => (
<IndividualSpeciesNotLanded key={speciesCatch.species}>
{getCodeWithNameOrDash(speciesCatch.species, speciesCatch.speciesName)}- {speciesCatch.weight} kg
Expand Down
6 changes: 0 additions & 6 deletions frontend/src/features/Logbook/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,6 @@ export const LogbookMessageSender = {
MAS: 'Capitaine'
}

// TODO Replace with `PriorNotification.PurposeCode`.
export const LogbookMessagePNOPurposeType = {
LAN: 'Débarquement',
SHE: "Mise à l'abri"
}

export const LogbookSpeciesPreservationState = {
ALI: 'Vivant',
BOI: 'Ébouillanté',
Expand Down

0 comments on commit 0066a3f

Please sign in to comment.