Skip to content

Commit

Permalink
Codice del frontend reindentato e rimossi un po' di warning del langu…
Browse files Browse the repository at this point in the history
…age server
  • Loading branch information
pdonadeo committed Dec 28, 2024
1 parent 15ebab4 commit a7ca411
Show file tree
Hide file tree
Showing 21 changed files with 343 additions and 276 deletions.
1 change: 0 additions & 1 deletion frontend/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import EpisodeSection from "./components/EpisodeSection";
import Header from "./components/Header";
import Footer from "./components/Footer";
Expand Down
24 changes: 12 additions & 12 deletions frontend/src/CustomHooks/ListTransition.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { motion } from "framer-motion";

const ListTransition = (props) => {
return (
<motion.div
{...props}
layout
animate={{ opacity: 1, scale: 1 }}
initial={{ opacity: 0 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.6 }}
>
{props.children}
</motion.div>
);
return (
<motion.div
{...props}
layout
animate={{ opacity: 1, scale: 1 }}
initial={{ opacity: 0 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.6 }}
>
{props.children}
</motion.div>
);
};

export default ListTransition;
37 changes: 19 additions & 18 deletions frontend/src/JoycordChannels.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';

import Channel from './components/Joycord/Channel';
import Category from './components/Joycord/Category';
import Thread from './components/Joycord/Thread';
import React from "react";

import Channel from "./components/Joycord/Channel";
import Category from "./components/Joycord/Category";
import Thread from "./components/Joycord/Thread";

function JoycordChannels() {
const [channels, setChannels] = React.useState([]);
Expand All @@ -13,13 +12,13 @@ function JoycordChannels() {
});

React.useEffect(() => {
fetch('/api/joycord/channels')
.then(response => response.json())
.then(data => {
fetch("/api/joycord/channels")
.then((response) => response.json())
.then((data) => {
// Do something with the downloaded JSON data
setChannels(data);
})
.catch(error => {
.catch(() => {
// Handle any errors that occur during the fetch
});
}, [setChannels]);
Expand All @@ -29,15 +28,17 @@ function JoycordChannels() {
<h1>Lista dei canali e delle discussioni aperte di Joycord</h1>
<ul>
{channels.map((channel) => (
<li key={channel.id}>{
channel.nodeType === "channelType" ? <Channel jsonObj={channel} /> : (
channel.nodeType === "categoryType" ? <Category jsonObj={channel} /> : (
channel.nodeType === "threadType" ? <Thread jsonObj={channel} /> : (
<div>{channel.id}</div>
)
)
)
}</li>
<li key={channel.id}>
{channel.nodeType === "channelType" ? (
<Channel jsonObj={channel} />
) : channel.nodeType === "categoryType" ? (
<Category jsonObj={channel} />
) : channel.nodeType === "threadType" ? (
<Thread jsonObj={channel} />
) : (
<div>{channel.id}</div>
)}
</li>
))}
</ul>
</>
Expand Down
24 changes: 16 additions & 8 deletions frontend/src/RispostaNo.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import React from 'react';

function RispostaNo({dati}) {
function RispostaNo({ dati }) {
return (
<div>
<h1>No. L'ultimo episodio è uscito {dati.giorni_fa}, {dati.data_italiano}.</h1>
{ dati.rompi_le_palle ?
<h2><em>Mi duole ammetterlo ma è giunto il momento di protestare!</em></h2> :
<h2><em>Però adesso non torturare Zampa, aspetta ancora qualche giorno…</em></h2>
}
<h1>
No. L&apos;ultimo episodio è uscito {dati.giorni_fa},{" "}
{dati.data_italiano}.
</h1>
{dati.rompi_le_palle ? (
<h2>
<em>Mi duole ammetterlo ma è giunto il momento di protestare!</em>
</h2>
) : (
<h2>
<em>
Però adesso non torturare Zampa, aspetta ancora qualche giorno…
</em>
</h2>
)}
</div>
);
}
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/RispostaSi.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react';

function RispostaSi({ dati }) {
return (
<h1>
Sì! È uscito <span title={dati.data_italiano}>{dati.giorni_fa}</span> <u>
l'episodio</u> numero {dati.ep_num} di Joypad, dal titolo <em>«{dati.titolo}»</em>
Sì! È uscito <span title={dati.data_italiano}>{dati.giorni_fa}</span>{" "}
<u>l&apos;episodio</u> numero {dati.ep_num} di Joypad, dal titolo{" "}
<em>«{dati.titolo}»</em>
</h1>
);
}
Expand Down
136 changes: 74 additions & 62 deletions frontend/src/components/EpisodeContent/EpisodeContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,74 +4,86 @@ import classes from "./EpisodeContent.module.css";
import GameBox from "./GameBox";

const EpisodeContent = (props) => {
const [section, setSection] = useState(props.section);
const { recensioni, consigli, chiacchiere, descrizione } = props;
const [section, setSection] = useState(props.section);
const { recensioni, consigli, chiacchiere, descrizione } = props;

const createContent = (section) => {
return (
<div>
{section.map((element, index) => (
<GameBox
key={index}
titolo={element.titolo}
speaker={element.speaker}
istante={element.istante}
descrizione={element.descrizione_html}
cover={element.cover}
/>
))}
</div>
);
};
const createContent = (section) => {
return (
<div>
{section.map((element, index) => (
<GameBox
key={index}
titolo={element.titolo}
speaker={element.speaker}
istante={element.istante}
descrizione={element.descrizione_html}
cover={element.cover}
/>
))}
</div>
);
};

let sectionContent;
let sectionContent;

if (section === "recensioni") sectionContent = createContent(props.recensioni);
if (section === "consigli") sectionContent = createContent(props.consigli);
if (section === "chiacchiere") sectionContent = createContent(props.chiacchiere);
if (section === "recensioni")
sectionContent = createContent(props.recensioni);
if (section === "consigli") sectionContent = createContent(props.consigli);
if (section === "chiacchiere")
sectionContent = createContent(props.chiacchiere);

if (section === "descrizione")
sectionContent = (
<div>
<p className={classes.description}>{descrizione}</p>
</div>
);
if (section === "descrizione")
sectionContent = (
<div>
<p className={classes.description}>{descrizione}</p>
</div>
);

const sectionHandler = (section) => {
setSection(section);
};
const sectionHandler = (section) => {
setSection(section);
};

return (
<div className={classes.containerAnimation}>
<ul className={classes.controls}>
<li onClick={sectionHandler.bind(this, "descrizione")}>
<p className={`${classes.control} ${section === "descrizione" && classes.tagActive}`}>DESCRIZIONE</p>
</li>
{recensioni.length !== 0 && (
<li onClick={sectionHandler.bind(this, "recensioni")}>
<p className={`${classes.control} ${section === "recensioni" && classes.tagActive}`}>
RECENSIONI <span>{recensioni.length}</span>
</p>
</li>
)}
{consigli.length !== 0 && (
<li onClick={sectionHandler.bind(this, "consigli")}>
<p className={`${classes.control} ${section === "consigli" && classes.tagActive}`}>
CONSIGLI <span>{consigli.length}</span>
</p>
</li>
)}
{chiacchiere.length !== 0 && (
<li onClick={sectionHandler.bind(this, "chiacchiere")}>
<p className={`${classes.control} ${section === "chiacchiere" && classes.tagActive}`}>
CHIACCHIERE <span>{chiacchiere.length}</span>
</p>
</li>
)}
</ul>
<div className={classes.contentContainer}>{sectionContent}</div>
</div>
);
return (
<div className={classes.containerAnimation}>
<ul className={classes.controls}>
<li onClick={sectionHandler.bind(this, "descrizione")}>
<p
className={`${classes.control} ${section === "descrizione" && classes.tagActive}`}
>
DESCRIZIONE
</p>
</li>
{recensioni.length !== 0 && (
<li onClick={sectionHandler.bind(this, "recensioni")}>
<p
className={`${classes.control} ${section === "recensioni" && classes.tagActive}`}
>
RECENSIONI <span>{recensioni.length}</span>
</p>
</li>
)}
{consigli.length !== 0 && (
<li onClick={sectionHandler.bind(this, "consigli")}>
<p
className={`${classes.control} ${section === "consigli" && classes.tagActive}`}
>
CONSIGLI <span>{consigli.length}</span>
</p>
</li>
)}
{chiacchiere.length !== 0 && (
<li onClick={sectionHandler.bind(this, "chiacchiere")}>
<p
className={`${classes.control} ${section === "chiacchiere" && classes.tagActive}`}
>
CHIACCHIERE <span>{chiacchiere.length}</span>
</p>
</li>
)}
</ul>
<div className={classes.contentContainer}>{sectionContent}</div>
</div>
);
};

export default EpisodeContent;
2 changes: 1 addition & 1 deletion frontend/src/components/EpisodeContent/GameBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const GameBox = (props) => {
</div>
<div className={classes.timeStamp}>
<p>
{minutes}' {seconds}''
{minutes}&apos; {seconds}&apos;&apos;
</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/EpisodeItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const EpisodeItem = (props) => {

// const [active, setActive] = useState(false);

const activeHandler = (event) => {
const activeHandler = () => {
// window.scrollTo({ top: y, behavior: "smooth" });
// setActive(!active);
// setTimeout(() => {
Expand Down
Loading

0 comments on commit a7ca411

Please sign in to comment.