Skip to content

Commit

Permalink
feat HeaderComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
tschanomis committed Jan 24, 2025
1 parent 4df82c2 commit 9d14042
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 40 deletions.
36 changes: 36 additions & 0 deletions front/src/app/components/headerComponent/HeaderComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faTelegram } from "@fortawesome/free-brands-svg-icons";

import Status from "../statusComponent/StatusComponent";

import { StatusProps } from "../statusComponent/type";

export default function HeaderComponent({
error,
data,
connectionRestored,
setConnectionRestored,
lastMessage,
}: StatusProps) {
return (
<div className="HeaderComponent flex justify-evenly w-full">
<div className="flex flex-col justify-center">
<div>Receive notifications on Telegram</div>
<a className="flex text-blue-400 space-x-1" href="https://t.me/KimsufiNotifierBot">
<div>
<FontAwesomeIcon icon={faTelegram} />
</div>
<div>t.me/KimsufiNotifierBot</div>
</a>
</div>
<h1 className="text-center text-xl font-bold">OVH Eco server availability</h1>
<Status
error={error}
data={data}
connectionRestored={connectionRestored}
setConnectionRestored={setConnectionRestored}
lastMessage={lastMessage}
/>
</div>
);
}
11 changes: 3 additions & 8 deletions front/src/app/components/statusComponent/StatusComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@ export default function Status({

const loaderDisplay: ReactNode = <div>Loading ...</div>;

const restoredDisplay: ReactNode = (
<div className="text-green-700">Websocket connected</div>
);
const restoredDisplay: ReactNode = <div className="text-green-700">Websocket connected</div>;

const lastMessageDisplay: ReactNode = (
<div>
Last update received at{" "}
{new Date(lastMessage).toTimeString().split(" ")[0]}
</div>
<div>Last update received at {new Date(lastMessage).toTimeString().split(" ")[0]}</div>
);

// Display error message
Expand All @@ -46,7 +41,7 @@ export default function Status({
return (
<div
className={`
basis-1/4 flex flex-col justify-center font-mono
flex flex-col justify-center font-mono
${!statusDisplay ? "hidden" : ""}
${connectionRestored ? fadeOut : ""}
`}
Expand Down
44 changes: 12 additions & 32 deletions front/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

import { useState } from "react";
import useWebSocket from "react-use-websocket";

import ServersTable from "./components/server";
import Status from "./components/statusComponent/StatusComponent";
import { Server, ErrorNull } from "./components/types";
import HeaderComponent from "./components/headerComponent/HeaderComponent";

import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faTelegram } from "@fortawesome/free-brands-svg-icons";
import { Server, ErrorNull } from "./components/types";

export default function Home() {
// Get the websocket URL from the environment variable
Expand Down Expand Up @@ -42,34 +41,15 @@ export default function Home() {
});

return (
<div className="flex flex-row justify-center">
<div className="pt-10 pb-20 px-10">
<div className="flex flex-row min-w-fit justify-center flex-nowrap text-nowrap">
<div className="basis-1/4 flex flex-col justify-center items-center">
<div>Receive notifications on Telegram</div>
<a
className="flex text-blue-400 space-x-1"
href="https://t.me/KimsufiNotifierBot"
>
<div>
<FontAwesomeIcon icon={faTelegram} />
</div>
<div>t.me/KimsufiNotifierBot</div>
</a>
</div>
<div className="basis-2/4 px-40 py-5 flex-none text-center text-xl font-bold">
OVH Eco server availability
</div>
<Status
error={error}
data={data}
connectionRestored={connectionRestored}
setConnectionRestored={setConnectionRestored}
lastMessage={lastMessage}
/>
</div>
<ServersTable data={data} />
</div>
<div className="Home flex flex-col items-center pt-10 pb-20 px-10 max-w-7xl mx-auto">
<HeaderComponent
error={error}
data={data}
connectionRestored={connectionRestored}
setConnectionRestored={setConnectionRestored}
lastMessage={lastMessage}
/>
<ServersTable data={data} />
</div>
);
}

0 comments on commit 9d14042

Please sign in to comment.