Skip to content

Commit

Permalink
feat: when table row clicked right side panel appear
Browse files Browse the repository at this point in the history
  • Loading branch information
Mlowegene committed Mar 15, 2024
1 parent 541a3e0 commit 1b6715a
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/pages/TrustRelationship/TrustRelationshipTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
TableCellStyled,
TooltipStyled,
} from '../MyTransfers/TransfersTable.styled';
import TrustRelationshipSidePanel from './trustRelationshipSidePanel';

const TrustRelationshipTableHeader = ({ tableTitle }) => {
return (
Expand Down Expand Up @@ -131,9 +132,19 @@ const TrustRelationshipTableBody = ({ tableColumns, tableRows }) => {
// State to track the index of the selected row
const [selectedRowIndex, setSelectedRowIndex] = useState(null);

// Function to handle row click
// state to track if side panel is open when you click the row on table
const [isSidePanelOpen, setIsSidePanelOpen] = useState(false);

// Function to handle row click and open side panel
const handleRowClick = (rowIndex) => {
setSelectedRowIndex(rowIndex);
setIsSidePanelOpen(true);
};

//function to close side panel
const handleClosePanel = () => {
setIsSidePanelOpen(false);
setSelectedRowIndex(null);
};

const { isLoading } = useTrustRelationshipsContext();
Expand All @@ -160,6 +171,7 @@ const TrustRelationshipTableBody = ({ tableColumns, tableRows }) => {
);

return (
<>
<TableBody>
{sortedTableRows &&
sortedTableRows.map((row, rowIndex) => {
Expand Down Expand Up @@ -204,6 +216,14 @@ const TrustRelationshipTableBody = ({ tableColumns, tableRows }) => {
);
})}
</TableBody>
{isSidePanelOpen && (
<TrustRelationshipSidePanel
open={open}
onClose={handleClosePanel}
/>
)}

</>
);
};

Expand Down
52 changes: 52 additions & 0 deletions src/pages/TrustRelationship/trustRelationshipSidePanel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {
Typography,
Button,
IconButton,
List,
ListItem,
ListItemText
} from '@mui/material';
import { DrawerStyled, DrawerHeaderStyled } from '../../components/layout/Menu/MenuStyled.js';
import CloseIcon from '@mui/icons-material/Close';

function TrustRelationshipSidePanel({ open, onClose }) {
return (
<DrawerStyled variant="permanent" open={open} anchor="right" sx={{ zIndex: 10 }}>
<DrawerHeaderStyled>
<IconButton onClick={onClose}>
<CloseIcon />
</IconButton>
</DrawerHeaderStyled>

<Typography variant="h4" sx={{fontWeight:'700', marginLeft: '2rem'}}>Establish Trust</Typography>
<Typography variant="h4" sx={{fontWeight:'700', marginLeft: '2rem'}}>Relationship</Typography>

<List>
<ListItem>
<ListItemText primary="Source Wallet" secondary="WalletZ" />
</ListItem>

<ListItem>
<ListItemText primary="Target Wallet" secondary="WalletX" />
</ListItem>

<ListItem>
<ListItemText primary="Initiated By" secondary="WalletX" />
</ListItem>

<ListItem>
<ListItemText primary="Request Type" secondary="Send" />
</ListItem>
</List>

<Button variant="contained" color="primary">
Accept
</Button>
<Button variant="outlined">
Decline
</Button>
</DrawerStyled>
);
}

export default TrustRelationshipSidePanel;

0 comments on commit 1b6715a

Please sign in to comment.