-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
498e96c
commit 5441cb1
Showing
5 changed files
with
233 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
daostar-website/src/components/ENSCard/AttestationCard.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
.attestation-card { | ||
position: relative; | ||
width: 100%; | ||
min-height: 100px; | ||
} | ||
|
||
.attestation-card h3 { | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
} | ||
|
||
.card-metadata { | ||
padding: 12px 24px; | ||
word-wrap: break-word; | ||
overflow-wrap: break-word; | ||
} | ||
|
||
.card-metadata p { | ||
line-height: 1.5; | ||
} | ||
|
||
.card-metadata h6 { | ||
font-weight: 400; | ||
color: #9c9c9c; | ||
margin: 0; | ||
|
||
} | ||
|
||
.card-metadata-value { | ||
max-width: 65%; | ||
text-overflow: ellipsis; | ||
word-wrap: break-word; | ||
overflow-wrap: break-word; | ||
white-space: nowrap; | ||
display: inline-block; | ||
vertical-align: bottom; | ||
} | ||
|
||
.card-metadata-item svg { | ||
position: relative; | ||
top: -4px; | ||
left: 4px; | ||
} | ||
|
||
.card-metadata-row { | ||
margin: 18px 24px 0 0; | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
|
||
a.card-link { | ||
border-bottom: 0; | ||
} | ||
|
||
.card-link .bp4-card { | ||
border: 1px solid var(--card-border); | ||
} | ||
|
||
.card-link .bp4-card:hover { | ||
background-color: #3b3b3b; | ||
color: inherit; | ||
border: 1px solid var(--card-border-hover); | ||
} | ||
|
||
.edit-reg-btn { | ||
position: absolute; | ||
top: 20px; | ||
right: 24px; | ||
} |
124 changes: 124 additions & 0 deletions
124
daostar-website/src/components/ENSCard/AttestationCard.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import React, { useState, Fragment } from 'react'; | ||
import { Button, Card, Divider, FormGroup, Spinner } from '@blueprintjs/core'; | ||
import EtherscanLink from "../RegistrationCard/DisplayRegistration/EtherscanLink/EtherscanLink"; | ||
import './AttestationCard.css' | ||
import { Link } from 'react-router-dom'; | ||
|
||
const DisplayAttestation = ({ | ||
id, | ||
key, | ||
value, | ||
|
||
}) => { | ||
const decodedData = JSON.parse(decodedDataJson); | ||
|
||
const renderEtherscanLink = (address) => ( | ||
<EtherscanLink address={address} /> | ||
); | ||
|
||
const formatTime = (timestamp) => { | ||
return new Date(timestamp * 1000).toLocaleString(); | ||
}; | ||
|
||
//Extract DAO Name | ||
const daoName = decodedData.find(item => item.name === "daoName")?.value.value || "Unknown DAO"; | ||
const daoURI = decodedData.find(item => item.name === "daoURI")?.value.value || "https://daostar.org/registration"; | ||
|
||
let decodedDataArray = Array.isArray(decodedData) ? decodedData : [decodedData]; | ||
function ensureArray(data) { | ||
if (!data) return []; // Return an empty array if data is falsy (e.g., undefined or null) | ||
return Array.isArray(data) ? data : [data]; | ||
} | ||
|
||
decodedDataArray = ensureArray(decodedData); | ||
|
||
return ( | ||
<Card | ||
className='wizard-card attestation-card' | ||
> | ||
<Fragment> | ||
<h3>{daoName}</h3> | ||
|
||
{standalone === true && ( | ||
<Button | ||
className="edit-reg-btn" | ||
icon="edit" | ||
text="Edit" | ||
onClick={onClickEdit} | ||
/> | ||
)} | ||
<Divider /> | ||
<div className="card-metadata"> | ||
<p className="bp4-text-small wizard-no-margin"> | ||
<span className="bp4-text-muted">Attestation ID: </span> | ||
{id} | ||
</p> | ||
<p className="bp4-text-small wizard-no-margin"> | ||
<span className="bp4-text-muted">Recipient Address: </span> | ||
{renderEtherscanLink(recipient)} | ||
</p> | ||
<p className="bp4-text-small wizard-no-margin"> | ||
<span className="bp4-text-muted">Attester Address: </span> | ||
{renderEtherscanLink(attester)} | ||
</p> | ||
<p className="bp4-text-small wizard-no-margin"> | ||
<span className="bp4-text-muted">Time: </span> | ||
<span className="card-metadata-value">{formatTime(time)}</span> | ||
</p> | ||
<p className="bp4-text-small wizard-no-margin"> | ||
<span className="bp4-text-muted">Expiration Time: </span> | ||
<span className="card-metadata-value">{expirationTime ? formatTime(expirationTime) : 'None'}</span> | ||
</p> | ||
<p className="bp4-text-small wizard-no-margin"> | ||
<span className="bp4-text-muted">Revocable: </span> | ||
<span className="card-metadata-value">{revocable ? 'Yes' : 'No'}</span> | ||
</p> | ||
<p className="bp4-text-small wizard-no-margin"> | ||
<span className="bp4-text-muted">Revoked: </span> | ||
<span className="card-metadata-value">{revoked ? 'Yes' : 'No'}</span> | ||
</p> | ||
<p className="bp4-text-small wizard-no-margin"> | ||
<span className="bp4-text-muted">Schema ID: </span> | ||
{schemaId} | ||
</p> | ||
<p className="bp4-text-small wizard-no-margin"> | ||
<span className="bp4-text-muted">IPFS Hash: </span> | ||
{ipfsHash} | ||
</p> | ||
|
||
<p className="bp4-text-small wizard-no-margin"> | ||
<span className="bp4-text-muted">Offchain: </span> | ||
<span className="card-metadata-value">{isOffchain ? 'Yes' : 'No'}</span> | ||
</p> | ||
<Divider style={{ marginTop: '5px', marginBottom: '5px'}}/> | ||
<p className="bp4-text-small wizard-no-margin"> | ||
<span className="bp4-text-muted">DAO URI: </span> | ||
<Link target='_blank' to={daoURI}>{daoURI}</Link> | ||
</p> | ||
</div> | ||
<Divider /> | ||
<div className="card-metadata"> | ||
<h6>Decoded Data:</h6> | ||
{decodedDataArray.map((item, index) => { | ||
let value; | ||
if (item.name === 'networkID') { | ||
// Convert hex to decimal for networkID | ||
value = parseInt(item.value?.value?.hex ?? item.value?.value, 16).toString(); | ||
} else { | ||
// For other items, use the original logic to determine the value | ||
value = item.value?.value?.hex ?? item.value?.value ?? 'N/A'; | ||
} | ||
return ( | ||
<p key={index} className="bp4-text-large" style={{ marginBottom: '10px' }}> | ||
<strong>{item.name}:</strong> {value} | ||
</p> | ||
); | ||
})} | ||
</div> | ||
|
||
</Fragment> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default DisplayAttestation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters