Skip to content

Commit

Permalink
Fix minor issues following rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
ivangabriele committed Oct 12, 2023
1 parent 8402b29 commit c394500
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package fr.gouv.cacem.monitorenv.infrastructure.database.model

import com.fasterxml.jackson.annotation.JsonBackReference
import com.vladmihalcea.hibernate.type.basic.PostgreSQLEnumType
import fr.gouv.cacem.monitorenv.domain.entities.controlUnit.ControlUnitResourceEntity
import fr.gouv.cacem.monitorenv.domain.entities.controlUnit.ControlUnitResourceType
import fr.gouv.cacem.monitorenv.domain.use_cases.controlUnit.dtos.FullControlUnitResourceDTO
import jakarta.persistence.*
import org.hibernate.annotations.ColumnTransformer
import org.hibernate.annotations.CreationTimestamp
import org.hibernate.annotations.Type
import org.hibernate.annotations.UpdateTimestamp
import java.time.Instant

Expand Down Expand Up @@ -37,9 +38,9 @@ data class ControlUnitResourceModel(
@Column(name = "photo")
var photo: ByteArray? = byteArrayOf(),

@Column(name = "type", nullable = false, columnDefinition = "control_unit_resource_type")
@Enumerated(EnumType.STRING)
@Column(name = "type", nullable = false)
@ColumnTransformer(write = "?::control_unit_resource_type")
@Type(PostgreSQLEnumType::class)
var type: ControlUnitResourceType,

@Column(name = "created_at_utc", nullable = false, updatable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function Item({ controlUnitResource, onEdit }: ItemProps) {
<InfoBoxHeader>
<div>
<Name>
{ControlUnit.ControlUnitResourceType[controlUnitResource.type]}{controlUnitResource.name}
{ControlUnit.ControlUnitResourceTypeLabel[controlUnitResource.type]}{controlUnitResource.name}
</Name>
<p>{controlUnitResource.base.name}</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ export const CONTROL_UNIT_RESOURCE_FORM_SCHEMA = object().shape({
})

export const CONTROL_UNIT_RESOURCE_TYPES_AS_OPTIONS = getOptionsFromLabelledEnum(
ControlUnit.ControlUnitResourceType,
ControlUnit.ControlUnitResourceTypeLabel,
true
).filter(
controlUnitResourceTypeAsOption =>
controlUnitResourceTypeAsOption.label !== ControlUnit.ControlUnitResourceType.UNKNOWN
)

export const INITIAL_CONTROL_UNIT_RESOURCE_FORM_VALUES: ControlUnitResourceFormValues = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function ControlUnitResourceList({ controlUnit }: ControlUnitResourceList
...controlUnitResourceFormValues,
// We set the resource type as the resource name if no name has been provided by the user
name: isEmptyish(controlUnitResourceFormValues.name)
? ControlUnit.ControlUnitResourceType[controlUnitResourceFormValues.type as string]
? ControlUnit.ControlUnitResourceTypeLabel[controlUnitResourceFormValues.type as string]
: controlUnitResourceFormValues.name
}

Expand Down

0 comments on commit c394500

Please sign in to comment.