Skip to content

Commit

Permalink
Merge pull request #127 from NetSepio/rushikesh-peaq
Browse files Browse the repository at this point in the history
fix : ui usernode page
  • Loading branch information
Rushikeshnimkar committed Sep 12, 2024
2 parents 1c62a4f + 92cfabf commit ed432b6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 13 deletions.
31 changes: 29 additions & 2 deletions components/nodedataDwifiUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Link from "next/link";
import { ethers } from 'ethers';
import contractABI from '../components/peaqabi/contractABI.json';


const contractAddress = '0x5940445e1e8A419ebea10B45c5d1C0F603926F41';

const NodeDwifiStreamUser = () => {
Expand All @@ -16,6 +17,7 @@ const NodeDwifiStreamUser = () => {
const [error, setError] = useState(null);
const [editingNode, setEditingNode] = useState(null);
const [isSaving, setIsSaving] = useState(false);
const [expandedLocations, setExpandedLocations] = useState({});

useEffect(() => {
checkConnection();
Expand Down Expand Up @@ -94,6 +96,13 @@ const NodeDwifiStreamUser = () => {
const handleEdit = (node) => {
setEditingNode(node);
};
const toggleLocation = (id) => {
setExpandedLocations(prev => ({
...prev,
[id]: !prev[id]
}));
};


const handleSave = async (updatedNode) => {
setError(null);
Expand Down Expand Up @@ -262,8 +271,26 @@ const NodeDwifiStreamUser = () => {
{item.isActive ? "Online" : "Offline"}
</span>
</td>
<td className="px-6 py-4 whitespace-nowrap">{item.location}</td>
<td className="px-6 py-4 whitespace-nowrap">{item.pricePerMinute} ETH</td>
<td className="px-6 py-4 whitespace-nowrap">
{expandedLocations[item.id] ? (
<span>{item.location}</span>
) : (
<span>
{item.location.length > 20
? `${item.location.slice(0, 20)}...`
: item.location}
</span>
)}
{item.location.length > 20 && (
<button
onClick={() => toggleLocation(item.id)}
className="ml-2 text-blue-500 hover:text-blue-600"
>
{expandedLocations[item.id] ? 'Show less' : 'Show more'}
</button>
)}
</td>
<td className="px-6 py-4 whitespace-nowrap">{item.pricePerMinute} AGNG</td>
<td className="px-6 py-4 whitespace-nowrap">{new Date(item.connectedAt).toLocaleString()}</td>
<td className="px-6 py-4 whitespace-nowrap">{new Date(item.lastChecked).toLocaleString()}</td>
<td className="px-6 py-4 whitespace-nowrap">
Expand Down
22 changes: 11 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ed432b6

Please sign in to comment.