2020-03-24 09:54:50 +01:00
|
|
|
import FunctionTabsContextProvider from '../../contexts/FunctionTabsContext';
|
2020-03-21 23:54:08 +01:00
|
|
|
import HeadTag from '../../components/HeadTag';
|
2020-03-24 09:54:50 +01:00
|
|
|
import FunctionComponentTop from '../../components/FunctionComponentTop';
|
|
|
|
import FunctionTabsTop from '../../components/FunctionTabs/FunctionTabsTop';
|
2020-03-23 21:22:41 +01:00
|
|
|
import FunctionTabs from '../../components/FunctionTabs/FunctionTabs';
|
2020-03-24 16:11:55 +01:00
|
|
|
import FunctionForm from '../../components/FunctionForm/FunctionForm';
|
2020-03-23 21:22:41 +01:00
|
|
|
import redirect from '../../utils/redirect';
|
2020-03-24 09:54:50 +01:00
|
|
|
import api from '../../utils/api';
|
|
|
|
import { API_URL } from '../../utils/config';
|
2020-03-23 21:22:41 +01:00
|
|
|
import '../../public/css/pages/FunctionComponent.css';
|
2020-03-21 23:54:08 +01:00
|
|
|
|
2020-03-23 21:22:41 +01:00
|
|
|
const FunctionComponent = (props) => {
|
|
|
|
|
|
|
|
// Constantes
|
|
|
|
const createdAt = new Date(props.createdAt);
|
|
|
|
const publicationDate = `${('0'+createdAt.getDate()).slice(-2)}/${('0'+(createdAt.getMonth()+1)).slice(-2)}/${createdAt.getFullYear()}`;
|
2020-03-21 23:54:08 +01:00
|
|
|
|
|
|
|
return (
|
2020-03-24 09:54:50 +01:00
|
|
|
<FunctionTabsContextProvider>
|
2020-03-23 21:22:41 +01:00
|
|
|
<HeadTag title={props.title} description={props.description} image={API_URL + props.image} />
|
|
|
|
|
|
|
|
<div className="container-fluid">
|
|
|
|
|
2020-03-24 09:54:50 +01:00
|
|
|
<FunctionTabsTop type={props.type} />
|
|
|
|
<FunctionComponentTop { ...props } API_URL={API_URL} publicationDate={publicationDate} />
|
|
|
|
|
|
|
|
<FunctionTabs type={props.type}>
|
2020-03-24 16:11:55 +01:00
|
|
|
{(props.type !== "article") ?
|
|
|
|
<FunctionForm inputArray={ [...props.utilizationForm || []] } slug={props.slug} />
|
|
|
|
:
|
|
|
|
<div className="FunctionComponent__slide text-center">Slide 1</div>
|
|
|
|
}
|
2020-03-24 09:54:50 +01:00
|
|
|
<div className="FunctionComponent__slide text-center">Slide 2</div>
|
|
|
|
<div className="FunctionComponent__slide text-center">Slide 3</div>
|
|
|
|
</FunctionTabs>
|
2020-03-23 21:22:41 +01:00
|
|
|
|
2020-03-21 23:54:08 +01:00
|
|
|
</div>
|
2020-03-24 09:54:50 +01:00
|
|
|
</FunctionTabsContextProvider>
|
2020-03-21 23:54:08 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-03-23 21:22:41 +01:00
|
|
|
export async function getServerSideProps(context) {
|
|
|
|
const { slug } = context.params;
|
|
|
|
return api.get(`/functions/${slug}`)
|
|
|
|
.then((response) => ({ props: response.data }))
|
|
|
|
.catch(() => redirect(context, '/404'));
|
|
|
|
}
|
|
|
|
|
2020-03-21 23:54:08 +01:00
|
|
|
export default FunctionComponent;
|