Skip to content

Commit

Permalink
feat: Add a title to the website pages (#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
alainncls authored Dec 20, 2023
1 parent 63e988c commit 2e1164c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 17 deletions.
6 changes: 3 additions & 3 deletions website/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ function App() {
<Navbar />
</header>
<Routes>
<Route path="*" element={<Home />} />
<Route path="/sdk-demo" element={<SDKDemo />} />
<Route path="/linea-poh" element={<Poh />} />
<Route path="*" element={<Home title={"Verax Attestation Registry"} />} />
<Route path="/sdk-demo" element={<SDKDemo title={"Verax | SDK Demo"} />} />
<Route path="/linea-poh" element={<Poh title={"Verax | Linea POH"} />} />
</Routes>
<footer>
<Footer />
Expand Down
18 changes: 14 additions & 4 deletions website/src/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import veraxLogo from "../assets/verax-logo-circle.svg";
import "./Home.css";
import { type FunctionComponent, useEffect } from "react";

function Home() {
export type HomeProps = {
title: string;
};

export const Home: FunctionComponent<HomeProps> = ({ title }) => {
useEffect(() => {
document.title = title;
}, [title]);

return (
<>
Expand All @@ -12,10 +20,12 @@ function Home() {
</div>

<h1>Verax Attestation Registry</h1>
<p>Verax is a shared registry for storing attestations of public interest on EVM chains,<br /> designed to enhance
data discoverability and consumption for dApps across the network. </p>
<p>
Verax is a shared registry for storing attestations of public interest on EVM chains,
<br /> designed to enhance data discoverability and consumption for dApps across the network.{" "}
</p>
</>
);
}
};

export default Home;
13 changes: 11 additions & 2 deletions website/src/pages/Poh.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import type { FunctionComponent } from "react";
import { useEffect, useState } from "react";
import "./Poh.css";
import { ConnectKitButton } from "connectkit";
import axios from "axios";
import { useAccount } from "wagmi";
import { Link } from "react-router-dom";

export type PohProps = {
title: string;
};

type IssuerAttestation = {
validated: boolean;
issuerName: string;
Expand All @@ -20,7 +25,7 @@ type POHResponse = {
attestations: IssuerAttestation[];
};

function Poh() {
export const Poh: FunctionComponent<PohProps> = ({ title }) => {
const [pohGroupA, setPohGroupA] = useState<IssuerAttestation[]>();
const [pohGroupB, setPohGroupB] = useState<IssuerAttestation[]>();
const [isPoh, setIsPoh] = useState<boolean>();
Expand All @@ -35,6 +40,10 @@ function Poh() {
setPohGroupB(undefined);
};

useEffect(() => {
document.title = title;
}, [title]);

useEffect(() => {
const getMyPoh = async () => {
const { data } = await axios.get<POHResponse>(`https://linea-xp-poh-api.linea.build/poh/${address}`, {
Expand Down Expand Up @@ -116,6 +125,6 @@ function Poh() {
)}
</>
);
}
};

export default Poh;
27 changes: 19 additions & 8 deletions website/src/pages/SDKDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { useEffect, useState } from "react";
import { type FunctionComponent, useEffect, useState } from "react";
import "./SDKDemo.css";
import { ConnectKitButton } from "connectkit";
import { Attestation, VeraxSdk } from "@verax-attestation-registry/verax-sdk";
import { useAccount, useNetwork } from "wagmi";

function SDKDemo() {
export type SDKDemoProps = {
title: string;
};

export const SDKDemo: FunctionComponent<SDKDemoProps> = ({ title }) => {
const [attestations, setAttestations] = useState<Attestation[]>([]);
const [attestationsCounter, setAttestationsCounter] = useState<number>(0);
const [txHash, setTxHash] = useState<string>("");
Expand All @@ -14,9 +18,14 @@ function SDKDemo() {
const { address, isConnected } = useAccount();
const { chain } = useNetwork();

useEffect(() => {
document.title = title;
}, [title]);

useEffect(() => {
if (chain && address) {
const sdkConf = chain.id === 59144 ? VeraxSdk.DEFAULT_LINEA_MAINNET_FRONTEND : VeraxSdk.DEFAULT_LINEA_TESTNET_FRONTEND;
const sdkConf =
chain.id === 59144 ? VeraxSdk.DEFAULT_LINEA_MAINNET_FRONTEND : VeraxSdk.DEFAULT_LINEA_TESTNET_FRONTEND;
const sdk = new VeraxSdk(sdkConf, address);
setVeraxSdk(sdk);
}
Expand Down Expand Up @@ -67,7 +76,6 @@ function SDKDemo() {
}
};


return (
<>
<h1>Verax - SDK Demo</h1>
Expand All @@ -80,8 +88,9 @@ function SDKDemo() {
{attestations.length > 0 && (
<>
{attestations.map((attestation) => (
<pre
key={attestation.id}>ID = {shortenHexString(attestation.id)} - Subject = {shortenHexString(attestation.subject)}</pre>
<pre key={attestation.id}>
ID = {shortenHexString(attestation.id)} - Subject = {shortenHexString(attestation.subject)}
</pre>
))}
</>
)}
Expand All @@ -93,12 +102,14 @@ function SDKDemo() {
</div>

<div className="card">
<button onClick={createAnAttestation} disabled={!isConnected}>Create an attestation via a Portal</button>
<button onClick={createAnAttestation} disabled={!isConnected}>
Create an attestation via a Portal
</button>
{txHash !== "" && <p>{`Transaction with hash ${txHash} sent!`}</p>}
{error !== "" && <p style={{ color: "red" }}>{error}</p>}
</div>
</>
);
}
};

export default SDKDemo;

0 comments on commit 2e1164c

Please sign in to comment.