Skip to content

Commit

Permalink
feat(entities): add Administration, ControlUnit, DepartmentArea & Sta…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
ivangabriele committed Nov 22, 2023
1 parent 5f43efc commit 9f04ac9
Show file tree
Hide file tree
Showing 6 changed files with 232 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/entities/Administration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { ControlUnit } from './ControlUnit'

export namespace Administration {
export interface Administration {
controlUnitIds: number[]
controlUnits: ControlUnit.ControlUnitData[]
id: number
isArchived: boolean
name: string
}

// ---------------------------------------------------------------------------
// Types

export type AdministrationData = Omit<Administration, 'controlUnitIds' | 'controlUnits'>
export type NewAdministrationData = Omit<AdministrationData, 'id'>
}
169 changes: 169 additions & 0 deletions src/entities/ControlUnit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
import { Mission } from './Mission'

import type { Administration } from './Administration'
import type { DepartmentArea } from './DepartmentArea'
import type { Station } from './Station'

export namespace ControlUnit {
export interface ControlUnit {
administration: Administration.AdministrationData
administrationId: number
/** Area of intervention for this unit. */
areaNote: string | undefined
controlUnitContactIds: number[]
controlUnitContacts: ControlUnitContactData[]
controlUnitResourceIds: number[]
// `ControlUnitResource` and not `ControlUnitResourceData` because we need `base` data for each resource
controlUnitResources: ControlUnitResource[]
departmentArea: DepartmentArea.DepartmentArea | undefined
/** `departmentAreaInseeCode` is the `departmentArea` ID. */
departmentAreaInseeCode: string | undefined
id: number
isArchived: boolean
name: string
/** Conditions under which this unit should be contacted. */
termsNote: string | undefined
}

export interface ControlUnitContact {
controlUnit: ControlUnitData
controlUnitId: number
email: string | undefined
id: number
name: string
phone: string | undefined
}

export interface ControlUnitResource {
controlUnit: ControlUnitData
controlUnitId: number
id: number
isArchived: boolean
name: string
note: string | undefined
/** Base64 Data URI. */
photo: string | undefined
station: Station.StationData
stationId: number
type: ControlUnitResourceType
}

// ---------------------------------------------------------------------------
// Constants

export enum ControlUnitContactPredefinedName {
ADJUNCT = 'Adjoint',
BRIDGE = 'Passerelle',
COMMANDER = 'Commandant',
COMMANDER_A = 'Commandant bordée A',
COMMANDER_B = 'Commandant bordée B',
CREW_A = 'Équipage A',
CREW_B = 'Équipage B',
DML = 'DML',
DOCK = 'Quai',
LAND = 'Terre',
LAND_ON_CALL = 'Permanence terre',
NEAR_COAST = 'Proche côte',
OFFICE = 'Bureau de l’unité',
ONBOARD_PHONE = 'Téléphone de bord',
ON_CALL = 'Permanence',
OPERATIONAL_CENTER = 'Centre opérationnel',
OPERATIONAL_CENTER_HNO = 'Centre opérationnel - HNO', // Heures Non-Ouvrées
OPERATIONAL_CENTER_HO = 'Centre opérationnel - HO', // Heures Ouvrées
PERMANENT_CONTACT_ONBOARD = 'Contact permanent à bord',
SEA = 'Mer',
SECRETARIAT = 'Secrétariat',
SERVICE_CHIEF = 'Chef de service',
UNIT_CHIEF = 'Chef d’unité',
UNKNOWN = 'Nom de contact à renseigner'
}

// Don't forget to mirror any update here in both Postgre & Backend enums.
export enum ControlUnitResourceType {
AIRPLANE = 'AIRPLANE',
BARGE = 'BARGE',
CAR = 'CAR',
DRONE = 'DRONE',
EQUESTRIAN = 'EQUESTRIAN',
FAST_BOAT = 'FAST_BOAT',
FRIGATE = 'FRIGATE',
HELICOPTER = 'HELICOPTER',
HYDROGRAPHIC_SHIP = 'HYDROGRAPHIC_SHIP',
KAYAK = 'KAYAK',
LIGHT_FAST_BOAT = 'LIGHT_FAST_BOAT',
MINE_DIVER = 'MINE_DIVER',
MOTORCYCLE = 'MOTORCYCLE',
NET_LIFTER = 'NET_LIFTER',
NO_RESOURCE = 'NO_RESOURCE',
OTHER = 'OTHER',
PATROL_BOAT = 'PATROL_BOAT',
PEDESTRIAN = 'PEDESTRIAN',
PIROGUE = 'PIROGUE',
RIGID_HULL = 'RIGID_HULL',
SEA_SCOOTER = 'SEA_SCOOTER',
SEMI_RIGID = 'SEMI_RIGID',
SUPPORT_SHIP = 'SUPPORT_SHIP',
TRAINING_SHIP = 'TRAINING_SHIP',
TUGBOAT = 'TUGBOAT'
}
export enum ControlUnitResourceTypeLabel {
AIRPLANE = 'Avion',
BARGE = 'Barge',
CAR = 'Voiture',
DRONE = 'Drône',
EQUESTRIAN = 'Équestre',
FAST_BOAT = 'Vedette',
FRIGATE = 'Frégate',
HELICOPTER = 'Hélicoptère',
HYDROGRAPHIC_SHIP = 'Bâtiment hydrographique',
KAYAK = 'Kayak',
LIGHT_FAST_BOAT = 'Vedette légère',
MINE_DIVER = 'Plongeur démineur',
MOTORCYCLE = 'Moto',
NET_LIFTER = 'Remonte-filets',
NO_RESOURCE = 'Aucun moyen',
OTHER = 'Autre',
PATROL_BOAT = 'Patrouilleur',
PEDESTRIAN = 'Piéton',
PIROGUE = 'Pirogue',
RIGID_HULL = 'Coque rigide',
SEA_SCOOTER = 'Scooter de mer',
SEMI_RIGID = 'Semi-rigide',
SUPPORT_SHIP = 'Bâtiment de soutien',
TRAINING_SHIP = 'Bâtiment-école',
TUGBOAT = 'Remorqueur'
}

// List of PAM units identifiers
// 10141 PAM Gyptis
// 10404 PAM Iris
// 10121 PAM Jeanne Barret
// 10345 PAM Osiris
// 10080 PAM Themis
export const PAMControlUnitIds = [10141, 10404, 10121, 10345, 10080]

// ---------------------------------------------------------------------------
// Types

export type ControlUnitData = Omit<
ControlUnit,
| 'administration'
| 'controlUnitContactIds'
| 'controlUnitContacts'
| 'controlUnitResourceIds'
| 'controlUnitResources'
| 'departmentArea'
>
export type NewControlUnitData = Omit<ControlUnitData, 'id'>

export type ControlUnitContactData = Omit<ControlUnitContact, 'controlUnit'>
export type NewControlUnitContactData = Omit<ControlUnitContactData, 'id'>

export type ControlUnitResourceData = Omit<ControlUnitResource, 'controlUnit' | 'station'>
export type NewControlUnitResourceData = Omit<ControlUnitResourceData, 'id'>

export type EngagedControlUnits = {
controlUnit: ControlUnit
missionSources: Mission.MissionSourceEnum[]
}[]
}
7 changes: 7 additions & 0 deletions src/entities/DepartmentArea.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export namespace DepartmentArea {
export interface DepartmentArea {
/** `inseeCode` is the ID. */
inseeCode: string
name: string
}
}
8 changes: 8 additions & 0 deletions src/entities/Mission.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export namespace Mission {
export enum MissionSourceEnum {
MONITORENV = 'MONITORENV',
MONITORFISH = 'MONITORFISH',
POSEIDON_CACEM = 'POSEIDON_CACEM',
POSEIDON_CNSP = 'POSEIDON_CNSP'
}
}
18 changes: 18 additions & 0 deletions src/entities/Station.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { ControlUnit } from './ControlUnit'

export namespace Station {
export interface Station {
controlUnitResourceIds: number[]
controlUnitResources: ControlUnit.ControlUnitResourceData[]
id: number
latitude: number
longitude: number
name: string
}

// ---------------------------------------------------------------------------
// Types

export type StationData = Omit<Station, 'controlUnitResourceIds' | 'controlUnitResources'>
export type NewStationData = Omit<StationData, 'id'>
}
13 changes: 13 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ export * as Icon from './icons'

export { ExclamationPoint } from './symbols/ExclamationPoint'

/* -----------------------------------------------------------------------------
Entities
IMPORTANT: Use `export type` instead of `export` for entities that are ONLY made of types.
Otherwise, use `export` or constants won't be importable by the final applications.
*/

export type { Administration } from './entities/Administration'
export { ControlUnit } from './entities/ControlUnit'
export type { DepartmentArea } from './entities/DepartmentArea'
export { Mission } from './entities/Mission'
export type { Station } from './entities/Station'

/* -----------------------------------------------------------------------------
Hooks
*/
Expand Down

0 comments on commit 9f04ac9

Please sign in to comment.