From 20cd7c6a17e41f60afe4f6037ebfd7333be956bf Mon Sep 17 00:00:00 2001 From: Kevin Mulcrone Date: Fri, 14 Oct 2022 02:03:48 -0400 Subject: [PATCH] feat(Labels): add tags to AddressRow --- .../Vault/Settings/Addresses/AddressRow.tsx | 70 +++++++++++++------ .../Vault/Settings/Addresses/LabelTag.tsx | 26 ++++--- 2 files changed, 63 insertions(+), 33 deletions(-) diff --git a/apps/frontend/src/pages/Vault/Settings/Addresses/AddressRow.tsx b/apps/frontend/src/pages/Vault/Settings/Addresses/AddressRow.tsx index 76bf8e01..4f72f847 100644 --- a/apps/frontend/src/pages/Vault/Settings/Addresses/AddressRow.tsx +++ b/apps/frontend/src/pages/Vault/Settings/Addresses/AddressRow.tsx @@ -1,12 +1,15 @@ -import React from 'react'; +import React, { useContext, useEffect, useState } from 'react'; import styled from 'styled-components'; import { Badge } from 'src/components'; +import { LabelTag } from './LabelTag'; + import { gray500 } from 'src/utils/colors'; import { classNames } from 'src/utils/other'; -import { Address } from '@lily/types'; +import { Address, AddressLabel } from '@lily/types'; +import { PlatformContext } from 'src/context'; interface Props { address: Address; @@ -14,26 +17,49 @@ interface Props { onClick: () => void; } -const AddressRow = ({ address, status, onClick }: Props) => ( - onClick()}> - - {address.address} - {address.bip32derivation[0].path} - - - - {status} - - - -); +const AddressRow = ({ address, status, onClick }: Props) => { + const { platform } = useContext(PlatformContext); + const [labels, setLabels] = useState([]); + + useEffect(() => { + const retrieveLabels = async () => { + const currentLabels = await platform.getAddressLabels(address.address); + setLabels(currentLabels); + }; + retrieveLabels(); + }, [address]); + + return ( + onClick()} + > + + {address.address} + {/* {address.bip32derivation[0].path} */} + + + + + {status} + + + + ); +}; const UtxoHeader = styled.div` font-size: 0.875rem; diff --git a/apps/frontend/src/pages/Vault/Settings/Addresses/LabelTag.tsx b/apps/frontend/src/pages/Vault/Settings/Addresses/LabelTag.tsx index 3c06c2bd..cb7c7dbd 100644 --- a/apps/frontend/src/pages/Vault/Settings/Addresses/LabelTag.tsx +++ b/apps/frontend/src/pages/Vault/Settings/Addresses/LabelTag.tsx @@ -4,23 +4,27 @@ import { AddressLabel } from '@lily/types'; interface Props { label: AddressLabel; - deleteLabel: (id: number) => void; + deleteLabel?: (id: number) => void; } export const LabelTag = ({ label, deleteLabel }: Props) => { return ( {label.label} - + {deleteLabel ? ( + + ) : null} ); };