Commit 6958346e authored by Damien Armillon's avatar Damien Armillon
Browse files

Add footer

parent 8b99653e
......@@ -5,7 +5,6 @@ const env = require("../.env");
const oauth = env.oauth;
const redirectUri = `${env.backURL}/oauth/callback`;
console.log(redirectUri);
const getURI = (redirectUri,state) => {
return `${oauth.authorizationURI}/?redirect_uri=${redirectUri}&client_id=${oauth.clientId}&response_type=code&state=${state}&scope=default`;
......
import React from 'react';
import { BrowserRouter as Router, Route} from 'react-router-dom';
import './App.css';
import AdminPage from './view/AdminPage/AdminPage';
import AllToucanPage from './view/AllToucanPage/AllToucanPage';
import PageHeader from './view/PageHeader'
import {PageFooter, PageHeader, AllToucanPage} from './view/index'
import Login from './view/Login';
import env from './.env';
import isLogged from './utils/Oauth';
import env from './.env'
function App() {
const logged = isLogged();
return (
<Router >
<PageHeader isLogged={logged} />
<Route exact path='/admin' render={()=>logged ? <AdminPage/> : window.location=`${env.backURL}/oauth/login`}/>
<Route exact path='/login/:token' component={Login} />
<AllToucanPage isAdmin={logged}/>
<Route exact path='/' render={()=><AllToucanPage isAdmin={logged} backURL={env.backURL}/>}/>
<PageFooter/>
</Router>
);
}
......
import React, {Component} from 'react'
import {Form, Message} from 'semantic-ui-react'
import env from '../../.env'
class FormToucan extends Component {
constructor(props) {
......@@ -60,7 +59,7 @@ class FormToucan extends Component {
form.append("title",title)
form.append("toucan",toucan)
form.append("cover",cover)
fetch(`${env.backURL}/toucan/toucans`,{
fetch(`${this.props.backURL}/toucan/toucans`,{
method: 'POST',
headers:{token: localStorage.getItem("token")},
body: form
......
import React, {Component} from 'react';
import {Segment} from 'semantic-ui-react';
//import ToucanTable from './showToucan/ToucanTable';
import FormToucan from './FormToucan';
//import LogoutButton from '../LogoutButton';
class MainPage extends Component {
render(){
return (
<Segment style={{margin:"3em",padding:"2em"}}>
<h2 style={{textAlign:"center"}}>Rajout de Toucan</h2>
<FormToucan />
</Segment>
);
}
}
export default MainPage;
import React, {useState, useEffect} from 'react'
import {Card, Segment} from 'semantic-ui-react'
import SelectYear from '../../utils/yearSelector'
import FormToucan from '../../utils//FormToucan.js'
import ToucanCard from './ToucanCard'
import env from '../../.env'
const date = new Date()
const beginYear = 1900 + (date.getMonth() < 8 ? date.getYear()-1 : date.getYear());
......@@ -13,7 +13,7 @@ function AllToucan(props){
const [after, setAfter] = useState((new Date(beginYear,8,1)).getTime());
useEffect(()=>{
fetch(`${env.backURL}/toucan/toucans?before=${before}&after=${after}`)
fetch(`${props.backURL}/toucan/toucans?before=${before}&after=${after}`)
.then(result => {
return result.json()
})
......@@ -21,7 +21,7 @@ function AllToucan(props){
setToucans(toucans)
})
.catch(err => console.log(err))
},[before,after]
},[before,after,props.backURL]
)
function updateFrame(value){
......@@ -30,29 +30,36 @@ function AllToucan(props){
setBefore(before)
setAfter(after)
}
const formNewToucan = props.isAdmin ?
<Segment style={{margin:"3em",padding:"2em"}}>
<h2 style={{textAlign:"center"}}>Rajout de Toucan</h2>
<FormToucan backURL={props.backURL}/>
</Segment> :
null
return (
<Segment style={{textAlign:"center", margin:"3em",padding:"2em"}} >
<SelectYear
style={{marginBottom:"2em"}}
beginYear={beginYear}
updateFrame = {updateFrame}
/>
<Card.Group centered >
{toucans.map( toucan => {
return <ToucanCard
image={`${env.backURL}/toucan/img/${toucan["_id"]}`}
link={`${env.backURL}/toucan/pdf/${toucan["_id"]}.pdf`}
header={toucan.title}
toucanId={toucan._id}
isAdmin={props.isAdmin}
date={(new Date(toucan.date).toLocaleDateString())}
key={toucan._id}
/>
})}
</Card.Group>
</Segment>
<div>
{formNewToucan}
<Segment style={{textAlign:"center", margin:"3em",padding:"2em"}} >
<SelectYear
style={{marginBottom:"2em"}}
beginYear={beginYear}
updateFrame = {updateFrame}
/>
<Card.Group centered >
{toucans.map( toucan => {
return <ToucanCard
image={`${props.backURL}/toucan/img/${toucan["_id"]}`}
link={`${props.backURL}/toucan/pdf/${toucan["_id"]}.pdf`}
header={toucan.title}
toucanId={toucan._id}
isAdmin={props.isAdmin}
date={(new Date(toucan.date).toLocaleDateString())}
key={toucan._id}
/>
})}
</Card.Group>
</Segment>
</div>
)}
......
......@@ -5,7 +5,7 @@ class Login extends Component {
componentDidMount(){
localStorage.setItem("token",this.props.match.params.token);
console.log(localStorage.getItem("token"));
window.location = '/admin';
window.location = '/';
}
......
import React from 'react'
function PageFooter(props){
return(
<div>
<p style={{textAlign:"right", color:"grey"}}>Site fait par Damien Armillon (alias Edsheebran) pour le Toucan Déchainé</p>
</div>
)
}
export default PageFooter
\ No newline at end of file
......@@ -3,6 +3,7 @@ import {Image, Button} from 'semantic-ui-react'
import LogoutButton from '../utils/LogoutButton'
import {Link} from 'react-router-dom'
import logo from '../image/logo.png'
import env from './../.env'
......@@ -13,9 +14,7 @@ const PageHeader = (props) => {
<div class="desktopItem" style={{textAlign:"center"}}> {console.log(props.isLogged)}
<Image src={logo} alt="Logo" href="/" style={{ width:'40%'}} />
{props.isLogged ? <LogoutButton style={{position:"absolute",top:'2em' ,right:"2em"}}/>:
<Link to="/admin" style={{position:"absolute",top:'2em' ,right:"2em"}} >
<Button icon="male" content="Espace admin"/>
</Link>
<Button icon="male" content="Espace admin" style={{position:"absolute",top:'2em' ,right:"2em"}} onClick={() =>window.location=`${env.backURL}/oauth/login`}/>
}
</div>,
......
export {default as PageFooter} from './PageFooter'
export {default as PageHeader} from './PageHeader'
export {default as AllToucanPage} from './AllToucanPage/AllToucanPage'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment