Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
RojhatToptamus committed Jun 23, 2024
1 parent 3d38338 commit 3c60df5
Show file tree
Hide file tree
Showing 12 changed files with 494 additions and 432 deletions.
156 changes: 102 additions & 54 deletions packages/nextjs/app/dashboard/attestation/[uid]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,90 +1,138 @@
'use client'
"use client";
import React, { useState, useEffect } from "react";
import { useRouter,useSearchParams } from "next/navigation";
import { fetchAttestation,Attestation } from "~~/utils/utils";
import { useRouter, useSearchParams } from "next/navigation";
import { fetchAttestation, Attestation } from "~~/utils/utils";

export default function AttestationPage({
params,
}: {
params: { uid: string };
}) {
const uid = params.uid;
const [attestation, setAttestation] = useState<Attestation | null>(null);

useEffect(() => {
console.log("UUID:", uid);
if (uid) {
fetchAttestation(uid)
.then((data) => {
console.log("Fetched data:", data);
setAttestation(data);
})
.catch((error) => {
console.error("Error fetching attestation:", error);
});
}
}, [uid]);

export default function AttestationPage({ params }: { params: { uid: string } }) {
const uid = params.uid;
const [attestation, setAttestation] = useState<Attestation | null>(null);

useEffect(() => {
console.log('UUID:', uid);
if (uid) {
fetchAttestation(uid)
.then(data => {
console.log('Fetched data:', data);
setAttestation(data);
})
.catch(error => {
console.error('Error fetching attestation:', error);
});
}
}, [uid]);

if (!attestation) {
return <div>Loading...</div>;
}

return (
<div className="attestation-container p-6 shadow-md rounded-lg bg-[#E9E9F6]">
if (!attestation) {
return <div>Loading...</div>;
}

return (
<div className="attestation-container p-6 shadow-md rounded-lg bg-[#E9E9F6]">
<div className="mb-4">
<span className="block text-sm text-gray-600">UID:</span>
<span className="block text-lg font-semibold text-gray-600">{attestation.uid}</span>
<span className="block text-lg font-semibold text-gray-600">
{attestation.uid}
</span>
</div>
<div className="border rounded-md overflow-hidden">
<table className="min-w-full bg-white">
<tbody>
<tr className="border-b">
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">Schema</td>
<td className="px-4 py-2 text-sm text-gray-900">{attestation.schema}</td>
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">
Schema
</td>
<td className="px-4 py-2 text-sm text-gray-900">
{attestation.schema}
</td>
</tr>
<tr className="border-b">
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">Is Endorsement</td>
<td className="px-4 py-2 text-sm text-gray-900">{attestation.isEndorsement ? 'True' : 'False'}</td>
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">
Is Endorsement
</td>
<td className="px-4 py-2 text-sm text-gray-900">
{attestation.isEndorsement ? "True" : "False"}
</td>
</tr>
<tr className="border-b">
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">Name</td>
<td className="px-4 py-2 text-sm text-gray-900">{attestation.name}</td>
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">
Name
</td>
<td className="px-4 py-2 text-sm text-gray-900">
{attestation.name}
</td>
</tr>
<tr className="border-b">
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">Domain</td>
<td className="px-4 py-2 text-sm text-gray-900">{attestation.domain}</td>
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">
Domain
</td>
<td className="px-4 py-2 text-sm text-gray-900">
{attestation.domain}
</td>
</tr>
<tr className="border-b">
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">Context</td>
<td className="px-4 py-2 text-sm text-gray-900">{attestation.context}</td>
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">
Context
</td>
<td className="px-4 py-2 text-sm text-gray-900">
{attestation.context}
</td>
</tr>
<tr className="border-b">
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">IPFS Hash</td>
<td className="px-4 py-2 text-sm text-gray-900"><a href={attestation.ipfsHash} className="text-blue-500">{attestation.ipfsHash}</a></td>
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">
IPFS Hash
</td>
<td className="px-4 py-2 text-sm text-gray-900">
<a href={attestation.ipfsHash} className="text-blue-500">
{attestation.ipfsHash}
</a>
</td>
</tr>
<tr className="border-b">
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">From</td>
<td className="px-4 py-2 text-sm text-gray-900">{attestation.from}</td>
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">
From
</td>
<td className="px-4 py-2 text-sm text-gray-900">
{attestation.from}
</td>
</tr>
<tr className="border-b">
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">To</td>
<td className="px-4 py-2 text-sm text-gray-900">{attestation.to}</td>
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">
To
</td>
<td className="px-4 py-2 text-sm text-gray-900">
{attestation.to}
</td>
</tr>
<tr className="border-b">
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">Created</td>
<td className="px-4 py-2 text-sm text-gray-900">{attestation.created}</td>
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">
Created
</td>
<td className="px-4 py-2 text-sm text-gray-900">
{attestation.created}
</td>
</tr>
<tr className="border-b">
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">Expiration</td>
<td className="px-4 py-2 text-sm text-gray-900">{attestation.expiration}</td>
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">
Expiration
</td>
<td className="px-4 py-2 text-sm text-gray-900">
{attestation.expiration}
</td>
</tr>
<tr>
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">Revoked</td>
<td className="px-4 py-2 text-sm text-gray-900">{attestation.revoked}</td>
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">
Revoked
</td>
<td className="px-4 py-2 text-sm text-gray-900">
{attestation.revoked}
</td>
</tr>
</tbody>
</table>
</div>
</div>
);
};


);
}
2 changes: 1 addition & 1 deletion packages/nextjs/app/dashboard/attestations/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import React, { useState, useEffect } from "react";
import Link from "next/link";
import { fetchAllAttestations, fetchStats, shortAddress} from "~~/utils/utils";
import { fetchAllAttestations, fetchStats, shortAddress } from "~~/utils/utils";
import Modal from "~~/components/Modal";
import CreateAttestationForm from "~~/components/forms/CreateAttestationForm";
const Dashboard = () => {
Expand Down
10 changes: 5 additions & 5 deletions packages/nextjs/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const Dashboard = () => {
return (
<div>
<div className="p-4">
<p>Welcome to Dashboard!</p>
<Link href="/dashboard/attestations">Attestations</Link>
<br></br>
<br></br>
<Link href="/dashboard/schemas">Schemas</Link>
<p>Welcome to Dashboard!</p>
<Link href="/dashboard/attestations">Attestations</Link>
<br></br>
<br></br>
<Link href="/dashboard/schemas">Schemas</Link>
</div>
</div>
);
Expand Down
92 changes: 53 additions & 39 deletions packages/nextjs/app/dashboard/schema/[uid]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,59 +1,73 @@
'use client'
"use client";
import React, { useState, useEffect } from "react";
import { useRouter,useSearchParams } from "next/navigation";
import { fetchSchema,Schema } from "~~/utils/utils";
import { useRouter, useSearchParams } from "next/navigation";
import { fetchSchema, Schema } from "~~/utils/utils";

export default function AttestationPage({
params,
}: {
params: { uid: string };
}) {
const uid = params.uid;
const [schema, setSchema] = useState<Schema | null>(null);

useEffect(() => {
console.log("UUID:", uid);
if (uid) {
fetchSchema(uid)
.then((data) => {
console.log("Fetched data:", data);
setSchema(data);
})
.catch((error) => {
console.error("Error fetching schema:", error);
});
}
}, [uid]);

export default function AttestationPage({ params }: { params: { uid: string } }) {
const uid = params.uid;
const [schema, setSchema] = useState<Schema | null>(null);

useEffect(() => {
console.log('UUID:', uid);
if (uid) {
fetchSchema(uid)
.then(data => {
console.log('Fetched data:', data);
setSchema(data);
})
.catch(error => {
console.error('Error fetching schema:', error);
});
}
}, [uid]);

if (!schema) {
return <div>Loading...</div>;
}

return (
<div className="attestation-container p-6 shadow-md rounded-lg bg-[#E9E9F6]">
if (!schema) {
return <div>Loading...</div>;
}

return (
<div className="attestation-container p-6 shadow-md rounded-lg bg-[#E9E9F6]">
<div className="mb-4">
<span className="block text-sm text-gray-600">UID:</span>
<span className="block text-lg font-semibold text-gray-600">{schema.uid}</span>
<span className="block text-lg font-semibold text-gray-600">
{schema.uid}
</span>
</div>
<div className="border rounded-md overflow-hidden">
<table className="min-w-full bg-white">
<tbody>
<tr className="border-b">
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">UID</td>
<td className="px-4 py-2 text-sm text-gray-900">{schema.uid ? 'True' : 'False'}</td>
<tr className="border-b">
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">
UID
</td>
<td className="px-4 py-2 text-sm text-gray-900">
{schema.uid ? "True" : "False"}
</td>
</tr>

<tr className="border-b">
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">Schema</td>
<td className="px-4 py-2 text-sm text-gray-900">{schema.schema}</td>
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">
Schema
</td>
<td className="px-4 py-2 text-sm text-gray-900">
{schema.schema}
</td>
</tr>
<tr className="border-b">
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">Attestations</td>
<td className="px-4 py-2 text-sm text-gray-900">{schema.attestations ? 'True' : 'False'}</td>
<td className="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-50">
Attestations
</td>
<td className="px-4 py-2 text-sm text-gray-900">
{schema.attestations ? "True" : "False"}
</td>
</tr>
</tbody>
</table>
</div>
</div>
);
};


);
}
4 changes: 2 additions & 2 deletions packages/nextjs/components/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode, ReactElement, useState } from 'react';
import React, { ReactNode, ReactElement, useState } from "react";

interface ModalProps {
children: ReactNode;
Expand Down Expand Up @@ -31,4 +31,4 @@ const Modal: React.FC<ModalProps> = ({ children, trigger }) => {
);
};

export default Modal;
export default Modal;
7 changes: 4 additions & 3 deletions packages/nextjs/components/forms/CreateAttestationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useEffect } from "react";
import { useRouter } from "next/navigation";
import { useScaffoldReadContract } from "~~/hooks/scaffold-stark/useScaffoldReadContract";
import { useAccount, useContractRead } from "@starknet-react/core";
import {displayTxResult} from "~~/app/debug/_components/contract/utilsDisplay";
import { displayTxResult } from "~~/app/debug/_components/contract/utilsDisplay";
import ERC20_ABI from "~~/utils/solas-abis/ERC20.json";

const CreateAttestationForm = () => {
Expand Down Expand Up @@ -128,8 +128,9 @@ const CreateAttestationForm = () => {
//@ts-ignore
{isLoading && <div>Loading ...</div>}
{isError || (!data && <div>{error?.message}</div>)}

{data && <div className="text-blue-900">{displayTxResult(data, false)}</div>}
{data && (
<div className="text-blue-900">{displayTxResult(data, false)}</div>
)}
</div>
);
};
Expand Down
Loading

0 comments on commit 3c60df5

Please sign in to comment.