Skip to content

Commit

Permalink
Add SM02 and update Opensources (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricky2563 authored Dec 25, 2024
1 parent bae20df commit a6b8998
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 6 deletions.
169 changes: 169 additions & 0 deletions components/OpenSource/SR01/SM02.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
import { useEffect, useState } from "react";

import cx from "classnames";

import { DiAtom } from "react-icons/di";
import { GiAnchor } from "react-icons/gi";
import { IoBulbOutline } from "react-icons/io5";
import { SM02Count } from "../../../interfaces";
import ClapButton from "../../Buttons/ClapButton";
import {
addCountToButton,
downloadMaterial,
removeButtonDBListeners,
startSM02ButtonDBListeners,
} from "../openSourceUtils";

const SM02 = () => {
const [countButtons, setCountButtons] = useState<SM02Count>({
esDownloadCount: 0,
hpDownloadCount: 0,
dcDownloadCount: 0,
likeCount: 0,
});

useEffect(() => {
startSM02ButtonDBListeners("sm02", setCountButtons);
return () => {
removeButtonDBListeners("sm02");
};
}, []);
return (
<div
className="section fp-noscroll"
style={{
backgroundColor: "black",
fontSize: "small",
}}
>
<div className="bg-changer">
<div
className={cx("section-bg active")}
style={{
backgroundImage: `url("/assets/images/opensource/sm02_opensource.jpg")`,
}}
></div>
</div>
<div className="container">
<div className="mt-2 text-center justify-content-center row">
<div className="col-lg-10 z-inf">
<h4 className="index-header f-700 text-white">SÃO MIGUEL 02</h4>
<hr className="divider" />
<p className="f-medium text-white">The beginning of the Hydrogen Hybrid Era is here.</p>

<ClapButton
count={countButtons.likeCount}
onClick={() => addCountToButton(countButtons.likeCount, "likeCount", "sm02")}
/>
</div>
</div>
<div className="row mt-3">
<div className="col">
<div className="item-card p-3">
<div className="icon icon-lg icon-shape bg-gradient-white shadow rounded-circle text-info">
<IoBulbOutline className="icon-lg" />
{/* <SiAtom className="icon-lg" /> */}
</div>
<h5 className="text-white mt-2 text-shadow">Electrical Systems</h5>
<ul className="opensource-list">
<li className="onsource-list-item">Printed Circuit Boards (PCBs)</li>
<li className="onsource-list-item">Source Code</li>
</ul>
<button
type="button"
className="btnd btnd-info mt-2"
onClick={() =>
downloadMaterial(
countButtons.esDownloadCount,
"esDownloadCount",
"sm02",
"https://gitlab.com/tecnico.solar.boat/2024/SM02",
)
}
>
{" "}
Download
</button>
<div>
<span className="opensource-downloads">
{countButtons.esDownloadCount} Downloads
</span>
</div>
</div>
</div>
<div className="col">
<div className="item-card p-3">
<div className="icon icon-lg icon-shape bg-gradient-white shadow rounded-circle text-info ">
<DiAtom className="icon-lg" />
</div>
<h5 className="text-white mt-2 text-shadow">{"FC & Hydrogen"}</h5>
<ul className="opensource-list">
<li className="onsource-list-item">Hydrogen Admission System</li>
<li className="onsource-list-item">Air Admission System</li>
<li className="onsource-list-item">Cooling System</li>
<li className="onsource-list-item">Simulations</li>
<li className="onsource-list-item">List of Material</li>
</ul>
<button
type="button"
className="btnd btnd-info mt-2"
onClick={() =>
downloadMaterial(
countButtons.hpDownloadCount,
"hpDownloadCount",
"sm02",
"https://tecnicosolarboat.tecnico.ulisboa.pt/OpenSource/SM02/H2/H2-SM02.zip",
)
}
>
{" "}
Download
</button>
<div>
<span className="opensource-downloads">
{countButtons.hpDownloadCount} Downloads
</span>
</div>
</div>
</div>
<div className="col">
<div className="item-card p-3">
<div className="icon icon-lg icon-shape bg-gradient-white shadow rounded-circle text-info">
<GiAnchor className="icon-lg" />
</div>
<h5 className="text-white mt-2 text-shadow">Design and Composites</h5>
<ul className="opensource-list">
<li className="onsource-list-item">{"Struture & Composite Assembly"}</li>
</ul>
<button
type="button"
className="btnd btnd-info mt-2"
onClick={() =>
downloadMaterial(
countButtons.dcDownloadCount,
"dcDownloadCount",
"sm02",
"https://tecnicosolarboat.tecnico.ulisboa.pt/OpenSource/SM02/DC/DC-SM02.zip",
)
}
>
{" "}
Download
</button>
<div>
<span className="opensource-downloads">
{countButtons.dcDownloadCount} Downloads
</span>
</div>
</div>
</div>
{/* <div className="col-lg-2"></div>
<div className="col-lg-2"></div> */}
</div>
</div>
</div>
);
};

export default SM02;
2 changes: 1 addition & 1 deletion components/OpenSource/SR01/SP01.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const SP01 = () => {
countButtons.esDownloadCount,
"esDownloadCount",
"sp01",
"https://gitlab.com/tecnico.solar.boat/2023/SP01",
"https://gitlab.com/tecnico.solar.boat/2024/SP01",
)
}
>
Expand Down
2 changes: 1 addition & 1 deletion components/OpenSource/SR01/SR03.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const SR03 = () => {
countButtons.esDownloadCount,
"esDownloadCount",
"sr03",
"https://gitlab.com/tecnico.solar.boat/2023/SR03",
"https://gitlab.com/tecnico.solar.boat/2024/SR03",
)
}
>
Expand Down
15 changes: 14 additions & 1 deletion components/OpenSource/openSourceUtils.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { off, onValue, ref, set } from "firebase/database";
import { Dispatch, SetStateAction } from "react";
import { SM01Count, SP01Count, SR01Count, SR02Count, SR03Count } from "../../interfaces";
import { SM01Count, SM02Count, SP01Count, SR01Count, SR02Count, SR03Count } from "../../interfaces";
import { db } from "../Contexts/Firebase";

/**
Expand Down Expand Up @@ -37,6 +37,18 @@ const startSMButtonDBListeners = (
});
};

const startSM02ButtonDBListeners = (
boat: string,
setCountButtons: Dispatch<SetStateAction<SM02Count>>,
) => {
onValue(ref(db, `public/officialWebsite/openSource/${boat}/buttonCount`), (snapshot) => {
const allButtonCounts: SM02Count = snapshot.val();
if (!allButtonCounts) return;
// get all photos of album
setCountButtons(allButtonCounts);
});
};

/**
* Starts listening to changes on the counts stored in the database
* @param boat
Expand Down Expand Up @@ -93,5 +105,6 @@ export {
removeButtonDBListeners,
startButtonDBListeners,
startSMButtonDBListeners,
startSM02ButtonDBListeners,
startSPButtonDBListeners,
};
7 changes: 7 additions & 0 deletions interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ export interface SM01Count {
likeCount: number;
}

export interface SM02Count {
esDownloadCount: number;
hpDownloadCount: number;
dcDownloadCount: number;
likeCount: number;
}

export interface SP01Count {
esDownloadCount: number;
dcDownloadCount: number;
Expand Down
7 changes: 5 additions & 2 deletions pages/opensource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Head from "next/head";
import { useState } from "react";
import Navbar from "../components/Navbar/Navbar";
import SM01 from "../components/OpenSource/SR01/SM01";
import SM02 from "../components/OpenSource/SR01/SM02";
import SP01 from "../components/OpenSource/SR01/SP01";
import SR01 from "../components/OpenSource/SR01/SR01";
import SR02 from "../components/OpenSource/SR01/SR02";
Expand All @@ -24,8 +25,9 @@ const OpenSource = () => {
responsiveWidth={1250}
navigationTooltips={[
"2023-present - SP 01",
"2020-present - SM 01",
"2021-present - SR 03",
"2024-present - SM 02",
"2020-2023 - SM 01",
"2021-2024 - SR 03",
"2018-2020 - SR 02",
"2016-2018 - SR 01",
]}
Expand All @@ -36,6 +38,7 @@ const OpenSource = () => {
return (
<ReactFullpage.Wrapper>
<SP01 />
<SM02 />
<SM01 />
<SR03 />
<SR02 />
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tsconfig.tsbuildinfo

Large diffs are not rendered by default.

0 comments on commit a6b8998

Please sign in to comment.