Newer
Older
import CustomComponent from "./customComponent"
import Map from "../core/Map"
import News from "../News"
import Stats from "../Stats"
import Hero from "../Hero"
import Image from "../core/Image"
import Data from "../Data"
import Maps from "../Maps"
import Events from "../Events"
import Iframe from "../core/Iframe"
import Text from "../Text"
actions_id: {
name: string
url: string
style: string
}
}
services_id: {
name: string
url: string
description: string
image: {
type: string
actions: IAction[] | []
mapdid: string
title: string
subtitle: string
content: string
url_dataviz: string
url_map: string
layout: string
length: number
size: string
services: IService[] | []
images: Iimage[] | []
}
const getActions = (actionsProps: IAction[] | []) => {
if (!actionsProps.length) return undefined
return actionsProps.map((action_id) => {
let action = action_id.actions_id
return {
...action,
}
})
}
const getServices = (servicesProps: IService[] | []) => {
if (!servicesProps.length) return undefined
return servicesProps.map((services_id) => {
let service = services_id.services_id
return {
...service,
}
})
}
const getImages = (imagesProps: Iimage[] | []) => {
if (!imagesProps.length) return undefined
return imagesProps.map((images) => {
return { src: images.directus_files_id.imageFile }
})
}
const Component = (props: IComponent) => {
const {
type,
actions: actionsProps = [],
services: servicesProps = [],
images: imagesProps = [],
mapdid,
...restProps
} = props
const actions = getActions(actionsProps)
const services = getServices(servicesProps)
const images = getImages(imagesProps)
switch (type) {
case "news":
let newsaction = actions?.length ? actions[0] : undefined
case "map":
if (!mapdid) return <div>Map</div>
return (
<div className="h-full min-h-[500px] w-full">
<Map {...restProps} mapid={parseInt(mapdid)} />
</div>
)
case "data":
case "stats":
return <Stats {...restProps} />
case "hero":
let heroaction = actions?.length
? actions[0]
services={services!}
{...restProps}
action={heroaction!}
options={{
size: "base",
layout: "card",
...restProps.options,
}}
/>
)
case "herotile":
return (
<Hero
services={services!}
{...restProps}
bgImage={images}
options={{
size: "base",
layout: "tile",
...restProps.options,
}}
let textAction = actions?.length ? actions[0] : undefined
let img = images?.length ? images[0].src : undefined
var oClass = restProps.options ? restProps.options.class : ""
case "mapgl":
return <div>Carte Maplibre</div>
case "geoportal":
return <Partners />
return <CustomComponent {...props} />